1 | /*
|
---|
2 | * Copyright 1999-2000,2004 The Apache Software Foundation.
|
---|
3 | *
|
---|
4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
---|
5 | * you may not use this file except in compliance with the License.
|
---|
6 | * You may obtain a copy of the License at
|
---|
7 | *
|
---|
8 | * http://www.apache.org/licenses/LICENSE-2.0
|
---|
9 | *
|
---|
10 | * Unless required by applicable law or agreed to in writing, software
|
---|
11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
---|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
13 | * See the License for the specific language governing permissions and
|
---|
14 | * limitations under the License.
|
---|
15 | */
|
---|
16 |
|
---|
17 | /*
|
---|
18 | * $Log: XMLMsgLoader.hpp,v $
|
---|
19 | * Revision 1.9 2004/09/08 13:56:24 peiyongz
|
---|
20 | * Apache License Version 2.0
|
---|
21 | *
|
---|
22 | * Revision 1.8 2003/12/24 15:24:13 cargilld
|
---|
23 | * More updates to memory management so that the static memory manager.
|
---|
24 | *
|
---|
25 | * Revision 1.7 2003/12/17 00:18:35 cargilld
|
---|
26 | * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data.
|
---|
27 | *
|
---|
28 | * Revision 1.6 2003/05/15 19:07:46 knoaman
|
---|
29 | * Partial implementation of the configurable memory manager.
|
---|
30 | *
|
---|
31 | * Revision 1.5 2003/03/07 18:11:55 tng
|
---|
32 | * Return a reference instead of void for operator=
|
---|
33 | *
|
---|
34 | * Revision 1.4 2003/02/17 19:54:47 peiyongz
|
---|
35 | * Allow set user specified error message file location in PlatformUtils::Initialize().
|
---|
36 | *
|
---|
37 | * Revision 1.3 2002/11/04 22:24:21 peiyongz
|
---|
38 | * Locale setting for message loader
|
---|
39 | *
|
---|
40 | * Revision 1.2 2002/11/04 15:22:05 tng
|
---|
41 | * C++ Namespace Support.
|
---|
42 | *
|
---|
43 | * Revision 1.1.1.1 2002/02/01 22:22:15 peiyongz
|
---|
44 | * sane_include
|
---|
45 | *
|
---|
46 | * Revision 1.5 2000/03/28 19:43:20 roddey
|
---|
47 | * Fixes for signed/unsigned warnings. New work for two way transcoding
|
---|
48 | * stuff.
|
---|
49 | *
|
---|
50 | * Revision 1.4 2000/03/02 19:54:49 roddey
|
---|
51 | * This checkin includes many changes done while waiting for the
|
---|
52 | * 1.1.0 code to be finished. I can't list them all here, but a list is
|
---|
53 | * available elsewhere.
|
---|
54 | *
|
---|
55 | * Revision 1.3 2000/02/24 20:05:26 abagchi
|
---|
56 | * Swat for removing Log from API docs
|
---|
57 | *
|
---|
58 | * Revision 1.2 2000/02/06 07:48:05 rahulj
|
---|
59 | * Year 2K copyright swat.
|
---|
60 | *
|
---|
61 | * Revision 1.1.1.1 1999/11/09 01:05:47 twl
|
---|
62 | * Initial checkin
|
---|
63 | *
|
---|
64 | * Revision 1.2 1999/11/08 20:45:20 rahul
|
---|
65 | * Swat for adding in Product name and CVS comment log variable.
|
---|
66 | *
|
---|
67 | */
|
---|
68 |
|
---|
69 |
|
---|
70 | #if !defined(XMLMSGLOADER_HPP)
|
---|
71 | #define XMLMSGLOADER_HPP
|
---|
72 |
|
---|
73 | #include <xercesc/util/XMemory.hpp>
|
---|
74 | #include <xercesc/util/PlatformUtils.hpp>
|
---|
75 |
|
---|
76 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
77 |
|
---|
78 | //
|
---|
79 | // This header defines an abstract message loading API. This is the API via
|
---|
80 | // which the parser system loads translatable text, and there can be multiple
|
---|
81 | // actual implementations of this mechanism. The API is very simple because
|
---|
82 | // there can be many kinds of underlying systems on which implementations are
|
---|
83 | // based and we don't want to get into portability trouble by being overly
|
---|
84 | // smart.
|
---|
85 | //
|
---|
86 | // Each instance of the message loader loads a file of messages, which are
|
---|
87 | // accessed by key and which are associated with a particular language. The
|
---|
88 | // actual source information may be in many forms, but by the time it is
|
---|
89 | // extracted for use it will be in Unicode format. The language is always
|
---|
90 | // the default language for the local machine.
|
---|
91 | //
|
---|
92 | // Msg loader derivatives are not required to be thread safe. The parser will
|
---|
93 | // never use a single instance in more than one thread.
|
---|
94 | //
|
---|
95 | class XMLUTIL_EXPORT XMLMsgLoader : public XMemory
|
---|
96 | {
|
---|
97 | public :
|
---|
98 | // -----------------------------------------------------------------------
|
---|
99 | // Class specific types
|
---|
100 | //
|
---|
101 | // XMLMsgId
|
---|
102 | // A simple typedef to give us flexibility about the representation
|
---|
103 | // of a message id.
|
---|
104 | // -----------------------------------------------------------------------
|
---|
105 | typedef unsigned int XMLMsgId;
|
---|
106 |
|
---|
107 |
|
---|
108 | // -----------------------------------------------------------------------
|
---|
109 | // Public Constructors and Destructor
|
---|
110 | // -----------------------------------------------------------------------
|
---|
111 | virtual ~XMLMsgLoader();
|
---|
112 |
|
---|
113 |
|
---|
114 | // -----------------------------------------------------------------------
|
---|
115 | // The virtual message loader API
|
---|
116 | // -----------------------------------------------------------------------
|
---|
117 | virtual bool loadMsg
|
---|
118 | (
|
---|
119 | const XMLMsgId msgToLoad
|
---|
120 | , XMLCh* const toFill
|
---|
121 | , const unsigned int maxChars
|
---|
122 | ) = 0;
|
---|
123 |
|
---|
124 | virtual bool loadMsg
|
---|
125 | (
|
---|
126 | const XMLMsgId msgToLoad
|
---|
127 | , XMLCh* const toFill
|
---|
128 | , const unsigned int maxChars
|
---|
129 | , const XMLCh* const repText1
|
---|
130 | , const XMLCh* const repText2 = 0
|
---|
131 | , const XMLCh* const repText3 = 0
|
---|
132 | , const XMLCh* const repText4 = 0
|
---|
133 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
|
---|
134 | ) = 0;
|
---|
135 |
|
---|
136 | virtual bool loadMsg
|
---|
137 | (
|
---|
138 | const XMLMsgId msgToLoad
|
---|
139 | , XMLCh* const toFill
|
---|
140 | , const unsigned int maxChars
|
---|
141 | , const char* const repText1
|
---|
142 | , const char* const repText2 = 0
|
---|
143 | , const char* const repText3 = 0
|
---|
144 | , const char* const repText4 = 0
|
---|
145 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
|
---|
146 | ) = 0;
|
---|
147 |
|
---|
148 | /** @name Locale Handling */
|
---|
149 | //@{
|
---|
150 | /**
|
---|
151 | * This function enables set the locale information which
|
---|
152 | * all concrete message loaders shall refer to during instantiation.
|
---|
153 | *
|
---|
154 | * Note: for detailed discussion, refer to PlatformUtils::initalize()
|
---|
155 | */
|
---|
156 | static void setLocale(const char* const localeToAdopt);
|
---|
157 |
|
---|
158 | /**
|
---|
159 | * For the derived to retrieve locale info during construction
|
---|
160 | */
|
---|
161 | static const char* getLocale();
|
---|
162 |
|
---|
163 | //@}
|
---|
164 |
|
---|
165 | /** @name NLSHome Handling */
|
---|
166 | //@{
|
---|
167 | /**
|
---|
168 | * This function enables set the NLSHome information which
|
---|
169 | * all concrete message loaders shall refer to during instantiation.
|
---|
170 | *
|
---|
171 | * Note: for detailed discussion, refer to PlatformUtils::initalize()
|
---|
172 | */
|
---|
173 | static void setNLSHome(const char* const nlsHomeToAdopt);
|
---|
174 |
|
---|
175 | /**
|
---|
176 | * For the derived to retrieve NLSHome info during construction
|
---|
177 | */
|
---|
178 | static const char* getNLSHome();
|
---|
179 |
|
---|
180 | //@}
|
---|
181 |
|
---|
182 | // -----------------------------------------------------------------------
|
---|
183 | // Deprecated: Getter methods
|
---|
184 | // -----------------------------------------------------------------------
|
---|
185 | virtual const XMLCh* getLanguageName() const;
|
---|
186 |
|
---|
187 |
|
---|
188 | protected :
|
---|
189 | // -----------------------------------------------------------------------
|
---|
190 | // Hidden Constructors
|
---|
191 | // -----------------------------------------------------------------------
|
---|
192 | XMLMsgLoader();
|
---|
193 |
|
---|
194 | // -----------------------------------------------------------------------
|
---|
195 | // Deprecated: Protected helper methods
|
---|
196 | // -----------------------------------------------------------------------
|
---|
197 | void setLanguageName(XMLCh* const nameToAdopt);
|
---|
198 |
|
---|
199 | private :
|
---|
200 | // -----------------------------------------------------------------------
|
---|
201 | // Unimplemented constructors and operators
|
---|
202 | // -----------------------------------------------------------------------
|
---|
203 | XMLMsgLoader(const XMLMsgLoader&);
|
---|
204 | XMLMsgLoader& operator=(const XMLMsgLoader&);
|
---|
205 |
|
---|
206 |
|
---|
207 | // -----------------------------------------------------------------------
|
---|
208 | // Private data members
|
---|
209 | //
|
---|
210 | // fLocale
|
---|
211 | // Locale info set through PlatformUtils::init().
|
---|
212 | // The derived class may refer to this for locale information.
|
---|
213 | //
|
---|
214 | // fPath
|
---|
215 | // NLSHome info set through PlatformUtils::init().
|
---|
216 | // The derived class may refer to this for NLSHome information.
|
---|
217 | //
|
---|
218 | // -----------------------------------------------------------------------
|
---|
219 | static char* fLocale;
|
---|
220 | static char* fPath;
|
---|
221 | static XMLCh fLanguage[];
|
---|
222 | };
|
---|
223 |
|
---|
224 |
|
---|
225 | // ---------------------------------------------------------------------------
|
---|
226 | // XMLMsgLoader: Public Constructors and Destructor
|
---|
227 | // ---------------------------------------------------------------------------
|
---|
228 | inline XMLMsgLoader::~XMLMsgLoader()
|
---|
229 | {
|
---|
230 | }
|
---|
231 |
|
---|
232 |
|
---|
233 | // ---------------------------------------------------------------------------
|
---|
234 | // XMLMsgLoader: Hidden Constructors
|
---|
235 | // ---------------------------------------------------------------------------
|
---|
236 | inline XMLMsgLoader::XMLMsgLoader()
|
---|
237 | {
|
---|
238 | }
|
---|
239 |
|
---|
240 | XERCES_CPP_NAMESPACE_END
|
---|
241 |
|
---|
242 | #endif
|
---|