GME  13
XMLMsgLoader.cpp
Go to the documentation of this file.
00001 /*
00002  * Licensed to the Apache Software Foundation (ASF) under one or more
00003  * contributor license agreements.  See the NOTICE file distributed with
00004  * this work for additional information regarding copyright ownership.
00005  * The ASF licenses this file to You under the Apache License, Version 2.0
00006  * (the "License"); you may not use this file except in compliance with
00007  * the License.  You may obtain a copy of the License at
00008  * 
00009  *      http://www.apache.org/licenses/LICENSE-2.0
00010  * 
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 /*
00019  *  $Id: XMLMsgLoader.cpp 482395 2006-12-04 22:44:40Z dbertoni $
00020  */
00021 
00022 // ---------------------------------------------------------------------------
00023 //  Includes
00024 // ---------------------------------------------------------------------------
00025 #include <xercesc/util/XMLMsgLoader.hpp>
00026 #include <xercesc/util/PlatformUtils.hpp>
00027 #include <xercesc/util/XMLString.hpp>
00028 #include <xercesc/util/XMLUniDefs.hpp>
00029 
00030 XERCES_CPP_NAMESPACE_BEGIN
00031 
00032 /***
00033  *   The PlatformUtils::initialize() would set fLocale
00034  *   to either a user-provided string or 0
00035  *
00036  ***/
00037 char* XMLMsgLoader::fLocale = 0;
00038 
00039 char* XMLMsgLoader::fPath = 0;
00040 
00041 /***
00042  *  if localeToAdopt is 0, that is to release memory for
00043  *  the user defined locale string
00044  *
00045  ***/
00046 void  XMLMsgLoader::setLocale(const char* const localeToAdopt)
00047 {
00048     /***
00049      * Release the current setting's memory, if any
00050      ***/
00051     if (fLocale)
00052     {
00053         XMLPlatformUtils::fgMemoryManager->deallocate(fLocale);//delete [] fLocale;
00054         fLocale = 0;
00055     }
00056 
00057     /***
00058      *  
00059      *  REVISIT: later we may do locale format checking
00060      * 
00061      *           refer to phttp://oss.software.ibm.com/icu/userguide/locale.html
00062      *           for details.
00063      */
00064     if (localeToAdopt && (strlen(localeToAdopt) == 2 || (strlen(localeToAdopt) > 3 && localeToAdopt[2]=='_')))
00065     {
00066         fLocale   = XMLString::replicate(localeToAdopt, XMLPlatformUtils::fgMemoryManager);                   
00067     }
00068 
00069 }
00070 
00071 const char* XMLMsgLoader::getLocale()
00072 {
00073     return fLocale;
00074 }
00075 
00076 /***
00077  *  if nlsHomeToAdopt is 0, that is to release memory for
00078  *  the user defined NLSHome string
00079  *
00080  ***/
00081 void  XMLMsgLoader::setNLSHome(const char* const nlsHomeToAdopt)
00082 {
00083     /***
00084      * Release the current setting's memory, if any
00085      ***/
00086     if (fPath)
00087     {
00088         XMLPlatformUtils::fgMemoryManager->deallocate(fPath);//delete [] fPath;
00089         fPath = 0;
00090     }
00091 
00092     if (nlsHomeToAdopt)
00093     {
00094         fPath = XMLString::replicate(nlsHomeToAdopt, XMLPlatformUtils::fgMemoryManager);
00095     }
00096 
00097 }
00098 
00099 const char* XMLMsgLoader::getNLSHome()
00100 {
00101     return fPath;
00102 }
00103 
00104 XERCES_CPP_NAMESPACE_END