Commit 9a1f5b45 authored by Alvarez, Gonzalo's avatar Alvarez, Gonzalo
Browse files

IoNg: write mode added to some functions

parent ec259069
......@@ -211,6 +211,15 @@ public:
what.write(name2, ioNgSerializer_);
}
template<typename T>
void write(const T& what,
String name2,
IoNgSerializer::WriteMode mode,
typename EnableIf<!IsRootUnDelegated<T>::True, int*>::Type = 0)
{
what.write(name2, ioNgSerializer_, mode);
}
template<typename T>
void overwrite(const T& what,
String name2,
......
......@@ -282,12 +282,12 @@ public:
typename EnableIf<Loki::TypeTraits<typename Real<T>::Type>::isArith,
int*>::Type = 0)
{
overwriteNotSupported(allowOverwrite);
SizeType n = what.size();
createGroup(name2);
write(name2 + "/Size", n);
if (allowOverwrite != ALLOW_OVERWRITE)
createGroup(name2);
write(name2 + "/Size", n, allowOverwrite);
for (SizeType i = 0; i < n; ++i)
write(name2 + "/" + typeToString(i), what[i]);
write(name2 + "/" + typeToString(i), what[i], allowOverwrite);
}
template<typename T1, typename T2>
......@@ -309,7 +309,6 @@ public:
template<typename T>
void write(String name2,
const std::vector<T>& what,
WriteMode = NO_OVERWRITE,
typename EnableIf<!Loki::TypeTraits<typename Real<T>::Type>::isArith
&& !IsPairLike<T>::True && !IsEnumClass<T>::value, int*>::Type = 0)
{
......@@ -320,6 +319,21 @@ public:
what[i].write(name2 + "/" + typeToString(i), *this);
}
template<typename T>
void write(String name2,
const std::vector<T>& what,
WriteMode allowOverwrite,
typename EnableIf<!Loki::TypeTraits<typename Real<T>::Type>::isArith
&& !IsPairLike<T>::True && !IsEnumClass<T>::value, int*>::Type = 0)
{
SizeType n = what.size();
if (allowOverwrite != ALLOW_OVERWRITE)
createGroup(name2);
write(name2 + "/Size", n, allowOverwrite);
for (SizeType i = 0; i < n; ++i)
what[i].write(name2 + "/" + typeToString(i), *this, allowOverwrite);
}
template<typename T>
void write(String name2,
const std::vector<T>& what,
......
......@@ -149,8 +149,13 @@ public:
ioSerializer.read(data_, label + "/data_");
}
void write(String label, IoSerializer& ioSerializer) const
void write(String label,
IoSerializer& ioSerializer,
IoSerializer::WriteMode wM = IoSerializer::NO_OVERWRITE) const
{
if (wM == IoSerializer::ALLOW_OVERWRITE)
return overwrite(label, ioSerializer);
ioSerializer.createGroup(label);
ioSerializer.write(label + "/nrow_", nrow_);
ioSerializer.write(label + "/ncol_", ncol_);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment