[2674] | 1 | /* |
---|
| 2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
---|
| 3 | * contributor license agreements. See the NOTICE file distributed with |
---|
| 4 | * this work for additional information regarding copyright ownership. |
---|
| 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
---|
| 6 | * (the "License"); you may not use this file except in compliance with |
---|
| 7 | * the License. You may obtain a copy of the License at |
---|
| 8 | * |
---|
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
---|
| 10 | * |
---|
| 11 | * Unless required by applicable law or agreed to in writing, software |
---|
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
---|
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
| 14 | * See the License for the specific language governing permissions and |
---|
| 15 | * limitations under the License. |
---|
| 16 | */ |
---|
| 17 | |
---|
| 18 | /* |
---|
| 19 | * $Id: XMLMsgLoader.hpp 568078 2007-08-21 11:43:25Z amassari $ |
---|
| 20 | */ |
---|
| 21 | |
---|
| 22 | |
---|
| 23 | #if !defined(XMLMSGLOADER_HPP) |
---|
| 24 | #define XMLMSGLOADER_HPP |
---|
| 25 | |
---|
| 26 | #include <xercesc/util/XMemory.hpp> |
---|
| 27 | #include <xercesc/util/PlatformUtils.hpp> |
---|
| 28 | |
---|
| 29 | XERCES_CPP_NAMESPACE_BEGIN |
---|
| 30 | |
---|
| 31 | // |
---|
| 32 | // This header defines an abstract message loading API. This is the API via |
---|
| 33 | // which the parser system loads translatable text, and there can be multiple |
---|
| 34 | // actual implementations of this mechanism. The API is very simple because |
---|
| 35 | // there can be many kinds of underlying systems on which implementations are |
---|
| 36 | // based and we don't want to get into portability trouble by being overly |
---|
| 37 | // smart. |
---|
| 38 | // |
---|
| 39 | // Each instance of the message loader loads a file of messages, which are |
---|
| 40 | // accessed by key and which are associated with a particular language. The |
---|
| 41 | // actual source information may be in many forms, but by the time it is |
---|
| 42 | // extracted for use it will be in Unicode format. The language is always |
---|
| 43 | // the default language for the local machine. |
---|
| 44 | // |
---|
| 45 | // Msg loader derivatives are not required to be thread safe. The parser will |
---|
| 46 | // never use a single instance in more than one thread. |
---|
| 47 | // |
---|
| 48 | class XMLUTIL_EXPORT XMLMsgLoader : public XMemory |
---|
| 49 | { |
---|
| 50 | public : |
---|
| 51 | // ----------------------------------------------------------------------- |
---|
| 52 | // Class specific types |
---|
| 53 | // |
---|
| 54 | // XMLMsgId |
---|
| 55 | // A simple typedef to give us flexibility about the representation |
---|
| 56 | // of a message id. |
---|
| 57 | // ----------------------------------------------------------------------- |
---|
| 58 | typedef unsigned int XMLMsgId; |
---|
| 59 | |
---|
| 60 | |
---|
| 61 | // ----------------------------------------------------------------------- |
---|
| 62 | // Public Constructors and Destructor |
---|
| 63 | // ----------------------------------------------------------------------- |
---|
| 64 | virtual ~XMLMsgLoader(); |
---|
| 65 | |
---|
| 66 | |
---|
| 67 | // ----------------------------------------------------------------------- |
---|
| 68 | // The virtual message loader API |
---|
| 69 | // ----------------------------------------------------------------------- |
---|
| 70 | virtual bool loadMsg |
---|
| 71 | ( |
---|
| 72 | const XMLMsgId msgToLoad |
---|
| 73 | , XMLCh* const toFill |
---|
| 74 | , const unsigned int maxChars |
---|
| 75 | ) = 0; |
---|
| 76 | |
---|
| 77 | virtual bool loadMsg |
---|
| 78 | ( |
---|
| 79 | const XMLMsgId msgToLoad |
---|
| 80 | , XMLCh* const toFill |
---|
| 81 | , const unsigned int maxChars |
---|
| 82 | , const XMLCh* const repText1 |
---|
| 83 | , const XMLCh* const repText2 = 0 |
---|
| 84 | , const XMLCh* const repText3 = 0 |
---|
| 85 | , const XMLCh* const repText4 = 0 |
---|
| 86 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager |
---|
| 87 | ) = 0; |
---|
| 88 | |
---|
| 89 | virtual bool loadMsg |
---|
| 90 | ( |
---|
| 91 | const XMLMsgId msgToLoad |
---|
| 92 | , XMLCh* const toFill |
---|
| 93 | , const unsigned int maxChars |
---|
| 94 | , const char* const repText1 |
---|
| 95 | , const char* const repText2 = 0 |
---|
| 96 | , const char* const repText3 = 0 |
---|
| 97 | , const char* const repText4 = 0 |
---|
| 98 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager |
---|
| 99 | ) = 0; |
---|
| 100 | |
---|
| 101 | /** @name Locale Handling */ |
---|
| 102 | //@{ |
---|
| 103 | /** |
---|
| 104 | * This function enables set the locale information which |
---|
| 105 | * all concrete message loaders shall refer to during instantiation. |
---|
| 106 | * |
---|
| 107 | * Note: for detailed discussion, refer to PlatformUtils::initalize() |
---|
| 108 | */ |
---|
| 109 | static void setLocale(const char* const localeToAdopt); |
---|
| 110 | |
---|
| 111 | /** |
---|
| 112 | * For the derived to retrieve locale info during construction |
---|
| 113 | */ |
---|
| 114 | static const char* getLocale(); |
---|
| 115 | |
---|
| 116 | //@} |
---|
| 117 | |
---|
| 118 | /** @name NLSHome Handling */ |
---|
| 119 | //@{ |
---|
| 120 | /** |
---|
| 121 | * This function enables set the NLSHome information which |
---|
| 122 | * all concrete message loaders shall refer to during instantiation. |
---|
| 123 | * |
---|
| 124 | * Note: for detailed discussion, refer to PlatformUtils::initalize() |
---|
| 125 | */ |
---|
| 126 | static void setNLSHome(const char* const nlsHomeToAdopt); |
---|
| 127 | |
---|
| 128 | /** |
---|
| 129 | * For the derived to retrieve NLSHome info during construction |
---|
| 130 | */ |
---|
| 131 | static const char* getNLSHome(); |
---|
| 132 | |
---|
| 133 | //@} |
---|
| 134 | |
---|
| 135 | // ----------------------------------------------------------------------- |
---|
| 136 | // Deprecated: Getter methods |
---|
| 137 | // ----------------------------------------------------------------------- |
---|
| 138 | virtual const XMLCh* getLanguageName() const; |
---|
| 139 | |
---|
| 140 | |
---|
| 141 | protected : |
---|
| 142 | // ----------------------------------------------------------------------- |
---|
| 143 | // Hidden Constructors |
---|
| 144 | // ----------------------------------------------------------------------- |
---|
| 145 | XMLMsgLoader(); |
---|
| 146 | |
---|
| 147 | // ----------------------------------------------------------------------- |
---|
| 148 | // Deprecated: Protected helper methods |
---|
| 149 | // ----------------------------------------------------------------------- |
---|
| 150 | void setLanguageName(XMLCh* const nameToAdopt); |
---|
| 151 | |
---|
| 152 | private : |
---|
| 153 | // ----------------------------------------------------------------------- |
---|
| 154 | // Unimplemented constructors and operators |
---|
| 155 | // ----------------------------------------------------------------------- |
---|
| 156 | XMLMsgLoader(const XMLMsgLoader&); |
---|
| 157 | XMLMsgLoader& operator=(const XMLMsgLoader&); |
---|
| 158 | |
---|
| 159 | |
---|
| 160 | // ----------------------------------------------------------------------- |
---|
| 161 | // Private data members |
---|
| 162 | // |
---|
| 163 | // fLocale |
---|
| 164 | // Locale info set through PlatformUtils::init(). |
---|
| 165 | // The derived class may refer to this for locale information. |
---|
| 166 | // |
---|
| 167 | // fPath |
---|
| 168 | // NLSHome info set through PlatformUtils::init(). |
---|
| 169 | // The derived class may refer to this for NLSHome information. |
---|
| 170 | // |
---|
| 171 | // ----------------------------------------------------------------------- |
---|
| 172 | static char* fLocale; |
---|
| 173 | static char* fPath; |
---|
| 174 | static XMLCh fLanguage[]; |
---|
| 175 | }; |
---|
| 176 | |
---|
| 177 | |
---|
| 178 | // --------------------------------------------------------------------------- |
---|
| 179 | // XMLMsgLoader: Public Constructors and Destructor |
---|
| 180 | // --------------------------------------------------------------------------- |
---|
| 181 | inline XMLMsgLoader::~XMLMsgLoader() |
---|
| 182 | { |
---|
| 183 | } |
---|
| 184 | |
---|
| 185 | |
---|
| 186 | // --------------------------------------------------------------------------- |
---|
| 187 | // XMLMsgLoader: Hidden Constructors |
---|
| 188 | // --------------------------------------------------------------------------- |
---|
| 189 | inline XMLMsgLoader::XMLMsgLoader() |
---|
| 190 | { |
---|
| 191 | } |
---|
| 192 | |
---|
| 193 | XERCES_CPP_NAMESPACE_END |
---|
| 194 | |
---|
| 195 | #endif |
---|