2009-04-27 10:59:16 +00:00
|
|
|
/*! @file
|
|
|
|
|
|
|
|
@id $Id: inherit_serialization.cxx 26 2009-04-24 07:13:10Z $
|
|
|
|
*/
|
|
|
|
// 1 2 3 4 5 6 7 8
|
|
|
|
// 45678901234567890123456789012345678901234567890123456789012345678901234567890
|
|
|
|
|
|
|
|
#include <xml-cxx/xml.hxx>
|
|
|
|
#include <iostream>
|
|
|
|
#include <sstream>
|
|
|
|
#include <list>
|
|
|
|
|
|
|
|
class A: public xml::Serialize {
|
|
|
|
public:
|
2009-04-29 11:58:57 +00:00
|
|
|
xml::List<std::string> list;
|
2009-04-27 10:59:16 +00:00
|
|
|
protected:
|
|
|
|
void initXmlMembers() {
|
|
|
|
className("A");
|
2009-04-29 11:58:57 +00:00
|
|
|
persist(list, "list");
|
2009-04-27 10:59:16 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2009-04-30 08:28:52 +00:00
|
|
|
class B: public xml::Serialize {
|
|
|
|
public:
|
|
|
|
int b;
|
|
|
|
A a;
|
|
|
|
xml::List<A> as;
|
|
|
|
protected:
|
|
|
|
void initXmlMembers() {
|
|
|
|
className("B");
|
|
|
|
persist(b, "b");
|
|
|
|
persist(a, "a");
|
|
|
|
persist(as, "As");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2009-04-27 10:59:16 +00:00
|
|
|
int main(int, char**) {
|
2009-05-04 12:47:57 +00:00
|
|
|
std::stringstream ss("<B>"
|
|
|
|
" <b>1234</b>"
|
|
|
|
" <a>"
|
|
|
|
" <list>"
|
|
|
|
" <item>guguseli</item>"
|
|
|
|
" </list>"
|
|
|
|
" </a>"
|
|
|
|
" <As>"
|
|
|
|
" <A>"
|
|
|
|
" <list>"
|
|
|
|
" <item>Hello</item>"
|
|
|
|
" <item>World</item>"
|
|
|
|
" <item>how</item>"
|
|
|
|
" <item>are</item>"
|
|
|
|
" <item>you</item>"
|
|
|
|
" </list>"
|
|
|
|
" </A>"
|
|
|
|
" <A>"
|
|
|
|
" <list>"
|
|
|
|
" <item>a</item>"
|
|
|
|
" <item>b</item>"
|
|
|
|
" <item>c</item>"
|
|
|
|
" <item>d</item>"
|
|
|
|
" <item>e</item>"
|
|
|
|
" </list>"
|
|
|
|
" </A>"
|
|
|
|
" <A>"
|
|
|
|
" <list>"
|
|
|
|
" <item>f</item>"
|
|
|
|
" <item>g</item>"
|
|
|
|
" <item>h</item>"
|
|
|
|
" <item>i</item>"
|
|
|
|
" <item>j</item>"
|
|
|
|
" </list>"
|
|
|
|
" </A>"
|
|
|
|
" <A>"
|
|
|
|
" <list>"
|
|
|
|
" <item>k</item>"
|
|
|
|
" <item>l</item>"
|
|
|
|
" <item>m</item>"
|
|
|
|
" <item>n</item>"
|
|
|
|
" <item>o</item>"
|
|
|
|
" </list>"
|
|
|
|
" </A>"
|
|
|
|
" </As>"
|
2009-04-30 08:28:52 +00:00
|
|
|
"</B>");
|
|
|
|
B b;
|
|
|
|
std::cout<<"SCHEMA:"<<std::endl<<b.schema()<<std::endl;
|
|
|
|
b.loadXml(ss);
|
2009-05-04 12:47:57 +00:00
|
|
|
if (b.as.front().list.front()=="Hello") b.as.front().list.front()="Good Bye";
|
|
|
|
if (b.as.front().list.back()=="you") b.as.front().list.back()="we";
|
2009-04-30 08:28:52 +00:00
|
|
|
b.saveXml(std::cout)<<std::endl;
|
2009-04-27 10:59:16 +00:00
|
|
|
return 0;
|
|
|
|
}
|