#include #include "CNestedDataFile.h" class foo { public: foo() { } }; int main() { try { CNestedDataFile s("test.dat"); setlocale(LC_ALL,""); // test reading int on top level cout << "foo_int: " << s.getValue("foo_int") << endl; // test reading float on top level printf("foo_float1: %25.25f\n",s.getValue("foo_float1")); printf("foo_float2: %25.25f\n",s.getValue("foo_float2")); // test reading string on top level cout << "foo_string: '" << s.getValue("foo_string") << "'" << endl; // test reading bool on top level cout << "foo_bool: " << s.getValue("foo_bool1") << endl; cout << "foo_bool: " << s.getValue("foo_bool2") << endl; // should cause a somewhat informative error message //s.getValue("foo"); //s.setValue("foo",foo()); // test reading vector > on top level { { const vector > v=s.getValue > >("foo_vector"); for(size_t x=0;x v=s.getValue >("foo_vector2"); cout << "should be zero: " << v.size() << endl; } // read vector as string cout << "vector value as string: '" << s.getValue("foo_vector") << "'" << endl; } // test reading string from deep scopes cout << "aaa.b.ccc: '" << s.getValue("aaa"DOT"b"DOT"ccc"DOT"bar_string") << "'" << endl; // test writing int to deep scopes cout << "writing d.eee.f.baz_int" << endl; s.setValue("d"DOT"eee"DOT"f"DOT"baz_int",27); // test writing float to deep scopes cout << "writing d.eee.f.baz_float1" << endl; s.setValue("d"DOT"eee"DOT"f"DOT"baz_float1",12.12345678912345678); cout << "writing d.eee.f.baz_float2" << endl; s.setValue("d"DOT"eee"DOT"f"DOT"baz_float2",10000000.12345); // test writing string to deep scopes cout << "writing d.eee.f.baz_string" << endl; s.setValue("d"DOT"eee"DOT"f"DOT"baz_string","\"qwer\"asdf\\zxcv\""); // test writing bool to deep scopes cout << "writing d.eee.f.baz_bool" << endl; s.setValue("d"DOT"eee"DOT"f"DOT"baz_bool1",true); s.setValue("d"DOT"eee"DOT"f"DOT"baz_bool2",false); // test writing vector > to deep scopes cout << "writing d.eee.f.baz_vector" << endl; { vector > v; vector v1,v2; v1.push_back("qwer"); v1.push_back("asdf"); v1.push_back("zxcv"); v2.push_back("uiop"); v2.push_back("hjkl"); v2.push_back("vbnm"); v.push_back(v1); v.push_back(v2); s.setValue > >("d"DOT"eee"DOT"f"DOT"baz_vector",v); } // test getting child names { const vector v=s.getChildKeys("aaa"); for(size_t t=0;t