mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-08-25 14:22: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
37
reference/Serialize/main.cpp
Normal file
37
reference/Serialize/main.cpp
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#include <Core/Core.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
struct Foo {
|
||||
int q;
|
||||
String text;
|
||||
Vector<int> data;
|
||||
|
||||
void Serialize(Stream& s)
|
||||
{
|
||||
s % q % text % data;
|
||||
}
|
||||
|
||||
String ToString() const
|
||||
{
|
||||
String s;
|
||||
s << "q = " << q << ", text = \"" << text << "\", data:";
|
||||
for(int i = 0; i < data.GetCount(); i++)
|
||||
s << ' ' << data[i];
|
||||
return s;
|
||||
}
|
||||
|
||||
Foo() { q = 0; }
|
||||
};
|
||||
|
||||
CONSOLE_APP_MAIN
|
||||
{
|
||||
Foo foo;
|
||||
LoadFromFile(foo, ConfigFile("data.bin"));
|
||||
Cout() << "Loaded Foo: " << foo << '\n';
|
||||
foo.text = FormatIntRoman(foo.q);
|
||||
foo.q++;
|
||||
foo.data.Add(foo.q);
|
||||
StoreToFile(foo, ConfigFile("data.bin"));
|
||||
Cout() << "Saved Foo: " << foo << '\n';
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue