From bada6666c70977a058755ccf232e7d67b24adeed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Wed, 23 Jul 2014 15:21:29 +0200 Subject: New upstream release --- xsd/examples/cxx/tree/embedded/xsdbin.cxx | 61 +++++++++++++------------------ 1 file changed, 25 insertions(+), 36 deletions(-) (limited to 'xsd/examples/cxx/tree/embedded/xsdbin.cxx') diff --git a/xsd/examples/cxx/tree/embedded/xsdbin.cxx b/xsd/examples/cxx/tree/embedded/xsdbin.cxx index 53e2533..656b830 100644 --- a/xsd/examples/cxx/tree/embedded/xsdbin.cxx +++ b/xsd/examples/cxx/tree/embedded/xsdbin.cxx @@ -1,5 +1,4 @@ // file : examples/cxx/tree/embedded/xsdbin.cxx -// author : Boris Kolpackov // copyright : not copyrighted - public domain // This program loads the XML Schema file(s) and converts them to @@ -28,11 +27,7 @@ #include #include -#if _XERCES_VERSION >= 30000 -# include -#else -# include -#endif +#include using namespace std; using namespace xercesc; @@ -88,10 +83,13 @@ main (int argc, char* argv[]) string base; string outdir; - class usage {}; + struct usage + { + usage (bool e = true): error (e) {} + bool error; + }; int argi (1); - bool help (false); bool multi_import (true); bool verbose (false); @@ -102,10 +100,7 @@ main (int argc, char* argv[]) string a (argv[argi]); if (a == "--help") - { - help = true; - throw usage (); - } + throw usage (false); else if (a == "--verbose") { verbose = true; @@ -154,20 +149,22 @@ main (int argc, char* argv[]) base = argv[argi]; } - catch (usage const&) + catch (usage const& e) { - cerr << "Usage: " << argv[0] << " [options] " << endl - << "Options:" << endl - << " --help Print usage information and exit." << endl - << " --verbose Print progress information." << endl - << " --output-dir Write generated files to ." << endl - << " --hxx-suffix Header file suffix instead of '-schema.hxx'." << endl - << " --cxx-suffix Source file suffix instead of '-schema.cxx'." << endl - << " --array-name Binary data array name." << endl - << " --disable-multi-import Disable multiple import support." << endl - << endl; - - return help ? 0 : 1; + ostream& o (e.error ? cerr : cout); + + o << "Usage: " << argv[0] << " [options] " << endl + << "Options:" << endl + << " --help Print usage information and exit." << endl + << " --verbose Print progress information." << endl + << " --output-dir Write generated files to ." << endl + << " --hxx-suffix Header file suffix instead of '-schema.hxx'." << endl + << " --cxx-suffix Source file suffix instead of '-schema.cxx'." << endl + << " --array-name Binary data array name." << endl + << " --disable-multi-import Disable multiple import support." << endl + << endl; + + return e.error ? 0 : 1; } XMLPlatformUtils::Initialize (); @@ -488,17 +485,9 @@ handle (const SAXParseException& e, severity s) char* id (XMLString::transcode (xid)); char* msg (XMLString::transcode (e.getMessage ())); - cerr << id << ":"; - -#if _XERCES_VERSION >= 30000 - cerr << e.getLineNumber () << ":" << e.getColumnNumber () << " "; -#else - XMLSSize_t l (e.getLineNumber ()); - XMLSSize_t c (e.getColumnNumber ()); - cerr << (l == -1 ? 0 : l) << ":" << (c == -1 ? 0 : c) << " "; -#endif - - cerr << (s == s_warning ? "warning: " : "error: ") << msg << endl; + cerr << id << ":" + << e.getLineNumber () << ":" << e.getColumnNumber () << " " + << (s == s_warning ? "warning: " : "error: ") << msg << endl; XMLString::release (&id); XMLString::release (&msg); -- cgit v1.2.3