git-svn-id: svn://db.shs.com.ru/pip@298 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
11
main.cpp
11
main.cpp
@@ -16,12 +16,11 @@ int main(int argc, char *argv[]) {
|
||||
s.text = "123";
|
||||
s.i = -1;
|
||||
PIVariant v = PIVariant::fromValue(s);
|
||||
piCout << v;
|
||||
s1 = v.value<__S__>();
|
||||
piCout << s1.text << s1.i << v.value<int>();
|
||||
PIPropertyStorage ps;
|
||||
piForeachC (PIPropertyStorage::Property & p, ps)
|
||||
;
|
||||
PIByteArray ba;
|
||||
ba << v;
|
||||
PIVariant v1;
|
||||
ba >> v1;
|
||||
piCout << v1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -70,4 +70,11 @@ protected:
|
||||
|
||||
};
|
||||
|
||||
|
||||
inline PIByteArray & operator <<(PIByteArray & s, const PIPropertyStorage::Property & v) {s << v.name << v.value << v.comment << v.flags; return s;}
|
||||
inline PIByteArray & operator >>(PIByteArray & s, PIPropertyStorage::Property & v) {s >> v.name >> v.value >> v.comment >> v.flags; return s;}
|
||||
|
||||
inline PIByteArray & operator <<(PIByteArray & s, const PIPropertyStorage & v) {s << v.properties(); return s;}
|
||||
inline PIByteArray & operator >>(PIByteArray & s, PIPropertyStorage & v) {s >> v.properties(); return s;}
|
||||
|
||||
#endif // PIPROPERTYSTORAGE_H
|
||||
|
||||
@@ -142,6 +142,8 @@ classname_to __PIVariantFunctions__<classname_from>::castVariant<classname_to>(c
|
||||
|
||||
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);
|
||||
public:
|
||||
|
||||
//! Type of %PIVariant content
|
||||
@@ -611,6 +613,36 @@ REGISTER_VARIANT(PIDate)
|
||||
REGISTER_VARIANT(PIDateTime)
|
||||
REGISTER_VARIANT(PISystemTime)
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
inline PICout operator <<(PICout s, const PIVariant & v) {
|
||||
s.space(); s.setControl(0, true);
|
||||
s << "PIVariant(" << v.typeName() << ", " << v.toString() << ")";
|
||||
|
||||
Reference in New Issue
Block a user