You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by pe...@apache.org on 2002/11/04 23:24:21 UTC
cvs commit: xml-xerces/c/src/xercesc/util XMLMsgLoader.cpp XMLUni.hpp XMLUni.cpp XMLMsgLoader.hpp PlatformUtils.hpp PlatformUtils.cpp
peiyongz 2002/11/04 14:24:21
Modified: c/src/xercesc/util XMLUni.hpp XMLUni.cpp XMLMsgLoader.hpp
PlatformUtils.hpp PlatformUtils.cpp
Added: c/src/xercesc/util XMLMsgLoader.cpp
Log:
Locale setting for message loader
Revision Changes Path
1.17 +13 -11 xml-xerces/c/src/xercesc/util/XMLUni.hpp
Index: XMLUni.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/XMLUni.hpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- XMLUni.hpp 4 Nov 2002 15:22:05 -0000 1.16
+++ XMLUni.hpp 4 Nov 2002 22:24:21 -0000 1.17
@@ -254,17 +254,19 @@
static const XMLCh fgDOMValidation[];
static const XMLCh fgDOMWhitespaceInElementContent[];
- // Introduced in DOM Level 3
- // DOMWriter feature
- static const XMLCh fgDOMWRTCanonicalForm[];
- static const XMLCh fgDOMWRTDiscardDefaultContent[];
- static const XMLCh fgDOMWRTEntities[];
- static const XMLCh fgDOMWRTFormatPrettyPrint[];
- static const XMLCh fgDOMWRTNormalizeCharacters[];
- static const XMLCh fgDOMWRTSplitCdataSections[];
- static const XMLCh fgDOMWRTValidation[];
- static const XMLCh fgDOMWRTWhitespaceInElementContent[];
+ // Introduced in DOM Level 3
+ // DOMWriter feature
+ static const XMLCh fgDOMWRTCanonicalForm[];
+ static const XMLCh fgDOMWRTDiscardDefaultContent[];
+ static const XMLCh fgDOMWRTEntities[];
+ static const XMLCh fgDOMWRTFormatPrettyPrint[];
+ static const XMLCh fgDOMWRTNormalizeCharacters[];
+ static const XMLCh fgDOMWRTSplitCdataSections[];
+ static const XMLCh fgDOMWRTValidation[];
+ static const XMLCh fgDOMWRTWhitespaceInElementContent[];
+ // Locale
+ static const char fgXercescDefaultLocale[];
};
XERCES_CPP_NAMESPACE_END
1.19 +4 -1 xml-xerces/c/src/xercesc/util/XMLUni.cpp
Index: XMLUni.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/XMLUni.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- XMLUni.cpp 4 Nov 2002 15:22:05 -0000 1.18
+++ XMLUni.cpp 4 Nov 2002 22:24:21 -0000 1.19
@@ -1199,5 +1199,8 @@
chLatin_n, chLatin_t, chLatin_e, chLatin_n, chLatin_t, chNull
};
+// en_US
+const char XMLUni::fgXercescDefaultLocale[] = "en_US";
+
XERCES_CPP_NAMESPACE_END
1.3 +29 -33 xml-xerces/c/src/xercesc/util/XMLMsgLoader.hpp
Index: XMLMsgLoader.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/XMLMsgLoader.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XMLMsgLoader.hpp 4 Nov 2002 15:22:05 -0000 1.2
+++ XMLMsgLoader.hpp 4 Nov 2002 22:24:21 -0000 1.3
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.3 2002/11/04 22:24:21 peiyongz
+ * Locale setting for message loader
+ *
* Revision 1.2 2002/11/04 15:22:05 tng
* C++ Namespace Support.
*
@@ -161,11 +164,27 @@
, const char* const repText4 = 0
) = 0;
+ /** @name Locale Handling */
+ //@{
+ /**
+ * This function enables set the locale information which
+ * all concrete message loaders shall refer to during instantiation.
+ *
+ * Note: for detailed discussion, refer to PlatformUtils::initalize()
+ */
+ static void setLocale(const char* const localeToAdopt);
+
+ /**
+ * Fr the derived to retrieve locale info during construction
+ */
+ static const char* getLocale();
+
+ //@}
// -----------------------------------------------------------------------
- // Getter methods
+ // Deprecated: Getter methods
// -----------------------------------------------------------------------
- const XMLCh* getLanguageName() const;
+ virtual const XMLCh* getLanguageName() const;
protected :
@@ -174,13 +193,11 @@
// -----------------------------------------------------------------------
XMLMsgLoader();
-
// -----------------------------------------------------------------------
- // Protected helper methods
+ // Deprecated: Protected helper methods
// -----------------------------------------------------------------------
void setLanguageName(XMLCh* const nameToAdopt);
-
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
@@ -192,12 +209,13 @@
// -----------------------------------------------------------------------
// Private data members
//
- // fLanguage
- // This is the language that is represented by this instance of the
- // loader. The derived class must pass this through for storage and
- // we adopt it and delete it when we go.
+ // fLocale
+ // Locale info set through PlatformUtils::init().
+ // The derived class may refer to this for locale information.
+ //
// -----------------------------------------------------------------------
- XMLCh* fLanguage;
+ static char* fLocale;
+ static XMLCh fLanguage[];
};
@@ -206,36 +224,14 @@
// ---------------------------------------------------------------------------
inline XMLMsgLoader::~XMLMsgLoader()
{
- delete [] fLanguage;
}
// ---------------------------------------------------------------------------
// XMLMsgLoader: Hidden Constructors
// ---------------------------------------------------------------------------
-inline XMLMsgLoader::XMLMsgLoader() :
-
- fLanguage(0)
-{
-}
-
-
-// ---------------------------------------------------------------------------
-// XMLMsgLoader: Getter methods
-// ---------------------------------------------------------------------------
-inline const XMLCh* XMLMsgLoader::getLanguageName() const
-{
- return fLanguage;
-}
-
-
-// ---------------------------------------------------------------------------
-// XMLMsgLoader: Protected helper methods
-// ---------------------------------------------------------------------------
-inline void XMLMsgLoader::setLanguageName(XMLCh* const nameToAdopt)
+inline XMLMsgLoader::XMLMsgLoader()
{
- delete [] fLanguage;
- fLanguage = nameToAdopt;
}
XERCES_CPP_NAMESPACE_END
1.6 +2 -2 xml-xerces/c/src/xercesc/util/PlatformUtils.hpp
Index: PlatformUtils.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/PlatformUtils.hpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- PlatformUtils.hpp 4 Nov 2002 15:22:04 -0000 1.5
+++ PlatformUtils.hpp 4 Nov 2002 22:24:21 -0000 1.6
@@ -158,7 +158,7 @@
*
* Initialization <b>must</b> be called first in any client code.
*/
- static void Initialize();
+ static void Initialize(const char* const locale = XMLUni::fgXercescDefaultLocale);
/** Perform per-process parser termination
*
1.4 +31 -1 xml-xerces/c/src/xercesc/util/PlatformUtils.cpp
Index: PlatformUtils.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/PlatformUtils.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- PlatformUtils.cpp 4 Nov 2002 15:22:04 -0000 1.3
+++ PlatformUtils.cpp 4 Nov 2002 22:24:21 -0000 1.4
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.4 2002/11/04 22:24:21 peiyongz
+ * Locale setting for message loader
+ *
* Revision 1.3 2002/11/04 15:22:04 tng
* C++ Namespace Support.
*
@@ -187,7 +190,7 @@
// ---------------------------------------------------------------------------
// XMLPlatformUtils: Init/term methods
// ---------------------------------------------------------------------------
-void XMLPlatformUtils::Initialize()
+void XMLPlatformUtils::Initialize(const char* const locale)
{
//
// Effects of overflow:
@@ -261,6 +264,25 @@
// a zero pointer if this platform doesn't want to support this.
//
fgNetAccessor = makeNetAccessor();
+
+ /***
+ * Locale setting for Message Loader
+ *
+ * Noticed: The locale is set iff the Initialize() is invoked for the
+ * very first time, thus to ensure that each and every message
+ * loaders, in this process space, share the same locale.
+ *
+ * All subsequent invocations of Initialize() have no effect on the
+ * message loaders, either instantiated, or to be instantiated.
+ *
+ * To set to a different locale, client application needs to
+ * Terminate() (or multiple Terminate() in the case where multiple
+ * Initialize() have been invoked before) and then followed by an
+ * Initialize(new_locale).
+ *
+ ***/
+ XMLMsgLoader::setLocale(locale);
+
}
@@ -317,8 +339,16 @@
//
platformTerm();
+ /***
+ * de-allocate resource
+ *
+ * refer to discussion in the Initialize()
+ ***/
+ XMLMsgLoader::setLocale(0);
+
// And say we are no longer initialized
gInitFlag = 0;
+
}
1.1 xml-xerces/c/src/xercesc/util/XMLMsgLoader.cpp
Index: XMLMsgLoader.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache\@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation, and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Id: XMLMsgLoader.cpp,v 1.1 2002/11/04 22:24:21 peiyongz Exp $
* $Log: XMLMsgLoader.cpp,v $
* Revision 1.1 2002/11/04 22:24:21 peiyongz
* Locale setting for message loader
*
*
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/util/XMLMsgLoader.hpp>
#include <xercesc/util/XMLString.hpp>
#include <xercesc/util/XMLUniDefs.hpp>
XERCES_CPP_NAMESPACE_BEGIN
/***
* The PlatformUtils::initialize() would set fLocale
* to either a user-privded string or 0
*
***/
char* XMLMsgLoader::fLocale = 0;
XMLCh XMLMsgLoader::fLanguage[] = {chLatin_e, chLatin_n, chNull};
/***
* if localeToAdopt is 0, that is to release memory for
* the user defined locale string
*
***/
void XMLMsgLoader::setLocale(const char* const localeToAdopt)
{
/***
* Release the current setting's memory, if any
***/
if (fLocale)
{
delete [] fLocale;
fLocale = 0;
}
/***
*
* REVISIT: later we may do locale format checking
*
* refer to phttp://oss.software.ibm.com/icu/userguide/locale.html
* for details.
*/
if (localeToAdopt)
{
fLocale = XMLString::replicate(localeToAdopt);
XMLString::transcode(fLocale, fLanguage, 2);
fLanguage[2] = 0;
}
}
const char* XMLMsgLoader::getLocale()
{
return fLocale;
}
// ---------------------------------------------------------------------------
// Deprecated
//
// These two methods are deprecated.
//
// The default implementations for these two methods are provided as is,
// any specific derivative may change this as and when necessary.
//
// ---------------------------------------------------------------------------
const XMLCh* XMLMsgLoader::getLanguageName() const
{
return fLanguage;
}
void XMLMsgLoader::setLanguageName(XMLCh* const)
{
}
XERCES_CPP_NAMESPACE_END
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org