driver.cxx 840 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // file : examples/inheritance/driver.cxx
  2. // copyright : not copyrighted - public domain
  3. #include <fstream>
  4. #include <iostream>
  5. #include <xml/parser>
  6. #include <xml/serializer>
  7. #include "position.hxx"
  8. using namespace std;
  9. int
  10. main (int argc, char* argv[])
  11. {
  12. if (argc != 2)
  13. {
  14. cerr << "usage: " << argv[0] << " <xml-file>" << endl;
  15. return 1;
  16. }
  17. try
  18. {
  19. // Load the object model state from XML.
  20. //
  21. ifstream ifs (argv[1]);
  22. xml::parser p (ifs, argv[1]);
  23. objects o (p);
  24. // Save the object model state back to XML.
  25. //
  26. xml::serializer s (cout, "output");
  27. o.serialize (s);
  28. }
  29. // This handler will handle both parsing (xml::parsing) and serialization
  30. // (xml::serialization) exceptions.
  31. //
  32. catch (const xml::exception& e)
  33. {
  34. cerr << e.what () << endl;
  35. return 1;
  36. }
  37. }