mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-08-23 06:13:07 -06:00
reference: XmlizeCustomValue example
git-svn-id: svn://ultimatepp.org/upp/trunk@2156 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
9d395ec6a9
commit
181f0b281f
2 changed files with 54 additions and 0 deletions
43
reference/XmlizeCustomValue/XmlizeCustomValue.cpp
Normal file
43
reference/XmlizeCustomValue/XmlizeCustomValue.cpp
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
#include <Core/Core.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
struct MyCustomValue : AssignValueTypeNo<MyCustomValue, 514> {
|
||||
int x, y, z;
|
||||
|
||||
int operator==(const MyCustomValue& o) const { return false; }
|
||||
void Serialize(Stream& s) {}
|
||||
String ToString() const { return ""; }
|
||||
unsigned GetHashValue() const { return 0; }
|
||||
bool IsNullInstance() const { return false; }
|
||||
|
||||
operator Value() const { return RichValue<MyCustomValue>(*this); }
|
||||
MyCustomValue(const Value& v) { *this = ValueTo<MyCustomValue>(v); }
|
||||
|
||||
MyCustomValue() {}
|
||||
};
|
||||
|
||||
void Xmlize(XmlIO xml, MyCustomValue& v)
|
||||
{
|
||||
xml
|
||||
.Attr("x", v.x)
|
||||
.Attr("y", v.y)
|
||||
.Attr("z", v.z)
|
||||
;
|
||||
}
|
||||
|
||||
INITBLOCK {
|
||||
RichValue<Color>::Register();
|
||||
}
|
||||
|
||||
REGISTER_VALUE_XMLIZE(MyCustomValue);
|
||||
|
||||
CONSOLE_APP_MAIN
|
||||
{
|
||||
MyCustomValue a;
|
||||
a.x = 1;
|
||||
a.y = 2;
|
||||
a.z = 3;
|
||||
Value v = a;
|
||||
LOG(StoreAsXML(v, "Test"));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue