From 40172c8a4c903acba24b236be7c3683b373f0bea Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 10 May 2014 18:41:25 -0700 Subject: Add 'persistence' example --- examples/persistence/driver.cxx | 46 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 examples/persistence/driver.cxx (limited to 'examples/persistence/driver.cxx') diff --git a/examples/persistence/driver.cxx b/examples/persistence/driver.cxx new file mode 100644 index 0000000..d62dd3b --- /dev/null +++ b/examples/persistence/driver.cxx @@ -0,0 +1,46 @@ +// file : examples/persistence/driver.cxx +// copyright : not copyrighted - public domain + +#include +#include + +#include +#include + +#include "position.hxx" + +using namespace std; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " " << endl; + return 1; + } + + try + { + // Load the object model state from XML. + // + ifstream ifs (argv[1]); + xml::parser p (ifs, argv[1]); + + object o (p); + + // Save the object model state back to XML. + // + xml::serializer s (cout, "output"); + + o.serialize (s); + } + // This handler will handle both parsing (xml::parsing) and serialization + // (xml::serialization) exceptions. + // + catch (const xml::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} -- cgit v1.1