mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
Core: some Xmlization moved to rich Value types
git-svn-id: svn://ultimatepp.org/upp/trunk@4674 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
9b3c112703
commit
a8170e10f0
8 changed files with 22 additions and 14 deletions
|
|
@ -97,6 +97,19 @@ void Color::Jsonize(JsonIO& jio)
|
|||
*this = Color(r, g, b);
|
||||
}
|
||||
|
||||
void Color::Xmlize(XmlIO& xio)
|
||||
{
|
||||
int r = GetR();
|
||||
int g = GetG();
|
||||
int b = GetB();
|
||||
xio
|
||||
.Attr("red", r)
|
||||
.Attr("green", g)
|
||||
.Attr("blue", b)
|
||||
;
|
||||
*this = Color(r, g, b);
|
||||
}
|
||||
|
||||
RGBA operator*(int alpha, Color c)
|
||||
{
|
||||
RGBA r;
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ public:
|
|||
|
||||
void Serialize(Stream& s) { s % color; }
|
||||
void Jsonize(JsonIO& jio);
|
||||
void Xmlize(XmlIO& xio);
|
||||
|
||||
Color() { SetNull(); }
|
||||
Color(int r, int g, int b) { color = RGB(r, g, b); }
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@ struct Size_ : Moveable< Size_<T> > {
|
|||
|
||||
void Serialize(Stream& s) { s % cx % cy; }
|
||||
void Jsonize(JsonIO& jio) { jio("cx", cx)("cy", cy); }
|
||||
void Xmlize(XmlIO& xio) { xio.Attr("cx", cx).Attr("cy", cy); }
|
||||
|
||||
#ifdef PLATFORM_WIN32
|
||||
operator SIZE*() { ASSERT(sizeof(*this) == sizeof(SIZE)); return (SIZE*)this; }
|
||||
|
|
@ -190,6 +191,7 @@ struct Point_ : Moveable< Point_<T> > {
|
|||
|
||||
void Serialize(Stream& s) { s % x % y; }
|
||||
void Jsonize(JsonIO& jio) { jio("x", x)("y", y); }
|
||||
void Xmlize(XmlIO& xio) { xio.Attr("x", x).Attr("y", y); }
|
||||
|
||||
#ifdef PLATFORM_WIN32
|
||||
operator POINT*() { ASSERT(sizeof(*this) == sizeof(POINT)); return (POINT*)this; }
|
||||
|
|
@ -368,8 +370,9 @@ struct Rect_ : Moveable< Rect_<T> > {
|
|||
operator Value() const { return RichValue<Rect_>(*this); }
|
||||
/*explicit */Rect_(const Value& src) { *this = RichValue<Rect_>::Extract(src); }
|
||||
|
||||
void Serialize(Stream& s) { s % left % top % right % bottom; }
|
||||
void Jsonize(JsonIO& jio) { jio("left", left)("top", top)("right", right)("bottom", bottom); }
|
||||
void Serialize(Stream& s) { s % left % top % right % bottom; }
|
||||
void Jsonize(JsonIO& jio) { jio("left", left)("top", top)("right", right)("bottom", bottom); }
|
||||
void Xmlize(XmlIO& xio) { xio.Attr("left", left).Attr("top", top).Attr("right", right).Attr("bottom", bottom); }
|
||||
|
||||
#ifdef PLATFORM_WIN32
|
||||
operator const RECT*() const { ASSERT(sizeof(*this) == sizeof(RECT)); return (RECT*)this; }
|
||||
|
|
|
|||
|
|
@ -304,12 +304,4 @@ template<> void Jsonize(JsonIO& io, Time& var)
|
|||
var.year, var.month, var.day, var.hour, var.minute, var.second));
|
||||
}
|
||||
|
||||
template<> void Jsonize(JsonIO& io, Complex& var)
|
||||
{
|
||||
double r = var.real();
|
||||
double i = var.imag();
|
||||
io("real", r)("imag", i);
|
||||
var = Complex(r, i);
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -182,7 +182,6 @@ template<> void Jsonize(JsonIO& io, String& var);
|
|||
template<> void Jsonize(JsonIO& io, WString& var);
|
||||
template<> void Jsonize(JsonIO& io, Date& var);
|
||||
template<> void Jsonize(JsonIO& io, Time& var);
|
||||
template<> void Jsonize(JsonIO& io, Complex& var);
|
||||
|
||||
template <class T, class V>
|
||||
void JsonizeArray(JsonIO& io, T& array)
|
||||
|
|
|
|||
|
|
@ -538,7 +538,7 @@ void Complex::Xmlize(XmlIO& xio)
|
|||
{
|
||||
double r, i;
|
||||
r = real(); i = imag();
|
||||
xio.Attr("real", r).Attr("image", i);
|
||||
xio.Attr("real", r).Attr("imag", i);
|
||||
*this = C(r, i);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -153,6 +153,7 @@ VALUE_XMLIZE(byte);
|
|||
VALUE_XMLIZE(Time);
|
||||
VALUE_XMLIZE(Date);
|
||||
|
||||
#ifndef SVO_VALUE
|
||||
template <class T>
|
||||
void XmlizePoint_(XmlIO& xml, T& p)
|
||||
{
|
||||
|
|
@ -211,7 +212,6 @@ void Xmlize(XmlIO& xml, Color& c)
|
|||
c = Color(r, g, b);
|
||||
}
|
||||
|
||||
#ifndef SVO_VALUE
|
||||
typedef void (*ValueXmlizer)(XmlIO& xml, Value& v);
|
||||
|
||||
VectorMap<dword, ValueXmlizer>& ValueXmlizeMap()
|
||||
|
|
|
|||
|
|
@ -125,6 +125,7 @@ template<> void Xmlize(XmlIO& xml, int16& var);
|
|||
template<> void Xmlize(XmlIO& xml, int64& var);
|
||||
template<> void Xmlize(XmlIO& xml, byte& var);
|
||||
|
||||
#ifndef SVO_VALUE
|
||||
template<> void Xmlize(XmlIO& xml, Point& p);
|
||||
template<> void Xmlize(XmlIO& xml, Point16& p);
|
||||
template<> void Xmlize(XmlIO& xml, Point64& p);
|
||||
|
|
@ -142,7 +143,6 @@ template<> void Xmlize(XmlIO& xml, Rectf& r);
|
|||
|
||||
template<> void Xmlize(XmlIO& xml, Color& c);
|
||||
|
||||
#ifndef SVO_VALUE
|
||||
template<> void Xmlize(XmlIO& xml, Value& v);
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue