PIByteArray works on binary stream
This commit is contained in:
@@ -206,8 +206,7 @@ classname_to __PIVariantFunctions__<classname_from>::castVariant<classname_to>(c
|
||||
//! \~english Variant type.
|
||||
class PIP_EXPORT PIVariant {
|
||||
friend PICout operator <<(PICout s, const PIVariant & v);
|
||||
friend PIByteArray & operator <<(PIByteArray & s, const PIVariant & v);
|
||||
friend PIByteArray & operator >>(PIByteArray & s, PIVariant & v);
|
||||
BINARY_STREAM_FRIEND(PIVariant);
|
||||
public:
|
||||
|
||||
//! Type of %PIVariant content
|
||||
@@ -773,38 +772,9 @@ REGISTER_VARIANT(PILined)
|
||||
REGISTER_VARIANT(PIMathVectord)
|
||||
REGISTER_VARIANT(PIMathMatrixd)
|
||||
|
||||
inline PIByteArray & operator <<(PIByteArray & s, const PIVariant & v) {
|
||||
s << v._content << int(v._type);
|
||||
if (v._type == PIVariant::pivCustom) {
|
||||
#ifdef CUSTOM_PIVARIANT
|
||||
if (v._info) {
|
||||
s << v._info->typeName;
|
||||
} else {
|
||||
s << PIStringAscii("");
|
||||
}
|
||||
#else
|
||||
s << PIStringAscii("");
|
||||
#endif
|
||||
}
|
||||
return s;
|
||||
}
|
||||
inline PIByteArray & operator >>(PIByteArray & s, PIVariant & v) {
|
||||
int t(0);
|
||||
s >> v._content >> t;
|
||||
v._type = (PIVariant::Type)t;
|
||||
if (v._type == PIVariant::pivCustom) {
|
||||
PIString tn;
|
||||
s >> tn;
|
||||
#ifdef CUSTOM_PIVARIANT
|
||||
PIByteArray vc = v._content;
|
||||
v = PIVariant::fromValue(vc, tn);
|
||||
#endif
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
template<typename P> inline PIBinaryStream<P> & operator <<(PIBinaryStream<P> & s, const PIVariant & v) {
|
||||
s << v._content << int(v._type);
|
||||
BINARY_STREAM_STORE(PIVariant) {
|
||||
s << v._content << v._type;
|
||||
if (v._type == PIVariant::pivCustom) {
|
||||
#ifdef CUSTOM_PIVARIANT
|
||||
if (v._info) {
|
||||
@@ -818,10 +788,8 @@ template<typename P> inline PIBinaryStream<P> & operator <<(PIBinaryStream<P> &
|
||||
}
|
||||
return s;
|
||||
}
|
||||
template<typename P> inline PIBinaryStream<P> & operator >>(PIBinaryStream<P> & s, PIVariant & v) {
|
||||
int t(0);
|
||||
s >> v._content >> t;
|
||||
v._type = (PIVariant::Type)t;
|
||||
BINARY_STREAM_RESTORE(PIVariant) {
|
||||
s >> v._content >> v._type;
|
||||
if (v._type == PIVariant::pivCustom) {
|
||||
PIString tn;
|
||||
s >> tn;
|
||||
|
||||
Reference in New Issue
Block a user