diff --git a/samples/DOMCount/DOMCount.cpp b/samples/DOMCount/DOMCount.cpp index ce0ce0d1275a67f8ee0cb426471d29c57af860fa..f12852540b69538319195e7d0ddc616561680b19 100644 --- a/samples/DOMCount/DOMCount.cpp +++ b/samples/DOMCount/DOMCount.cpp @@ -197,15 +197,15 @@ int main(int argC, char* argV[]) } // Instantiate the DOM parser. - DOMParser parser; - parser.setValidationScheme(valScheme); - parser.setDoNamespaces(doNamespaces); - parser.setDoSchema(doSchema); - parser.setValidationSchemaFullChecking(schemaFullChecking); + DOMParser* parser = new DOMParser; + parser->setValidationScheme(valScheme); + parser->setDoNamespaces(doNamespaces); + parser->setDoSchema(doSchema); + parser->setValidationSchemaFullChecking(schemaFullChecking); // And create our error handler and install it DOMCountErrorHandler errorHandler; - parser.setErrorHandler(&errorHandler); + parser->setErrorHandler(&errorHandler); // // Get the starting time and kick off the parse of the indicated @@ -250,7 +250,7 @@ int main(int argC, char* argV[]) try { const unsigned long startMillis = XMLPlatformUtils::getCurrentMillis(); - parser.parse(xmlFile); + parser->parse(xmlFile); const unsigned long endMillis = XMLPlatformUtils::getCurrentMillis(); duration = endMillis - startMillis; } @@ -289,7 +289,7 @@ int main(int argC, char* argV[]) } else { - DOM_Document doc = parser.getDocument(); + DOM_Document doc = parser->getDocument(); unsigned int elementCount = doc.getElementsByTagName("*").getLength(); // Print out the stats that we collected and time taken. @@ -301,6 +301,11 @@ int main(int argC, char* argV[]) if (doList) fin.close(); + // + // Delete the parser itself. Must be done prior to calling Terminate, below. + // + delete parser; + // And call the termination method XMLPlatformUtils::Terminate(); diff --git a/samples/EnumVal/EnumVal.cpp b/samples/EnumVal/EnumVal.cpp index 378da32d9bd17591e3739ed26014844c30586686..77a135a1f53c9c523e401e2b33829d4871514ddd 100644 --- a/samples/EnumVal/EnumVal.cpp +++ b/samples/EnumVal/EnumVal.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.14 2001/10/25 15:18:33 tng + * delete the parser before XMLPlatformUtils::Terminate. + * * Revision 1.13 2001/10/19 19:02:42 tng * [Bug 3909] return non-zero an exit code when error was encounted. * And other modification for consistent help display and return code across samples. @@ -229,8 +232,8 @@ int main(int argC, char* argV[]) // int errorCount = 0; DTDValidator* valToUse = new DTDValidator; - SAXParser parser(valToUse); - parser.setValidationScheme(valScheme); + SAXParser* parser = new SAXParser(valToUse); + parser->setValidationScheme(valScheme); // // Get the starting time and kick off the parse of the indicated @@ -238,8 +241,8 @@ int main(int argC, char* argV[]) // try { - parser.parse(xmlFile); - errorCount = parser.getErrorCount(); + parser->parse(xmlFile); + errorCount = parser->getErrorCount(); } catch (const XMLException& e) @@ -332,6 +335,11 @@ int main(int argC, char* argV[]) else cout << "\nErrors occured, no output available\n" << endl; + // + // Delete the parser itself. Must be done prior to calling Terminate, below. + // + delete parser; + // And call the termination method XMLPlatformUtils::Terminate(); diff --git a/samples/IDOMCount/IDOMCount.cpp b/samples/IDOMCount/IDOMCount.cpp index 48b1522acdedaeb33bf34728d651fe7958b120f7..4bda6b2c648f22af0c98823ff9f2ded612e2adfe 100644 --- a/samples/IDOMCount/IDOMCount.cpp +++ b/samples/IDOMCount/IDOMCount.cpp @@ -233,15 +233,15 @@ int main(int argC, char* argV[]) } // Instantiate the DOM parser. - IDOMParser parser; - parser.setValidationScheme(valScheme); - parser.setDoNamespaces(doNamespaces); - parser.setDoSchema(doSchema); - parser.setValidationSchemaFullChecking(schemaFullChecking); + IDOMParser* parser = new IDOMParser; + parser->setValidationScheme(valScheme); + parser->setDoNamespaces(doNamespaces); + parser->setDoSchema(doSchema); + parser->setValidationSchemaFullChecking(schemaFullChecking); // And create our error handler and install it DOMCountErrorHandler errorHandler; - parser.setErrorHandler(&errorHandler); + parser->setErrorHandler(&errorHandler); // // Get the starting time and kick off the parse of the indicated @@ -286,8 +286,8 @@ int main(int argC, char* argV[]) try { const unsigned long startMillis = XMLPlatformUtils::getCurrentMillis(); - parser.resetDocumentPool(); - parser.parse(xmlFile); + parser->resetDocumentPool(); + parser->parse(xmlFile); const unsigned long endMillis = XMLPlatformUtils::getCurrentMillis(); duration = endMillis - startMillis; } @@ -326,7 +326,7 @@ int main(int argC, char* argV[]) } else { - IDOM_Document *doc = parser.getDocument(); + IDOM_Document *doc = parser->getDocument(); unsigned int elementCount = 0; if (doc) elementCount = countChildElements((IDOM_Node*)doc->getDocumentElement()); @@ -337,6 +337,11 @@ int main(int argC, char* argV[]) } } + // + // Delete the parser itself. Must be done prior to calling Terminate, below. + // + delete parser; + // And call the termination method XMLPlatformUtils::Terminate(); diff --git a/samples/MemParse/MemParse.cpp b/samples/MemParse/MemParse.cpp index 09d89804f2edbd78d23334b6cd139d4e76a58658..bca1ef428a9f68f1209010bca2595e2d98e9f54f 100644 --- a/samples/MemParse/MemParse.cpp +++ b/samples/MemParse/MemParse.cpp @@ -57,6 +57,9 @@ /* * $Log$ + * Revision 1.12 2001/10/25 15:18:33 tng + * delete the parser before XMLPlatformUtils::Terminate. + * * Revision 1.11 2001/10/19 18:56:08 tng * Pulled the hardcoded "encoding" out of the document itself and made it a #define * to make it easier to support other encodings. Patch from David McCreedy. @@ -271,19 +274,19 @@ int main(int argC, char* argV[]) // Create a SAX parser object. Then, according to what we were told on // the command line, set it to validate or not. // - SAXParser parser; - parser.setValidationScheme(valScheme); - parser.setDoNamespaces(doNamespaces); - parser.setDoSchema(doSchema); - parser.setValidationSchemaFullChecking(schemaFullChecking); + SAXParser* parser = new SAXParser; + parser->setValidationScheme(valScheme); + parser->setDoNamespaces(doNamespaces); + parser->setDoSchema(doSchema); + parser->setValidationSchemaFullChecking(schemaFullChecking); // // Create our SAX handler object and install it on the parser, as the // document and error handlers. // MemParseHandlers handler; - parser.setDocumentHandler(&handler); - parser.setErrorHandler(&handler); + parser->setDocumentHandler(&handler); + parser->setErrorHandler(&handler); // // Create MemBufferInputSource from the buffer containing the XML @@ -311,10 +314,10 @@ int main(int argC, char* argV[]) try { const unsigned long startMillis = XMLPlatformUtils::getCurrentMillis(); - parser.parse(*memBufIS); + parser->parse(*memBufIS); const unsigned long endMillis = XMLPlatformUtils::getCurrentMillis(); duration = endMillis - startMillis; - errorCount = parser.getErrorCount(); + errorCount = parser->getErrorCount(); } catch (const XMLException& e) @@ -338,6 +341,13 @@ int main(int argC, char* argV[]) << handler.getCharacterCount() << " characters).\n" << endl; } + // + // Delete the parser itself. Must be done prior to calling Terminate, below. + // + delete parser; + + delete memBufIS; + // And call the termination method XMLPlatformUtils::Terminate(); diff --git a/samples/PParse/PParse.cpp b/samples/PParse/PParse.cpp index e9b1341b1bcb2cfb537b948fc1a86f3c61d99590..3ca731e21b0bee0e4ea57b08173c2bb1db74a0a6 100644 --- a/samples/PParse/PParse.cpp +++ b/samples/PParse/PParse.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.12 2001/10/25 15:18:33 tng + * delete the parser before XMLPlatformUtils::Terminate. + * * Revision 1.11 2001/10/19 18:52:04 tng * Since PParse can take any XML file as input file, it shouldn't hardcode to expect 16 elements. * Change it to work similar to SAXCount which just prints the number of elements, characters, attributes ... etc. @@ -283,14 +286,14 @@ int main(int argC, char* argV[]) // Create a SAX parser object to use and create our SAX event handlers // and plug them in. // - SAXParser parser; + SAXParser* parser = new SAXParser; PParseHandlers handler; - parser.setDocumentHandler(&handler); - parser.setErrorHandler(&handler); - parser.setValidationScheme(valScheme); - parser.setDoNamespaces(doNamespaces); - parser.setDoSchema(doSchema); - parser.setValidationSchemaFullChecking(schemaFullChecking); + parser->setDocumentHandler(&handler); + parser->setErrorHandler(&handler); + parser->setValidationScheme(valScheme); + parser->setDoNamespaces(doNamespaces); + parser->setDoSchema(doSchema); + parser->setValidationSchemaFullChecking(schemaFullChecking); // // Ok, lets do the progressive parse loop. On each time around the @@ -304,7 +307,7 @@ int main(int argC, char* argV[]) XMLPScanToken token; const unsigned long startMillis = XMLPlatformUtils::getCurrentMillis(); - if (!parser.parseFirst(xmlFile, token)) + if (!parser->parseFirst(xmlFile, token)) { cerr << "scanFirst() failed\n" << endl; XMLPlatformUtils::Terminate(); @@ -316,21 +319,21 @@ int main(int argC, char* argV[]) // or hit the end. // bool gotMore = true; - while (gotMore && !parser.getErrorCount()) - gotMore = parser.parseNext(token); + while (gotMore && !parser->getErrorCount()) + gotMore = parser->parseNext(token); const unsigned long endMillis = XMLPlatformUtils::getCurrentMillis(); duration = endMillis - startMillis; - errorCount = parser.getErrorCount(); + errorCount = parser->getErrorCount(); // - // Reset the parser. In this simple progrma, since we just exit + // Reset the parser-> In this simple progrma, since we just exit // now, its not technically required. But, in programs which // would remain open, you should reset after a progressive parse // in case you broke out before the end of the file. This insures // that all opened files, sockets, etc... are closed. // - parser.parseReset(token); + parser->parseReset(token); } catch (const XMLException& toCatch) @@ -352,6 +355,11 @@ int main(int argC, char* argV[]) << handler.getCharacterCount() << " chars)" << endl; } + // + // Delete the parser itself. Must be done prior to calling Terminate, below. + // + delete parser; + // And call the termination method XMLPlatformUtils::Terminate(); diff --git a/samples/Redirect/Redirect.cpp b/samples/Redirect/Redirect.cpp index b2cf22d7ea437b940d7da7a785a4a6f4e71e9750..a1d5e698f0b3b1fa3ee842c8dc2c882954cc10fe 100644 --- a/samples/Redirect/Redirect.cpp +++ b/samples/Redirect/Redirect.cpp @@ -75,6 +75,9 @@ * to read the contents of 'personal.dtd'. * * $Log$ + * Revision 1.6 2001/10/25 15:18:33 tng + * delete the parser before XMLPlatformUtils::Terminate. + * * Revision 1.5 2001/10/19 19:02:42 tng * [Bug 3909] return non-zero an exit code when error was encounted. * And other modification for consistent help display and return code across samples. @@ -152,16 +155,16 @@ int main(int argc, char* args[]) // Create a SAX parser object. Then, according to what we were told on // the command line, set it to validate or not. // - SAXParser parser; + SAXParser* parser = new SAXParser; // // Create our SAX handler object and install it on the parser, as the // document, entity and error handlers. // RedirectHandlers handler; - parser.setDocumentHandler(&handler); - parser.setErrorHandler(&handler); - parser.setEntityResolver(&handler); + parser->setDocumentHandler(&handler); + parser->setErrorHandler(&handler); + parser->setEntityResolver(&handler); // // Get the starting time and kick off the parse of the indicated file. @@ -172,10 +175,10 @@ int main(int argc, char* args[]) try { const unsigned long startMillis = XMLPlatformUtils::getCurrentMillis(); - parser.parse(xmlFile); + parser->parse(xmlFile); const unsigned long endMillis = XMLPlatformUtils::getCurrentMillis(); duration = endMillis - startMillis; - errorCount = parser.getErrorCount(); + errorCount = parser->getErrorCount(); } catch (const XMLException& e) @@ -196,6 +199,11 @@ int main(int argc, char* args[]) << handler.getCharacterCount() << " chars)" << endl; } + // + // Delete the parser itself. Must be done prior to calling Terminate, below. + // + delete parser; + XMLPlatformUtils::Terminate(); if (errorCount > 0) diff --git a/samples/SAX2Count/SAX2Count.cpp b/samples/SAX2Count/SAX2Count.cpp index 1cea7ee6057dabd12e4f5305f7f6be99b33955c6..c8e15b67b76463ce4e5cc947477cb6ac3db8e23c 100644 --- a/samples/SAX2Count/SAX2Count.cpp +++ b/samples/SAX2Count/SAX2Count.cpp @@ -56,6 +56,9 @@ /* * $Log$ +* Revision 1.12 2001/10/25 15:18:33 tng +* delete the parser before XMLPlatformUtils::Terminate. +* * Revision 1.11 2001/10/19 19:02:43 tng * [Bug 3909] return non-zero an exit code when error was encounted. * And other modification for consistent help display and return code across samples. @@ -345,6 +348,11 @@ int main(int argC, char* argV[]) if (doList) fin.close(); + // + // Delete the parser itself. Must be done prior to calling Terminate, below. + // + delete parser; + // And call the termination method XMLPlatformUtils::Terminate(); diff --git a/samples/SAX2Print/SAX2Print.cpp b/samples/SAX2Print/SAX2Print.cpp index 9fcf6a48bae0fdfdba0033623822493f805519e5..a03f2b40593d25e8f5f79209f5bf77b63a968f74 100644 --- a/samples/SAX2Print/SAX2Print.cpp +++ b/samples/SAX2Print/SAX2Print.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.6 2001/10/25 15:18:33 tng + * delete the parser before XMLPlatformUtils::Terminate. + * * Revision 1.5 2001/10/19 19:02:43 tng * [Bug 3909] return non-zero an exit code when error was encounted. * And other modification for consistent help display and return code across samples. @@ -313,6 +316,11 @@ int main(int argC, char* argV[]) return 4; } + // + // Delete the parser itself. Must be done prior to calling Terminate, below. + // + delete parser; + // And call the termination method XMLPlatformUtils::Terminate(); diff --git a/samples/SAXCount/SAXCount.cpp b/samples/SAXCount/SAXCount.cpp index 07879beb37ec75f60919dd6b0f38aa1f31358af2..394c9e57921ba2a3a6085f64ec45aa3fcd216e95 100644 --- a/samples/SAXCount/SAXCount.cpp +++ b/samples/SAXCount/SAXCount.cpp @@ -56,6 +56,9 @@ /* * $Log$ +* Revision 1.18 2001/10/25 15:18:33 tng +* delete the parser before XMLPlatformUtils::Terminate. +* * Revision 1.17 2001/10/19 19:02:43 tng * [Bug 3909] return non-zero an exit code when error was encounted. * And other modification for consistent help display and return code across samples. @@ -261,20 +264,20 @@ int main(int argC, char* argV[]) // Create a SAX parser object. Then, according to what we were told on // the command line, set it to validate or not. // - SAXParser parser; + SAXParser* parser = new SAXParser; - parser.setValidationScheme(valScheme); - parser.setDoNamespaces(doNamespaces); - parser.setDoSchema(doSchema); - parser.setValidationSchemaFullChecking(schemaFullChecking); + parser->setValidationScheme(valScheme); + parser->setDoNamespaces(doNamespaces); + parser->setDoSchema(doSchema); + parser->setValidationSchemaFullChecking(schemaFullChecking); // // Create our SAX handler object and install it on the parser, as the // document and error handler. // SAXCountHandlers handler; - parser.setDocumentHandler(&handler); - parser.setErrorHandler(&handler); + parser->setDocumentHandler(&handler); + parser->setErrorHandler(&handler); // @@ -324,7 +327,7 @@ int main(int argC, char* argV[]) try { const unsigned long startMillis = XMLPlatformUtils::getCurrentMillis(); - parser.parse(xmlFile); + parser->parse(xmlFile); const unsigned long endMillis = XMLPlatformUtils::getCurrentMillis(); duration = endMillis - startMillis; } @@ -362,6 +365,11 @@ int main(int argC, char* argV[]) if (doList) fin.close(); + // + // Delete the parser itself. Must be done prior to calling Terminate, below. + // + delete parser; + // And call the termination method XMLPlatformUtils::Terminate(); diff --git a/samples/SAXPrint/SAXPrint.cpp b/samples/SAXPrint/SAXPrint.cpp index b5a613d33f0c215675f444b4ee908af316356637..82ee0169b69ebe0220c3ffba40aa4ce3253df3f8 100644 --- a/samples/SAXPrint/SAXPrint.cpp +++ b/samples/SAXPrint/SAXPrint.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.17 2001/10/25 15:18:33 tng + * delete the parser before XMLPlatformUtils::Terminate. + * * Revision 1.16 2001/10/19 19:02:43 tng * [Bug 3909] return non-zero an exit code when error was encounted. * And other modification for consistent help display and return code across samples. @@ -313,24 +316,24 @@ int main(int argC, char* argV[]) // Create a SAX parser object. Then, according to what we were told on // the command line, set it to validate or not. // - SAXParser parser; - parser.setValidationScheme(valScheme); - parser.setDoNamespaces(doNamespaces); - parser.setDoSchema(doSchema); - parser.setValidationSchemaFullChecking(schemaFullChecking); + SAXParser* parser = new SAXParser; + parser->setValidationScheme(valScheme); + parser->setDoNamespaces(doNamespaces); + parser->setDoSchema(doSchema); + parser->setValidationSchemaFullChecking(schemaFullChecking); // // Create the handler object and install it as the document and error - // handler for the parser. Then parse the file and catch any exceptions + // handler for the parser-> Then parse the file and catch any exceptions // that propogate out // try { SAXPrintHandlers handler(encodingName, unRepFlags); - parser.setDocumentHandler(&handler); - parser.setErrorHandler(&handler); - parser.parse(xmlFile); - errorCount = parser.getErrorCount(); + parser->setDocumentHandler(&handler); + parser->setErrorHandler(&handler); + parser->parse(xmlFile); + errorCount = parser->getErrorCount(); } catch (const XMLException& toCatch) @@ -342,6 +345,11 @@ int main(int argC, char* argV[]) return -1; } + // + // Delete the parser itself. Must be done prior to calling Terminate, below. + // + delete parser; + // And call the termination method XMLPlatformUtils::Terminate(); diff --git a/samples/StdInParse/StdInParse.cpp b/samples/StdInParse/StdInParse.cpp index ed010193012ef56c7111a1bcb12d58723ffcde2c..d59a7098d2cef4e435344afad9c59232874fd441 100644 --- a/samples/StdInParse/StdInParse.cpp +++ b/samples/StdInParse/StdInParse.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.12 2001/10/25 15:18:33 tng + * delete the parser before XMLPlatformUtils::Terminate. + * * Revision 1.11 2001/10/19 19:02:43 tng * [Bug 3909] return non-zero an exit code when error was encounted. * And other modification for consistent help display and return code across samples. @@ -230,11 +233,11 @@ int main(int argC, char* argV[]) // Create a SAX parser object. Then, according to what we were told on // the command line, set the options. // - SAXParser parser; - parser.setValidationScheme(valScheme); - parser.setDoNamespaces(doNamespaces); - parser.setDoSchema(doSchema); - parser.setValidationSchemaFullChecking(schemaFullChecking); + SAXParser* parser = new SAXParser; + parser->setValidationScheme(valScheme); + parser->setDoNamespaces(doNamespaces); + parser->setDoSchema(doSchema); + parser->setValidationSchemaFullChecking(schemaFullChecking); // @@ -244,8 +247,8 @@ int main(int argC, char* argV[]) // to do. // StdInParseHandlers handler; - parser.setDocumentHandler(&handler); - parser.setErrorHandler(&handler); + parser->setDocumentHandler(&handler); + parser->setErrorHandler(&handler); // // Kick off the parse and catch any exceptions. Create a standard @@ -257,10 +260,10 @@ int main(int argC, char* argV[]) try { const unsigned long startMillis = XMLPlatformUtils::getCurrentMillis(); - parser.parse(src); + parser->parse(src); const unsigned long endMillis = XMLPlatformUtils::getCurrentMillis(); duration = endMillis - startMillis; - errorCount = parser.getErrorCount(); + errorCount = parser->getErrorCount(); } catch (const XMLException& e) @@ -281,6 +284,11 @@ int main(int argC, char* argV[]) << handler.getCharacterCount() << " chars)" << endl; } + // + // Delete the parser itself. Must be done prior to calling Terminate, below. + // + delete parser; + XMLPlatformUtils::Terminate(); if (errorCount > 0)