.reference

git-svn-id: svn://ultimatepp.org/upp/trunk@12539 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2018-11-15 08:26:07 +00:00
parent 303ee1fc78
commit 8bbf8a34e4
4 changed files with 58 additions and 4 deletions

View file

@ -25,9 +25,9 @@ struct OpenGLExample : GLCtrl {
w.Clipoff(200, 50, 95, 100);
w.DrawText(0, 80, "CLIPPED", Roman(25));
w.End();
GLDraw::ClearCache(); // This is required because GLCtrl creates a new OpenGL context,
// invalidating all texture handles
for(int angle = 0; angle < 360; angle += 30)
w.DrawText(sz.cx - sz.cx / 3, sz.cy - sz.cy / 3, angle * 10, "x Text with angle " + AsString(angle));
}
virtual void MouseMove(Point p, dword) {

View file

@ -0,0 +1,40 @@
#include <Core/Core.h>
using namespace Upp;
struct Item {
int value;
};
struct Data {
Array<Item> array;
Point p;
template <class IO>
void Ize(IO& io) { // define single template function for both JSON and XML
io
.Var("p", p, [=] (IO& io, Point& m) { // use lambda to define how to 'ize' structure
io("X", m.x)("Y", m.y);
})
.Array("values", array, [=] (IO& io, Item& m) { // use lambda to define how to 'ize' elements
io("value", m.value);
}, "element") // this is ignored in Json, provides tag of single element
;
}
void Xmlize(XmlIO& io) { Ize(io); }
void Jsonize(JsonIO& io) { Ize(io); }
};
CONSOLE_APP_MAIN
{
StdLogSetup(LOG_COUT|LOG_FILE);
Data data;
data.array.Add().value = 12345;
data.p.x = 1;
data.p.y = 2;
LOG(StoreAsXML(data));
LOG(StoreAsJson(data));
}

View file

@ -0,0 +1,11 @@
description "Using single template method for both Jsonize and Xmlize, using lambda to define structure\377";
uses
Core;
file
IzeLambda.cpp;
mainconfig
"" = "";

View file

@ -22,7 +22,7 @@ void Data::Xmlize(XmlIO& xml)
xml
("Dimension", sz)
("text", text)
("vector", vector)
.List("vector", "size", vector)
("Scores", score)
("map", map)
("sizemap", sizemap)
@ -72,6 +72,9 @@ CONSOLE_APP_MAIN
x.number = -1.235e-30;
x.option = true;
LOG(StoreAsXML(x));
LOG("====");
StoreAsXMLFile(x);
Data y;