diff options
author | Mark Spruiell <mes@zeroc.com> | 2002-08-27 18:56:51 +0000 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2002-08-27 18:56:51 +0000 |
commit | e675ae71c840582bcaf196099756ec2baf3459e7 (patch) | |
tree | ac2e42be949246106118576079c3472793e0c116 /cpp/src | |
parent | bug fix (diff) | |
download | ice-e675ae71c840582bcaf196099756ec2baf3459e7.tar.bz2 ice-e675ae71c840582bcaf196099756ec2baf3459e7.tar.xz ice-e675ae71c840582bcaf196099756ec2baf3459e7.zip |
clean up
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/slice2xsd/.depend | 2 | ||||
-rw-r--r-- | cpp/src/slice2xsd/Validate.cpp | 131 |
2 files changed, 84 insertions, 49 deletions
diff --git a/cpp/src/slice2xsd/.depend b/cpp/src/slice2xsd/.depend index bb2e91009c7..c99aa513403 100644 --- a/cpp/src/slice2xsd/.depend +++ b/cpp/src/slice2xsd/.depend @@ -1,3 +1,3 @@ Gen.o: Gen.cpp ../../include/IceUtil/Functional.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Slice/CPlusPlusUtil.h ../../include/Slice/Parser.h ../../include/IceUtil/Shared.h ../../include/IceUtil/InputUtil.h ../../include/IceUtil/OutputUtil.h Gen.h Main.o: Main.cpp Gen.h ../../include/Slice/Parser.h ../../include/IceUtil/Shared.h ../../include/IceUtil/Config.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/InputUtil.h ../../include/IceUtil/OutputUtil.h -Validate.o: Validate.cpp +Validate.o: Validate.cpp ../../include/IceUtil/Config.h diff --git a/cpp/src/slice2xsd/Validate.cpp b/cpp/src/slice2xsd/Validate.cpp index f70763dc2cb..b2bed446c19 100644 --- a/cpp/src/slice2xsd/Validate.cpp +++ b/cpp/src/slice2xsd/Validate.cpp @@ -8,6 +8,8 @@ // // ********************************************************************** +#include <IceUtil/Config.h> + #include <util/PlatformUtils.hpp> #include <util/XMLString.hpp> #include <util/XMLUniDefs.hpp> @@ -26,6 +28,7 @@ #include <iostream> using namespace std; + // Global streaming operator for DOMString is defined in DOMPrint.cpp //extern ostream& operator<<(ostream& target, const DOMString& s); ostream& operator<< (ostream& target, const DOMString& s) @@ -61,7 +64,6 @@ public: << "\", line " << toCatch.getLineNumber() << ", column " << toCatch.getColumnNumber() << "\n Message: " << DOMString(toCatch.getMessage()) << endl; - } void @@ -80,23 +82,30 @@ public: bool getSawErrors() const { return _sawErrors; } - bool _sawErrors; + bool _sawErrors; }; void -usage(const char* progName) +usage(const char* n) { + cerr << "Usage: " << n << " xml-files...\n"; + cerr << + "Options:\n" + "-h, --help Show this message.\n" + "-v, --version Display the Ice version.\n" + ; } int main(int argc, char** argv) { - // Initialize the XML4C2 system + // + // Initialize the XML4C2 system + // try { XMLPlatformUtils::Initialize(); } - catch(const XMLException& toCatch) { cerr << "Error during Xerces-c Initialization.\n" @@ -105,58 +114,84 @@ main(int argc, char** argv) return 1; } + int idx = 1; + while(idx < argc) + { + if(strcmp(argv[idx], "-h") == 0 || strcmp(argv[idx], "--help") == 0) + { + usage(argv[0]); + return EXIT_SUCCESS; + } + else if(strcmp(argv[idx], "-v") == 0 || strcmp(argv[idx], "--version") == 0) + { + cout << ICE_STRING_VERSION << endl; + return EXIT_SUCCESS; + } + else if(argv[idx][0] == '-') + { + cerr << argv[0] << ": unknown option `" << argv[idx] << "'" << endl; + usage(argv[0]); + return EXIT_FAILURE; + } + else + { + ++idx; + } + } + if(argc < 2) { + cerr << argv[0] << ": no input file" << endl; usage(argv[0]); return EXIT_FAILURE; } - // - // Create our parser, then attach an error handler to the parser. - // The parser will call back to methods of the ErrorHandler if it - // discovers errors during the course of parsing the XML document. - // - DOMParser* parser = new DOMParser; - parser->setValidationScheme(DOMParser::Val_Auto); - parser->setDoNamespaces(true); - parser->setDoSchema(true); - parser->setValidationSchemaFullChecking(true); - - DOMTreeErrorReporter *errReporter = new DOMTreeErrorReporter(); - parser->setErrorHandler(errReporter); - parser->setCreateEntityReferenceNodes(false); - parser->setToCreateXMLDeclTypeNode(true); - - // - // Parse the XML file, catching any XML exceptions that might propogate - // out of it. - // bool errorsOccured = false; - try + for(idx = 1 ; idx < argc ; ++idx) { - parser->parse(argv[1]); - int errorCount = parser->getErrorCount(); - if(errorCount > 0) + // + // Create our parser, then attach an error handler to the parser. + // The parser will call back to methods of the ErrorHandler if it + // discovers errors during the course of parsing the XML document. + // + DOMParser* parser = new DOMParser; + parser->setValidationScheme(DOMParser::Val_Auto); + parser->setDoNamespaces(true); + parser->setDoSchema(true); + parser->setValidationSchemaFullChecking(true); + + DOMTreeErrorReporter *errReporter = new DOMTreeErrorReporter(); + parser->setErrorHandler(errReporter); + parser->setCreateEntityReferenceNodes(false); + parser->setToCreateXMLDeclTypeNode(true); + + // + // Parse the XML file, catching any XML exceptions that might propogate + // out of it. + // + try + { + parser->parse(argv[idx]); + if(parser->getErrorCount() > 0) + { + errorsOccured = true; + } + } + catch(const XMLException& e) + { + cerr << "An error occured during parsing\n Message: " << DOMString(e.getMessage()) << endl; errorsOccured = true; - } - - catch(const XMLException& e) - { - cerr << "An error occured during parsing\n Message: " - << DOMString(e.getMessage()) << endl; - errorsOccured = true; - } - catch(const DOM_DOMException& e) - { - cerr << "A DOM error occured during parsing\n DOMException code: " - << e.code << endl; - errorsOccured = true; - } - - catch (...) - { - cerr << "An error occured during parsing\n " << endl; - errorsOccured = true; + } + catch(const DOM_DOMException& e) + { + cerr << "A DOM error occured during parsing\n DOMException code: " << e.code << endl; + errorsOccured = true; + } + catch(...) + { + cerr << "An error occured during parsing\n " << endl; + errorsOccured = true; + } } return (errorsOccured) ? EXIT_FAILURE : EXIT_SUCCESS; |