Example XMLBase operations
,XMLBase
- Author
- MIP
#include <Base/Common/XMLIO.hh>
#include <Base/Debug/Debug.hh>
#include <Base/Common/XMLBase.hh>
using namespace BIAS;
using namespace std;
#define VERSIONOFTESTCLASS 0.37
public:
virtual int XMLGetClassName(string& TopLevelTag, double& Version) const;
virtual int XMLOut(
const xmlNodePtr Node,
XMLIO& XMLObject)
const;
virtual int XMLIn(
const xmlNodePtr Node,
XMLIO& XMLObject);
virtual ~myTestClass();
int thedata;
};
myTestClass::~myTestClass() {}
int myTestClass::XMLGetClassName(std::string& TopLevelTag,
double &Version) const {
TopLevelTag = "myTestClass";
Version = VERSIONOFTESTCLASS;
return 0;
}
int myTestClass::XMLOut(
const xmlNodePtr Node,
XMLIO& XMLObject)
const {
return 0;
}
int myTestClass::XMLIn(
const xmlNodePtr Node,
XMLIO& XMLObject) {
return 0;
}
int main (int , char ** )
{
myTestClass x, y, z;
x.thedata = 42;
x.XMLWrite("backupofx.xml");
string str;
x.XMLWriteToString(str);
cout << "xml in string:\n" << str << endl;
y.XMLRead("backupofx.xml");
z.XMLReadFromString(str);
int result(0);
if (x.thedata == y.thedata && x.thedata == z.thedata)
result=0;
else
result=-1;
cout
<<"x.thedata="<<x.thedata<<endl
<<"y.thedata="<<y.thedata <<endl
<<"z.thedata="<<z.thedata <<endl
<<"result="<<result<<endl;
return result;
}