fix PIByteArray load/store operators for containers

This commit is contained in:
2020-10-16 12:28:57 +03:00
parent 51775a5ee6
commit 8ef4c9ca23
5 changed files with 96 additions and 106 deletions

View File

@@ -197,8 +197,8 @@ inline PIByteArray & operator <<(PIByteArray & s, const PIByteArray::RawData & v
return s;
}
//! \relatesalso PIByteArray \brief Store operator for PIVector of any trivial copyable type
template<typename T, typename std::enable_if< std::is_trivially_copyable<T>::value, int>::type = 0>
//! \relatesalso PIByteArray \brief Store operator for PIVector of any fundamental type
template<typename T, typename std::enable_if< std::is_fundamental<T>::value, int>::type = 0>
inline PIByteArray & operator <<(PIByteArray & s, const PIVector<T> & v) {
s << int(v.size_s());
int os = s.size_s();
@@ -209,8 +209,8 @@ inline PIByteArray & operator <<(PIByteArray & s, const PIVector<T> & v) {
return s;
}
//! \relatesalso PIByteArray \brief Store operator for PIDeque of any trivial copyable type
template<typename T, typename std::enable_if< std::is_trivially_copyable<T>::value, int>::type = 0>
//! \relatesalso PIByteArray \brief Store operator for PIDeque of any fundamental type
template<typename T, typename std::enable_if< std::is_fundamental<T>::value, int>::type = 0>
inline PIByteArray & operator <<(PIByteArray & s, const PIDeque<T> & v) {
s << int(v.size_s());
int os = s.size_s();
@@ -221,8 +221,8 @@ inline PIByteArray & operator <<(PIByteArray & s, const PIDeque<T> & v) {
return s;
}
//! \relatesalso PIByteArray \brief Store operator for PIVector2D of any trivial copyable type
template<typename T, typename std::enable_if< std::is_trivially_copyable<T>::value, int>::type = 0>
//! \relatesalso PIByteArray \brief Store operator for PIVector2D of any fundamental type
template<typename T, typename std::enable_if< std::is_fundamental<T>::value, int>::type = 0>
inline PIByteArray & operator <<(PIByteArray & s, const PIVector2D<T> & v) {
s << int(v.rows()) << int(v.cols());
int os = s.size_s();
@@ -277,8 +277,8 @@ inline PIByteArray & operator >>(PIByteArray & s, PIByteArray::RawData v) {
return s;
}
//! \relatesalso PIByteArray \brief Restore operator for PIVector of any trivial copyable type
template<typename T, typename std::enable_if< std::is_trivially_copyable<T>::value, int>::type = 0>
//! \relatesalso PIByteArray \brief Restore operator for PIVector of any fundamental type
template<typename T, typename std::enable_if< std::is_fundamental<T>::value, int>::type = 0>
inline PIByteArray & operator >>(PIByteArray & s, PIVector<T> & v) {
assert(s.size_s() >= 4);
int sz; s >> sz;
@@ -290,8 +290,8 @@ inline PIByteArray & operator >>(PIByteArray & s, PIVector<T> & v) {
return s;
}
//! \relatesalso PIByteArray \brief Restore operator for PIDeque of any trivial copyable type
template<typename T, typename std::enable_if< std::is_trivially_copyable<T>::value, int>::type = 0>
//! \relatesalso PIByteArray \brief Restore operator for PIDeque of any fundamental type
template<typename T, typename std::enable_if< std::is_fundamental<T>::value, int>::type = 0>
inline PIByteArray & operator >>(PIByteArray & s, PIDeque<T> & v) {
assert(s.size_s() >= 4);
int sz; s >> sz;
@@ -303,8 +303,8 @@ inline PIByteArray & operator >>(PIByteArray & s, PIDeque<T> & v) {
return s;
}
//! \relatesalso PIByteArray \brief Restore operator for PIVector2D of any trivial copyable type
template<typename T, typename std::enable_if< std::is_trivially_copyable<T>::value, int>::type = 0>
//! \relatesalso PIByteArray \brief Restore operator for PIVector2D of any fundamental type
template<typename T, typename std::enable_if< std::is_fundamental<T>::value, int>::type = 0>
inline PIByteArray & operator >>(PIByteArray & s, PIVector2D<T> & v) {
assert(s.size_s() >= 8);
int r, c; s >> r >> c;
@@ -330,24 +330,24 @@ inline PIByteArray & operator >>(PIByteArray & s, PIPair<Type0, Type1> & v) {s >
// store operators for complex types
//! \relatesalso PIByteArray \brief Store operator for PIVector of any non-trivial copyable type
template<typename T, typename std::enable_if<!std::is_trivially_copyable<T>::value, int>::type = 0>
//! \relatesalso PIByteArray \brief Store operator for PIVector of any compound type
template<typename T, typename std::enable_if<!std::is_fundamental<T>::value, int>::type = 0>
inline PIByteArray & operator <<(PIByteArray & s, const PIVector<T> & v) {
s << int(v.size_s());
for (uint i = 0; i < v.size(); ++i) s << v[i];
return s;
}
//! \relatesalso PIByteArray \brief Store operator for PIDeque of any non-trivial copyable type
template<typename T, typename std::enable_if<!std::is_trivially_copyable<T>::value, int>::type = 0>
//! \relatesalso PIByteArray \brief Store operator for PIDeque of any compound type
template<typename T, typename std::enable_if<!std::is_fundamental<T>::value, int>::type = 0>
inline PIByteArray & operator <<(PIByteArray & s, const PIDeque<T> & v) {
s << int(v.size_s());
for (uint i = 0; i < v.size(); ++i) s << v[i];
return s;
}
//! \relatesalso PIByteArray \brief Store operator for PIVector2D of any non-trivial copyable type
template<typename T, typename std::enable_if<!std::is_trivially_copyable<T>::value, int>::type = 0>
//! \relatesalso PIByteArray \brief Store operator for PIVector2D of any compound type
template<typename T, typename std::enable_if<!std::is_fundamental<T>::value, int>::type = 0>
inline PIByteArray & operator <<(PIByteArray & s, const PIVector2D<T> & v) {
s << int(v.rows()) << int(v.cols()) << v.toPlainVector();
return s;
@@ -359,8 +359,8 @@ inline PIByteArray & operator <<(PIByteArray & s, const PIVector2D<T> & v) {
// restore operators for complex types
//! \relatesalso PIByteArray \brief Restore operator for PIVector of any non-trivial copyable type
template<typename T, typename std::enable_if<!std::is_trivially_copyable<T>::value, int>::type = 0>
//! \relatesalso PIByteArray \brief Restore operator for PIVector of any compound type
template<typename T, typename std::enable_if<!std::is_fundamental<T>::value, int>::type = 0>
inline PIByteArray & operator >>(PIByteArray & s, PIVector<T> & v) {
assert(s.size_s() >= 4);
int sz; s >> sz;
@@ -369,8 +369,8 @@ inline PIByteArray & operator >>(PIByteArray & s, PIVector<T> & v) {
return s;
}
//! \relatesalso PIByteArray \brief Restore operator for PIDeque of any non-trivial copyable type
template<typename T, typename std::enable_if<!std::is_trivially_copyable<T>::value, int>::type = 0>
//! \relatesalso PIByteArray \brief Restore operator for PIDeque of any compound type
template<typename T, typename std::enable_if<!std::is_fundamental<T>::value, int>::type = 0>
inline PIByteArray & operator >>(PIByteArray & s, PIDeque<T> & v) {
assert(s.size_s() >= 4);
int sz; s >> sz;
@@ -379,8 +379,8 @@ inline PIByteArray & operator >>(PIByteArray & s, PIDeque<T> & v) {
return s;
}
//! \relatesalso PIByteArray \brief Restore operator for PIVector2D of any non-trivial copyable type
template<typename T, typename std::enable_if<!std::is_trivially_copyable<T>::value, int>::type = 0>
//! \relatesalso PIByteArray \brief Restore operator for PIVector2D of any compound type
template<typename T, typename std::enable_if<!std::is_fundamental<T>::value, int>::type = 0>
inline PIByteArray & operator >>(PIByteArray & s, PIVector2D<T> & v) {
assert(s.size_s() >= 8);
int r,c;

View File

@@ -159,10 +159,10 @@ private:
/*
#define REGISTER_PIVARIANTSIMPLE_STREAM(Type) \
STATIC_INITIALIZER_BEGIN() \
STATIC_INITIALIZER_BEGIN \
__VariantFunctionsBase__ * f = __VariantFunctions__<Type>().instance(); \
__VariantFunctionsBase__::registered()[f->hash()] = f; \
STATIC_INITIALIZER_END()
STATIC_INITIALIZER_END
*/