summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2012-03-08 11:20:20 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2012-03-08 11:20:20 +0200
commit0897bd94a7d430a3d14a2de01a109191bb89c86e (patch)
treede46076b328298182f3f13d2fc4ec6445ce685f4 /examples
parent4c408a85759eb42b6b84b8cdab81453df31cd289 (diff)
Print usage/version information to STDOUT instead of STDERR
Diffstat (limited to 'examples')
-rw-r--r--examples/cxx/tree/embedded/xsdbin.cxx40
1 files changed, 21 insertions, 19 deletions
diff --git a/examples/cxx/tree/embedded/xsdbin.cxx b/examples/cxx/tree/embedded/xsdbin.cxx
index 53e2533..0da307b 100644
--- a/examples/cxx/tree/embedded/xsdbin.cxx
+++ b/examples/cxx/tree/embedded/xsdbin.cxx
@@ -88,10 +88,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 +105,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 +154,22 @@ main (int argc, char* argv[])
base = argv[argi];
}
- catch (usage const&)
+ catch (usage const& e)
{
- cerr << "Usage: " << argv[0] << " [options] <files>" << endl
- << "Options:" << endl
- << " --help Print usage information and exit." << endl
- << " --verbose Print progress information." << endl
- << " --output-dir <dir> Write generated files to <dir>." << endl
- << " --hxx-suffix <sfx> Header file suffix instead of '-schema.hxx'." << endl
- << " --cxx-suffix <sfx> Source file suffix instead of '-schema.cxx'." << endl
- << " --array-name <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] <files>" << endl
+ << "Options:" << endl
+ << " --help Print usage information and exit." << endl
+ << " --verbose Print progress information." << endl
+ << " --output-dir <dir> Write generated files to <dir>." << endl
+ << " --hxx-suffix <sfx> Header file suffix instead of '-schema.hxx'." << endl
+ << " --cxx-suffix <sfx> Source file suffix instead of '-schema.cxx'." << endl
+ << " --array-name <name> Binary data array name." << endl
+ << " --disable-multi-import Disable multiple import support." << endl
+ << endl;
+
+ return e.error ? 0 : 1;
}
XMLPlatformUtils::Initialize ();