mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
reference: Xmlize_std
git-svn-id: svn://ultimatepp.org/upp/trunk@553 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
d6db33b1d2
commit
ba17b01438
2 changed files with 44 additions and 0 deletions
33
reference/Xmlize_std/Xmlize.cpp
Normal file
33
reference/Xmlize_std/Xmlize.cpp
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#include <Core/Core.h>
|
||||
#include <vector>
|
||||
|
||||
using namespace Upp;
|
||||
using namespace std;
|
||||
|
||||
template<> void Upp::Xmlize(XmlIO xml, vector<int>& data) {
|
||||
if(xml.IsStoring())
|
||||
for(int i = 0; i < (int)data.size(); i++)
|
||||
Xmlize(xml.Add("item"), data[i]);
|
||||
else {
|
||||
data.clear();
|
||||
for(int i = 0; i < xml->GetCount(); i++)
|
||||
if(xml->Node(i).IsTag("item")) {
|
||||
data.push_back(0);
|
||||
Xmlize(xml.At(i), data.back());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CONSOLE_APP_MAIN
|
||||
{
|
||||
vector<int> x;
|
||||
x.push_back(1);
|
||||
x.push_back(2);
|
||||
x.push_back(3);
|
||||
String s = StoreAsXML(x, "std-test");
|
||||
DUMP(s);
|
||||
vector<int> y;
|
||||
LoadFromXML(y, s);
|
||||
for(int i = 0; i < (int)y.size(); i++)
|
||||
DUMP(y[i]);
|
||||
}
|
||||
11
reference/Xmlize_std/Xmlize_std.upp
Normal file
11
reference/Xmlize_std/Xmlize_std.upp
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
description "Xmlize with existing type, in this case std::vector<int>";
|
||||
|
||||
uses
|
||||
Core;
|
||||
|
||||
file
|
||||
Xmlize.cpp;
|
||||
|
||||
mainconfig
|
||||
"" = "";
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue