peiyongz 2002/11/07 10:30:34
Modified: c/samples/DOMCount DOMCount.cpp
Log:
command line option for "locale"
Revision Changes Path
1.31 +39 -19 xml-xerces/c/samples/DOMCount/DOMCount.cpp
Index: DOMCount.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/samples/DOMCount/DOMCount.cpp,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- DOMCount.cpp 4 Nov 2002 14:08:59 -0000 1.30
+++ DOMCount.cpp 7 Nov 2002 18:30:34 -0000 1.31
@@ -96,7 +96,9 @@
" -n Enable namespace processing. Defaults to off.\n"
" -s Enable schema processing. Defaults to off.\n"
" -f Enable full schema constraint checking. Defaults to
off.\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;
}
@@ -128,24 +130,11 @@
// ---------------------------------------------------------------------------
int main(int argC, char* argV[])
{
- // Initialize the XML4C system
- try
- {
- XMLPlatformUtils::Initialize();
- }
-
- catch (const XMLException& toCatch)
- {
- cerr << "Error during initialization! :\n"
- << StrX(toCatch.getMessage()) << endl;
- return 1;
- }
// Check command line and extract arguments.
if (argC < 2)
{
usage();
- XMLPlatformUtils::Terminate();
return 1;
}
@@ -156,6 +145,9 @@
bool schemaFullChecking = false;
bool doList = false;
bool errorOccurred = false;
+ bool recognizeNEL = false;
+ char localeStr[64];
+ memset(localeStr, 0, sizeof localeStr);
int argInd;
for (argInd = 1; argInd < argC; argInd++)
@@ -168,7 +160,6 @@
if (!strcmp(argV[argInd], "-?"))
{
usage();
- XMLPlatformUtils::Terminate();
return 2;
}
else if (!strncmp(argV[argInd], "-v=", 3)
@@ -185,7 +176,6 @@
else
{
cerr << "Unknown -v= value: " << parm << endl;
- XMLPlatformUtils::Terminate();
return 2;
}
}
@@ -215,8 +205,14 @@
// 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]
@@ -231,8 +227,32 @@
if (argInd != argC - 1)
{
usage();
- XMLPlatformUtils::Terminate();
return 1;
+ }
+
+ // Initialize the XML4C system
+ try
+ {
+ if (strlen(localeStr))
+ {
+ XMLPlatformUtils::Initialize(localeStr);
+ }
+ else
+ {
+ XMLPlatformUtils::Initialize();
+ }
+
+ if (recognizeNEL)
+ {
+ XMLPlatformUtils::recognizeNEL(recognizeNEL);
+ }
+ }
+
+ catch (const XMLException& toCatch)
+ {
+ cerr << "Error during initialization! :\n"
+ << StrX(toCatch.getMessage()) << endl;
+ return 1;
}
// Instantiate the DOM parser.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]