1 | /*
|
---|
2 | * The Apache Software License, Version 1.1
|
---|
3 | *
|
---|
4 | * Copyright (c) 1999-2000 The Apache Software Foundation. All rights
|
---|
5 | * reserved.
|
---|
6 | *
|
---|
7 | * Redistribution and use in source and binary forms, with or without
|
---|
8 | * modification, are permitted provided that the following conditions
|
---|
9 | * are met:
|
---|
10 | *
|
---|
11 | * 1. Redistributions of source code must retain the above copyright
|
---|
12 | * notice, this list of conditions and the following disclaimer.
|
---|
13 | *
|
---|
14 | * 2. Redistributions in binary form must reproduce the above copyright
|
---|
15 | * notice, this list of conditions and the following disclaimer in
|
---|
16 | * the documentation and/or other materials provided with the
|
---|
17 | * distribution.
|
---|
18 | *
|
---|
19 | * 3. The end-user documentation included with the redistribution,
|
---|
20 | * if any, must include the following acknowledgment:
|
---|
21 | * "This product includes software developed by the
|
---|
22 | * Apache Software Foundation (http://www.apache.org/)."
|
---|
23 | * Alternately, this acknowledgment may appear in the software itself,
|
---|
24 | * if and wherever such third-party acknowledgments normally appear.
|
---|
25 | *
|
---|
26 | * 4. The names "Xerces" and "Apache Software Foundation" must
|
---|
27 | * not be used to endorse or promote products derived from this
|
---|
28 | * software without prior written permission. For written
|
---|
29 | * permission, please contact apache\@apache.org.
|
---|
30 | *
|
---|
31 | * 5. Products derived from this software may not be called "Apache",
|
---|
32 | * nor may "Apache" appear in their name, without prior written
|
---|
33 | * permission of the Apache Software Foundation.
|
---|
34 | *
|
---|
35 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
---|
36 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
37 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
---|
38 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
---|
39 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
---|
40 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
---|
41 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
---|
42 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
---|
43 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
---|
44 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
---|
45 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
---|
46 | * SUCH DAMAGE.
|
---|
47 | * ====================================================================
|
---|
48 | *
|
---|
49 | * This software consists of voluntary contributions made by many
|
---|
50 | * individuals on behalf of the Apache Software Foundation, and was
|
---|
51 | * originally based on software copyright (c) 1999, International
|
---|
52 | * Business Machines, Inc., http://www.ibm.com . For more information
|
---|
53 | * on the Apache Software Foundation, please see
|
---|
54 | * <http://www.apache.org/>.
|
---|
55 | */
|
---|
56 |
|
---|
57 | /*
|
---|
58 | * $Log: XMLMsgLoader.hpp,v $
|
---|
59 | * Revision 1.8 2003/12/24 15:24:13 cargilld
|
---|
60 | * More updates to memory management so that the static memory manager.
|
---|
61 | *
|
---|
62 | * Revision 1.7 2003/12/17 00:18:35 cargilld
|
---|
63 | * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data.
|
---|
64 | *
|
---|
65 | * Revision 1.6 2003/05/15 19:07:46 knoaman
|
---|
66 | * Partial implementation of the configurable memory manager.
|
---|
67 | *
|
---|
68 | * Revision 1.5 2003/03/07 18:11:55 tng
|
---|
69 | * Return a reference instead of void for operator=
|
---|
70 | *
|
---|
71 | * Revision 1.4 2003/02/17 19:54:47 peiyongz
|
---|
72 | * Allow set user specified error message file location in PlatformUtils::Initialize().
|
---|
73 | *
|
---|
74 | * Revision 1.3 2002/11/04 22:24:21 peiyongz
|
---|
75 | * Locale setting for message loader
|
---|
76 | *
|
---|
77 | * Revision 1.2 2002/11/04 15:22:05 tng
|
---|
78 | * C++ Namespace Support.
|
---|
79 | *
|
---|
80 | * Revision 1.1.1.1 2002/02/01 22:22:15 peiyongz
|
---|
81 | * sane_include
|
---|
82 | *
|
---|
83 | * Revision 1.5 2000/03/28 19:43:20 roddey
|
---|
84 | * Fixes for signed/unsigned warnings. New work for two way transcoding
|
---|
85 | * stuff.
|
---|
86 | *
|
---|
87 | * Revision 1.4 2000/03/02 19:54:49 roddey
|
---|
88 | * This checkin includes many changes done while waiting for the
|
---|
89 | * 1.1.0 code to be finished. I can't list them all here, but a list is
|
---|
90 | * available elsewhere.
|
---|
91 | *
|
---|
92 | * Revision 1.3 2000/02/24 20:05:26 abagchi
|
---|
93 | * Swat for removing Log from API docs
|
---|
94 | *
|
---|
95 | * Revision 1.2 2000/02/06 07:48:05 rahulj
|
---|
96 | * Year 2K copyright swat.
|
---|
97 | *
|
---|
98 | * Revision 1.1.1.1 1999/11/09 01:05:47 twl
|
---|
99 | * Initial checkin
|
---|
100 | *
|
---|
101 | * Revision 1.2 1999/11/08 20:45:20 rahul
|
---|
102 | * Swat for adding in Product name and CVS comment log variable.
|
---|
103 | *
|
---|
104 | */
|
---|
105 |
|
---|
106 |
|
---|
107 | #if !defined(XMLMSGLOADER_HPP)
|
---|
108 | #define XMLMSGLOADER_HPP
|
---|
109 |
|
---|
110 | #include <xercesc/util/XMemory.hpp>
|
---|
111 | #include <xercesc/util/PlatformUtils.hpp>
|
---|
112 |
|
---|
113 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
114 |
|
---|
115 | //
|
---|
116 | // This header defines an abstract message loading API. This is the API via
|
---|
117 | // which the parser system loads translatable text, and there can be multiple
|
---|
118 | // actual implementations of this mechanism. The API is very simple because
|
---|
119 | // there can be many kinds of underlying systems on which implementations are
|
---|
120 | // based and we don't want to get into portability trouble by being overly
|
---|
121 | // smart.
|
---|
122 | //
|
---|
123 | // Each instance of the message loader loads a file of messages, which are
|
---|
124 | // accessed by key and which are associated with a particular language. The
|
---|
125 | // actual source information may be in many forms, but by the time it is
|
---|
126 | // extracted for use it will be in Unicode format. The language is always
|
---|
127 | // the default language for the local machine.
|
---|
128 | //
|
---|
129 | // Msg loader derivatives are not required to be thread safe. The parser will
|
---|
130 | // never use a single instance in more than one thread.
|
---|
131 | //
|
---|
132 | class XMLUTIL_EXPORT XMLMsgLoader : public XMemory
|
---|
133 | {
|
---|
134 | public :
|
---|
135 | // -----------------------------------------------------------------------
|
---|
136 | // Class specific types
|
---|
137 | //
|
---|
138 | // XMLMsgId
|
---|
139 | // A simple typedef to give us flexibility about the representation
|
---|
140 | // of a message id.
|
---|
141 | // -----------------------------------------------------------------------
|
---|
142 | typedef unsigned int XMLMsgId;
|
---|
143 |
|
---|
144 |
|
---|
145 | // -----------------------------------------------------------------------
|
---|
146 | // Public Constructors and Destructor
|
---|
147 | // -----------------------------------------------------------------------
|
---|
148 | virtual ~XMLMsgLoader();
|
---|
149 |
|
---|
150 |
|
---|
151 | // -----------------------------------------------------------------------
|
---|
152 | // The virtual message loader API
|
---|
153 | // -----------------------------------------------------------------------
|
---|
154 | virtual bool loadMsg
|
---|
155 | (
|
---|
156 | const XMLMsgId msgToLoad
|
---|
157 | , XMLCh* const toFill
|
---|
158 | , const unsigned int maxChars
|
---|
159 | ) = 0;
|
---|
160 |
|
---|
161 | virtual bool loadMsg
|
---|
162 | (
|
---|
163 | const XMLMsgId msgToLoad
|
---|
164 | , XMLCh* const toFill
|
---|
165 | , const unsigned int maxChars
|
---|
166 | , const XMLCh* const repText1
|
---|
167 | , const XMLCh* const repText2 = 0
|
---|
168 | , const XMLCh* const repText3 = 0
|
---|
169 | , const XMLCh* const repText4 = 0
|
---|
170 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
|
---|
171 | ) = 0;
|
---|
172 |
|
---|
173 | virtual bool loadMsg
|
---|
174 | (
|
---|
175 | const XMLMsgId msgToLoad
|
---|
176 | , XMLCh* const toFill
|
---|
177 | , const unsigned int maxChars
|
---|
178 | , const char* const repText1
|
---|
179 | , const char* const repText2 = 0
|
---|
180 | , const char* const repText3 = 0
|
---|
181 | , const char* const repText4 = 0
|
---|
182 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
|
---|
183 | ) = 0;
|
---|
184 |
|
---|
185 | /** @name Locale Handling */
|
---|
186 | //@{
|
---|
187 | /**
|
---|
188 | * This function enables set the locale information which
|
---|
189 | * all concrete message loaders shall refer to during instantiation.
|
---|
190 | *
|
---|
191 | * Note: for detailed discussion, refer to PlatformUtils::initalize()
|
---|
192 | */
|
---|
193 | static void setLocale(const char* const localeToAdopt);
|
---|
194 |
|
---|
195 | /**
|
---|
196 | * For the derived to retrieve locale info during construction
|
---|
197 | */
|
---|
198 | static const char* getLocale();
|
---|
199 |
|
---|
200 | //@}
|
---|
201 |
|
---|
202 | /** @name NLSHome Handling */
|
---|
203 | //@{
|
---|
204 | /**
|
---|
205 | * This function enables set the NLSHome information which
|
---|
206 | * all concrete message loaders shall refer to during instantiation.
|
---|
207 | *
|
---|
208 | * Note: for detailed discussion, refer to PlatformUtils::initalize()
|
---|
209 | */
|
---|
210 | static void setNLSHome(const char* const nlsHomeToAdopt);
|
---|
211 |
|
---|
212 | /**
|
---|
213 | * For the derived to retrieve NLSHome info during construction
|
---|
214 | */
|
---|
215 | static const char* getNLSHome();
|
---|
216 |
|
---|
217 | //@}
|
---|
218 |
|
---|
219 | // -----------------------------------------------------------------------
|
---|
220 | // Deprecated: Getter methods
|
---|
221 | // -----------------------------------------------------------------------
|
---|
222 | virtual const XMLCh* getLanguageName() const;
|
---|
223 |
|
---|
224 |
|
---|
225 | protected :
|
---|
226 | // -----------------------------------------------------------------------
|
---|
227 | // Hidden Constructors
|
---|
228 | // -----------------------------------------------------------------------
|
---|
229 | XMLMsgLoader();
|
---|
230 |
|
---|
231 | // -----------------------------------------------------------------------
|
---|
232 | // Deprecated: Protected helper methods
|
---|
233 | // -----------------------------------------------------------------------
|
---|
234 | void setLanguageName(XMLCh* const nameToAdopt);
|
---|
235 |
|
---|
236 | private :
|
---|
237 | // -----------------------------------------------------------------------
|
---|
238 | // Unimplemented constructors and operators
|
---|
239 | // -----------------------------------------------------------------------
|
---|
240 | XMLMsgLoader(const XMLMsgLoader&);
|
---|
241 | XMLMsgLoader& operator=(const XMLMsgLoader&);
|
---|
242 |
|
---|
243 |
|
---|
244 | // -----------------------------------------------------------------------
|
---|
245 | // Private data members
|
---|
246 | //
|
---|
247 | // fLocale
|
---|
248 | // Locale info set through PlatformUtils::init().
|
---|
249 | // The derived class may refer to this for locale information.
|
---|
250 | //
|
---|
251 | // fPath
|
---|
252 | // NLSHome info set through PlatformUtils::init().
|
---|
253 | // The derived class may refer to this for NLSHome information.
|
---|
254 | //
|
---|
255 | // -----------------------------------------------------------------------
|
---|
256 | static char* fLocale;
|
---|
257 | static char* fPath;
|
---|
258 | static XMLCh fLanguage[];
|
---|
259 | };
|
---|
260 |
|
---|
261 |
|
---|
262 | // ---------------------------------------------------------------------------
|
---|
263 | // XMLMsgLoader: Public Constructors and Destructor
|
---|
264 | // ---------------------------------------------------------------------------
|
---|
265 | inline XMLMsgLoader::~XMLMsgLoader()
|
---|
266 | {
|
---|
267 | }
|
---|
268 |
|
---|
269 |
|
---|
270 | // ---------------------------------------------------------------------------
|
---|
271 | // XMLMsgLoader: Hidden Constructors
|
---|
272 | // ---------------------------------------------------------------------------
|
---|
273 | inline XMLMsgLoader::XMLMsgLoader()
|
---|
274 | {
|
---|
275 | }
|
---|
276 |
|
---|
277 | XERCES_CPP_NAMESPACE_END
|
---|
278 |
|
---|
279 | #endif
|
---|