You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by an...@locus.apache.org on 2000/10/20 01:52:41 UTC

cvs commit: xml-xerces/c/samples/SAXCount SAXCount.cpp

andyh       00/10/19 16:52:41

  Modified:    c/samples/SAXCount SAXCount.cpp
  Log:
  SAXCount: Allow multiple files on command line
  
  Revision  Changes    Path
  1.9       +68 -66    xml-xerces/c/samples/SAXCount/SAXCount.cpp
  
  Index: SAXCount.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/samples/SAXCount/SAXCount.cpp,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- SAXCount.cpp	2000/06/16 20:25:38	1.8
  +++ SAXCount.cpp	2000/10/19 23:52:41	1.9
  @@ -56,6 +56,9 @@
   
   /*
   * $Log: SAXCount.cpp,v $
  +* Revision 1.9  2000/10/19 23:52:41  andyh
  +* SAXCount: Allow multiple files on command line
  +*
   * Revision 1.8  2000/06/16 20:25:38  rahulj
   * Add the -v=always option to force validation checking. Need this
   * option for running the conformance tests.
  @@ -148,15 +151,8 @@
       const char*              xmlFile = 0;
       SAXParser::ValSchemes    valScheme = SAXParser::Val_Auto;
       bool                     doNamespaces = false;
  -    
  -    // See if non validating dom parser configuration is requested.
  -    if ((argC == 2) && !strcmp(argV[1], "-?"))
  -    {
  -        usage();
  -        XMLPlatformUtils::Terminate();
  -        return 2;
  -    }
       
  +
       int argInd;
       for (argInd = 1; argInd < argC; argInd++)
       {
  @@ -194,73 +190,78 @@
       }
       
       //
  -    //  There should be only one and only one parameter left, and that
  -    //  should be the file name.
  +    //  There should at least one parameter left, and that
  +    //  should be the file name(s).
       //
  -    if (argInd != argC - 1)
  +    if (argInd == argC)
       {
           usage();
           XMLPlatformUtils::Terminate();
           return 1;
       }
  -    xmlFile = argV[argInd];
  -    
  -    //
  -    //  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);
       
  -    //
  -    //  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);
  -    
  -
  -   //
  -    //  Get the starting time and kick off the parse of the indicated
  -    //  file. Catch any exceptions that might propogate out of it.
  -    //
  -    unsigned long duration;
  -    try
  -    {
  -        const unsigned long startMillis = XMLPlatformUtils::getCurrentMillis();
  -        parser.parse(xmlFile);
  -        const unsigned long endMillis = XMLPlatformUtils::getCurrentMillis();
  -        duration = endMillis - startMillis;
  -    }
  -    
  -    catch (const XMLException& e)
  -    {
  -        cerr << "\nError during parsing: '" << xmlFile << "'\n"
  -            << "Exception message is:  \n"
  -            << StrX(e.getMessage()) << "\n" << endl;
  -        XMLPlatformUtils::Terminate();
  -        return 4;
  -    }
  -
  -    catch (...)
  +    for (; argInd < argC; argInd++)
       {
  -        cerr << "\nUnexpected exception during parsing: '" << xmlFile << "'\n";
  -        XMLPlatformUtils::Terminate();
  -        return 4;
  -    }
  -
  -    
  -    // Print out the stats that we collected and time taken
  -    if (!handler.getSawErrors())
  -    {
  -        cout << xmlFile << ": " << duration << " ms ("
  -            << handler.getElementCount() << " elems, "
  -            << handler.getAttrCount() << " attrs, "
  -            << handler.getSpaceCount() << " spaces, "
  -            << handler.getCharacterCount() << " chars)" << endl;
  +        xmlFile = argV[argInd];
  +        
  +        //
  +        //  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);
  +        
  +        //
  +        //  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);
  +        
  +        
  +        //
  +        //  Get the starting time and kick off the parse of the indicated
  +        //  file. Catch any exceptions that might propogate out of it.
  +        //
  +        unsigned long duration;
  +        try
  +        {
  +            const unsigned long startMillis = XMLPlatformUtils::getCurrentMillis();
  +            parser.parse(xmlFile);
  +            const unsigned long endMillis = XMLPlatformUtils::getCurrentMillis();
  +            duration = endMillis - startMillis;
  +        }
  +        
  +        catch (const XMLException& e)
  +        {
  +            cerr << "\nError during parsing: '" << xmlFile << "'\n"
  +                << "Exception message is:  \n"
  +                << StrX(e.getMessage()) << "\n" << endl;
  +            XMLPlatformUtils::Terminate();
  +            return 4;
  +        }
  +        
  +        catch (...)
  +        {
  +            cerr << "\nUnexpected exception during parsing: '" << xmlFile << "'\n";
  +            XMLPlatformUtils::Terminate();
  +            return 4;
  +        }
  +        
  +        
  +        // Print out the stats that we collected and time taken
  +        if (!handler.getSawErrors())
  +        {
  +            cout << xmlFile << ": " << duration << " ms ("
  +                << handler.getElementCount() << " elems, "
  +                << handler.getAttrCount() << " attrs, "
  +                << handler.getSpaceCount() << " spaces, "
  +                << handler.getCharacterCount() << " chars)" << endl;
  +        }
       }
       
       // And call the termination method