diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2014-05-11 15:48:33 -0700 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2014-05-11 15:48:33 -0700 |
commit | 16e73947858754de5bfcbd91f8f6ce021e99c673 (patch) | |
tree | ff6e4d051f17d6f0d2cd9fdc1f78632105dd52cb /examples/inheritance/driver.cxx | |
parent | e28bfc09f230ed00e94a79efaa6fafd0d07eaf12 (diff) |
Add 'inheritance' example
Diffstat (limited to 'examples/inheritance/driver.cxx')
-rw-r--r-- | examples/inheritance/driver.cxx | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/examples/inheritance/driver.cxx b/examples/inheritance/driver.cxx new file mode 100644 index 0000000..d6cd5ea --- /dev/null +++ b/examples/inheritance/driver.cxx @@ -0,0 +1,46 @@ +// file : examples/inheritance/driver.cxx +// copyright : not copyrighted - public domain + +#include <fstream> +#include <iostream> + +#include <xml/parser.hxx> +#include <xml/serializer.hxx> + +#include "position.hxx" + +using namespace std; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " <xml-file>" << endl; + return 1; + } + + try + { + // Load the object model state from XML. + // + ifstream ifs (argv[1]); + xml::parser p (ifs, argv[1]); + + objects 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; + } +} |