PIByteArray works on binary stream

This commit is contained in:
2022-05-10 15:23:18 +03:00
parent 0f9e592273
commit b2bc385397
58 changed files with 254 additions and 923 deletions

View File

@@ -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