#include <xmlstorage.h>#include <iostream>
Go to the source code of this file.
Functions | |
| void | test_write () |
| bool | test_read () |
| int | main () |
| int main | ( | ) |
Definition at line 112 of file stream-example.cpp.
References test_read(), and test_write().
{
test_write();
test_read();
return 0;
}

| bool test_read | ( | ) |
Definition at line 70 of file stream-example.cpp.
References XMLStorage::XMLStreamReader::back(), XMLStorage::XMLStreamReader::get_errors(), XMLStorage::XMLStreamReader::go_down(), and XMLStorage::XMLErrorList::str().
{
XMLStreamReader reader("stream-example.xml");
if (reader.go_down("PERSON")) {
if (reader.go_down("NAME")) {
const string& content = reader->get_content();
cout << "NAME content=" << content << endl;
reader.back(); // </NAME>
}
if (reader.go_down("VORNAME")) {
const string& content = reader->get_content();
cout << "VORNAME content=" << content << endl;
reader.back(); // </VORNAME>
}
}
if (reader.go_down("ADRESSE")) {
const string& priv = reader->get("private");
const string& content = reader->get_content();
cout << "ADRESSE.@private=" << priv << endl;
cout << "ADRESSE content=" << content << endl;
reader.back(); // </ADRESSE>
}
reader.back(); // </PERSON>
const XMLErrorList& errors = reader.get_errors();
if (!errors.empty()) {
cerr << errors.str() << endl;
return false;
}
return true;
}

| void test_write | ( | ) |
Definition at line 46 of file stream-example.cpp.
References XMLStorage::XMLWriter::back(), XMLStorage::XMLWriter::create(), and XMLStorage::XMLWriter::set_content().
{
XMLWriter writer("stream-example.xml");
writer.create("PERSON");
writer.create("NAME");
writer["EncodeTest"] = "1>2";
writer.set_content("Mustername und Straße");
writer.back(); // </NAME>
writer.create("VORNAME");
writer.set_content("Mustervorname äöü");
writer.back(); // </VORNAME>
writer.create("ADRESSE");
writer["private"] = XMLBool(true);
writer.set_content("Musteradresse");
writer.back(); // </ADRESSE>
writer.back(); // </PERSON>
}

1.7.2