mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-09-10 03:54:54 -06:00
changed svn layout
git-svn-id: svn://ultimatepp.org/upp/trunk@281 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
commit
263ff5f895
2665 changed files with 642923 additions and 0 deletions
78
reference/Xmlize/Xmlize.cpp
Normal file
78
reference/Xmlize/Xmlize.cpp
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
#include <Core/Core.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
struct Data {
|
||||
Size sz;
|
||||
int lang;
|
||||
String text;
|
||||
Vector<Size> vector;
|
||||
VectorMap<String, int> score;
|
||||
VectorMap<String, String> map;
|
||||
ArrayMap<int, Size> sizemap;
|
||||
double number;
|
||||
bool option;
|
||||
|
||||
void Dump();
|
||||
void Xmlize(XmlIO xml);
|
||||
};
|
||||
|
||||
void Data::Xmlize(XmlIO xml)
|
||||
{
|
||||
xml
|
||||
("Dimension", sz)
|
||||
("text", text)
|
||||
("vector", vector)
|
||||
("Scores", score)
|
||||
("map", map)
|
||||
("sizemap", sizemap)
|
||||
("number", number)
|
||||
("option", option)
|
||||
;
|
||||
XmlizeLang(xml, "Language", lang);
|
||||
}
|
||||
|
||||
void Data::Dump()
|
||||
{
|
||||
DUMP(sz);
|
||||
DUMP(text);
|
||||
LOG("lang: " << LNGAsText(lang));
|
||||
DUMPC(vector);
|
||||
LOG("score: ");
|
||||
for(int i = 0; i < score.GetCount(); i++)
|
||||
LOG(" " << score.GetKey(i) << " ..... " << score[i]);
|
||||
LOG("map: ");
|
||||
for(int i = 0; i < map.GetCount(); i++)
|
||||
LOG(" " << map.GetKey(i) << " ..... " << map[i]);
|
||||
LOG("sizemap: ");
|
||||
for(int i = 0; i < sizemap.GetCount(); i++)
|
||||
LOG(" " << sizemap.GetKey(i) << " ..... " << sizemap[i]);
|
||||
DUMP(number);
|
||||
DUMP(option);
|
||||
}
|
||||
|
||||
CONSOLE_APP_MAIN
|
||||
{
|
||||
Data x;
|
||||
x.sz.cx = 10;
|
||||
x.sz.cy = 20;
|
||||
x.lang = LNGFromText("CS-CZ");
|
||||
x.text = "Some text";
|
||||
x.vector.Add(Size(1, 2));
|
||||
x.vector.Add(Size(3, 4));
|
||||
x.score.Add("peter", 100);
|
||||
x.score.Add("john", 10);
|
||||
x.score.Add("frank", 20);
|
||||
x.map.Add("keytext", "valuetext");
|
||||
x.map.Add("key1text", "value1text");
|
||||
x.sizemap.Add(1, Size(2, 3));
|
||||
x.sizemap.Add(10, Size(20, 30));
|
||||
x.number = -1.235e-30;
|
||||
x.option = true;
|
||||
|
||||
StoreAsXMLFile(x);
|
||||
|
||||
Data y;
|
||||
LoadFromXMLFile(y);
|
||||
y.Dump();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue