PIByteArray works on binary stream
This commit is contained in:
@@ -96,8 +96,7 @@ namespace PIEvaluatorTypes {
|
||||
class PIP_EXPORT PIEvaluatorContent
|
||||
{
|
||||
friend class PIEvaluator;
|
||||
friend inline PIByteArray & operator <<(PIByteArray & s, const PIEvaluatorContent & v);
|
||||
friend inline PIByteArray & operator >>(PIByteArray & s, PIEvaluatorContent & v);
|
||||
BINARY_STREAM_FRIEND(PIEvaluatorContent);
|
||||
public:
|
||||
PIEvaluatorContent();
|
||||
~PIEvaluatorContent() {;}
|
||||
@@ -229,37 +228,16 @@ private:
|
||||
inline bool operator ==(PIEvaluatorTypes::Element e1, PIEvaluatorTypes::Element e2) {return (e1.type == e2.type && e1.num == e2.num);}
|
||||
inline bool operator !=(PIEvaluatorTypes::Element e1, PIEvaluatorTypes::Element e2) {return (e1.type != e2.type || e1.num != e2.num);}
|
||||
|
||||
inline PIByteArray & operator <<(PIByteArray & s, const PIEvaluatorTypes::Instruction & v) {
|
||||
s << PIByteArray::RawData(&v, sizeof(v) - sizeof(v.operators)) << v.operators;
|
||||
return s;
|
||||
}
|
||||
inline PIByteArray & operator >>(PIByteArray & s, PIEvaluatorTypes::Instruction & v) {
|
||||
s >> PIByteArray::RawData(&v, sizeof(v) - sizeof(v.operators)) >> v.operators;
|
||||
return s;
|
||||
}
|
||||
inline PIByteArray & operator <<(PIByteArray & s, const PIEvaluatorTypes::Element & v) {
|
||||
s << PIByteArray::RawData(&v, sizeof(v));
|
||||
return s;
|
||||
}
|
||||
inline PIByteArray & operator >>(PIByteArray & s, PIEvaluatorTypes::Element & v) {
|
||||
s >> PIByteArray::RawData(&v, sizeof(v));
|
||||
return s;
|
||||
}
|
||||
inline PIByteArray & operator <<(PIByteArray & s, const PIEvaluatorTypes::Variable & v) {
|
||||
s << v.name << v.value;
|
||||
return s;
|
||||
}
|
||||
inline PIByteArray & operator >>(PIByteArray & s, PIEvaluatorTypes::Variable & v) {
|
||||
s >> v.name >> v.value;
|
||||
return s;
|
||||
}
|
||||
inline PIByteArray & operator <<(PIByteArray & s, const PIEvaluatorContent & v) {
|
||||
s << v.variables << v.cv_count;
|
||||
return s;
|
||||
}
|
||||
inline PIByteArray & operator >>(PIByteArray & s, PIEvaluatorContent & v) {
|
||||
s >> v.variables >> v.cv_count;
|
||||
return s;
|
||||
}
|
||||
BINARY_STREAM_STORE (PIEvaluatorTypes::Instruction) {s << PIByteArray::RawData(&v, sizeof(v) - sizeof(v.operators)) << v.operators; return s;}
|
||||
BINARY_STREAM_RESTORE(PIEvaluatorTypes::Instruction) {s >> PIByteArray::RawData(&v, sizeof(v) - sizeof(v.operators)) >> v.operators; return s;}
|
||||
|
||||
BINARY_STREAM_STORE (PIEvaluatorTypes::Element) {s << PIByteArray::RawData(&v, sizeof(v)); return s;}
|
||||
BINARY_STREAM_RESTORE(PIEvaluatorTypes::Element) {s >> PIByteArray::RawData(&v, sizeof(v)); return s;}
|
||||
|
||||
BINARY_STREAM_STORE (PIEvaluatorTypes::Variable) {s << v.name << v.value; return s;}
|
||||
BINARY_STREAM_RESTORE(PIEvaluatorTypes::Variable) {s >> v.name >> v.value; return s;}
|
||||
|
||||
BINARY_STREAM_STORE (PIEvaluatorContent) {s << v.variables << v.cv_count; return s;}
|
||||
BINARY_STREAM_RESTORE(PIEvaluatorContent) {s >> v.variables >> v.cv_count; return s;}
|
||||
|
||||
#endif // PIEVALUATOR_H
|
||||
|
||||
@@ -1172,9 +1172,9 @@ inline PICout operator<<(PICout s, const PIMathMatrix<Type> &m) {
|
||||
* @param v PIMathMatrix type
|
||||
* @return PIBiteArray serialized PIMathMatrix
|
||||
*/
|
||||
template<typename Type>
|
||||
inline PIByteArray &operator<<(PIByteArray &s, const PIMathMatrix<Type> &v) {
|
||||
s << (const PIVector2D<Type> &) v;
|
||||
template <typename P, typename T>
|
||||
inline PIBinaryStream<P> & operator <<(PIBinaryStream<P> & s, const PIMathMatrix<T> & v) {
|
||||
s << (const PIVector2D<T> &) v;
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -1185,9 +1185,9 @@ inline PIByteArray &operator<<(PIByteArray &s, const PIMathMatrix<Type> &v) {
|
||||
* @param v PIMathMatrix type
|
||||
* @return PIMathMatrix deserialized from PIByteArray
|
||||
*/
|
||||
template<typename Type>
|
||||
inline PIByteArray &operator>>(PIByteArray &s, PIMathMatrix<Type> &v) {
|
||||
s >> (PIVector2D<Type> &) v;
|
||||
template <typename P, typename T>
|
||||
inline PIBinaryStream<P> & operator >>(PIBinaryStream<P> & s, PIMathMatrix<T> & v) {
|
||||
s >> (PIVector2D<T> &) v;
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
@@ -258,8 +258,10 @@ typedef PIMathVectorT<4u, double> PIMathVectorT4d;
|
||||
template<typename Type>
|
||||
class PIP_EXPORT PIMathVector {
|
||||
typedef PIMathVector<Type> _CVector;
|
||||
template<typename TypeOp> friend PIByteArray & operator <<(PIByteArray & s, const PIMathVector<TypeOp> & v);
|
||||
template<typename TypeOp> friend PIByteArray & operator >>(PIByteArray & s, PIMathVector<TypeOp> & v);
|
||||
template <typename P, typename Type1>
|
||||
friend PIBinaryStream<P> & operator <<(PIBinaryStream<P> & s, const PIMathVector<Type1> & v);
|
||||
template <typename P, typename Type1>
|
||||
friend PIBinaryStream<P> & operator >>(PIBinaryStream<P> & s, PIMathVector<Type1> & v);
|
||||
public:
|
||||
PIMathVector(const uint size = 0, const Type & new_value = Type()) {c.resize(size, new_value);}
|
||||
PIMathVector(const PIVector<Type> & val) {c = val;}
|
||||
@@ -510,10 +512,10 @@ inline std::ostream & operator <<(std::ostream & s, const PIMathVector<Type> & v
|
||||
template<typename Type>
|
||||
inline PICout operator <<(PICout s, const PIMathVector<Type> & v) {s << "Vector{"; for (uint i = 0; i < v.size(); ++i) {s << v[i]; if (i < v.size() - 1) s << ", ";} s << "}"; return s;}
|
||||
|
||||
template<typename Type>
|
||||
inline PIByteArray & operator <<(PIByteArray & s, const PIMathVector<Type> & v) {s << v.c; return s;}
|
||||
template<typename Type>
|
||||
inline PIByteArray & operator >>(PIByteArray & s, PIMathVector<Type> & v) {s >> v.c; return s;}
|
||||
template <typename P, typename T>
|
||||
inline PIBinaryStream<P> & operator <<(PIBinaryStream<P> & s, const PIMathVector<T> & v) {s << v.c; return s;}
|
||||
template <typename P, typename T>
|
||||
inline PIBinaryStream<P> & operator >>(PIBinaryStream<P> & s, PIMathVector<T> & v) {s >> v.c; return s;}
|
||||
|
||||
|
||||
typedef PIMathVector<int> PIMathVectori;
|
||||
|
||||
Reference in New Issue
Block a user