peiyongz    2002/11/07 10:30:42

  Modified:    c/samples/SAX2Count SAX2Count.cpp
  Log:
  command line option for "locale"
  
  Revision  Changes    Path
  1.22      +40 -18    xml-xerces/c/samples/SAX2Count/SAX2Count.cpp
  
  Index: SAX2Count.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/samples/SAX2Count/SAX2Count.cpp,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- SAX2Count.cpp     4 Nov 2002 14:09:06 -0000       1.21
  +++ SAX2Count.cpp     7 Nov 2002 18:30:42 -0000       1.22
  @@ -56,6 +56,9 @@
   
   /*
   * $Log$
  +* Revision 1.22  2002/11/07 18:30:42  peiyongz
  +* command line option for "locale"
  +*
   * Revision 1.21  2002/11/04 14:09:06  tng
   * [Bug 14201] use of ios::nocreate breaks build.
   *
  @@ -153,7 +156,9 @@
               "                NOTE: THIS IS OPPOSITE FROM OTHER SAMPLES.\n"
               "    -s          Disable schema processing. Defaults to on.\n"
               "                NOTE: THIS IS OPPOSITE FROM OTHER SAMPLES.\n"
  -                   "    -?          Show this help.\n\n"
  +            "    -special:nel  Recognize nel \n"
  +            "    -locale=ll_CC specify the locale, default: en_US \n"
  +            "    -?          Show this help.\n\n"
               "  * = Default if not provided explicitly.\n"
            << endl;
   }
  @@ -164,24 +169,11 @@
   // ---------------------------------------------------------------------------
   int main(int argC, char* argV[])
   {
  -    // Initialize the XML4C2 system
  -    try
  -    {
  -        XMLPlatformUtils::Initialize();
  -    }
  -
  -    catch (const XMLException& toCatch)
  -    {
  -        cerr << "Error during initialization! Message:\n"
  -            << StrX(toCatch.getMessage()) << endl;
  -        return 1;
  -    }
   
       // Check command line and extract arguments.
       if (argC < 2)
       {
           usage();
  -        XMLPlatformUtils::Terminate();
           return 1;
       }
   
  @@ -193,6 +185,9 @@
       bool                         doList = false;
       bool                         errorOccurred = false;
       bool                         namespacePrefixes = false;
  +    bool                         recognizeNEL = false;
  +    char                         localeStr[64];
  +    memset(localeStr, 0, sizeof localeStr);
   
       int argInd;
       for (argInd = 1; argInd < argC; argInd++)
  @@ -205,7 +200,6 @@
           if (!strcmp(argV[argInd], "-?"))
           {
               usage();
  -            XMLPlatformUtils::Terminate();
               return 2;
           }
            else if (!strncmp(argV[argInd], "-v=", 3)
  @@ -222,7 +216,6 @@
               else
               {
                   cerr << "Unknown -v= value: " << parm << endl;
  -                XMLPlatformUtils::Terminate();
                   return 2;
               }
           }
  @@ -257,8 +250,13 @@
               // it will recognize the unicode character 0x85 as new line character
               // instead of regular character as specified in XML 1.0
               // do not turn this on unless really necessary
  -            XMLPlatformUtils::recognizeNEL(true);
  +             recognizeNEL = true;
           }
  +         else if (!strncmp(argV[argInd], "-locale=", 8))
  +        {
  +             // Get out the end of line
  +             strcpy(localeStr, &(argV[argInd][8]));
  +        }                    
           else
           {
               cerr << "Unknown option '" << argV[argInd]
  @@ -273,7 +271,31 @@
       if (argInd != argC - 1)
       {
           usage();
  -        XMLPlatformUtils::Terminate();
  +        return 1;
  +    }
  +
  +    // Initialize the XML4C2 system
  +    try
  +    {
  +        if (strlen(localeStr))
  +        {
  +            XMLPlatformUtils::Initialize(localeStr);
  +        }
  +        else
  +        {
  +            XMLPlatformUtils::Initialize();
  +        }
  +
  +        if (recognizeNEL)
  +        {
  +            XMLPlatformUtils::recognizeNEL(recognizeNEL);
  +        }
  +    }
  +
  +    catch (const XMLException& toCatch)
  +    {
  +        cerr << "Error during initialization! Message:\n"
  +            << StrX(toCatch.getMessage()) << endl;
           return 1;
       }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to