Functions

xmltest.cpp File Reference

XMLStorage test program. More...

#include <xmlstorage.h>
#include <iostream>
Include dependency graph for xmltest.cpp:

Go to the source code of this file.

Functions

bool xml_test ()
int main ()

Detailed Description

XMLStorage test program.

Definition in file xmltest.cpp.


Function Documentation

int main (  )

Definition at line 100 of file xmltest.cpp.

References xml_test().

{
    return xml_test()? EXIT_SUCCESS: EXIT_FAILURE;
}

Here is the call graph for this function:

bool xml_test (  )

Definition at line 50 of file xmltest.cpp.

References XMLStorage::XMLDoc::_errors, XMLStorage::XMLPos::back(), XMLStorage::XMLString::c_str(), XMLStorage::XMLPos::create(), XMLStorage::FORMAT_ORIGINAL, XMLStorage::FORMAT_PLAIN, XMLStorage::FORMAT_PRETTY, XMLStorage::FORMAT_SMART, XMLStorage::XMLPos::go(), XMLStorage::XMLDoc::read_file(), XMLStorage::XMLErrorList::str(), and XMLStorage::XMLDoc::write_file().

Referenced by main().

{
    XMLDoc doc;
    bool ret;

    //ret = doc.read_file("poem.xml");
    //ret = doc.read_file("machines.xml");
    ret = doc.read_file("packets.xml");

    if (!ret) {
        std::cerr << doc._errors.str() << std::endl;
        return false;
    }

    doc.write_file("out_plain.xml", FORMAT_PLAIN);
    doc.write_file("out_smart.xml", FORMAT_SMART);
    doc.write_file("out_original.xml", FORMAT_ORIGINAL);
    doc.write_file("out_pretty.xml", FORMAT_PRETTY);

    XMLPos pos(&doc);

//  if (pos.go("get_packets/packet"))
//  if (pos.go("/get_packets/packet"))
//  if (pos.go("/get_packets/packet[5]"))
    if (pos.go("/get_packets/packet[@db_id=\"7628\"]"))
//  if (pos.go("get_machines/machine[@wsid=\"client2\"]"))
    {
        cout << "db_id = " << XMLInt(pos, "db_id") << endl;
        cout << "name = " << XMLString(pos, "name").c_str() << endl;
        cout << "short_name = " << XMLString(pos, "short_name").c_str() << endl;

        pos.back();
    }

     // test of special characters
    XMLDoc d;
    XMLPos p(&d);

    p.create("n1");
        char s[6] = "12345";
        s[2] = 0x15;
        p->set_content(s);
    p.back();

    d.write_file("testfile.xml");

    return true;
}

Here is the call graph for this function:

Here is the caller graph for this function: