XMLMsgLoader.hpp
上传用户:huihehuasu
上传日期:2007-01-10
资源大小:6948k
文件大小:8k
源码类别:

xml/soap/webservice

开发平台:

C/C++

  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.  * $Log: XMLMsgLoader.hpp,v $
  58.  * Revision 1.5  2000/03/28 19:43:20  roddey
  59.  * Fixes for signed/unsigned warnings. New work for two way transcoding
  60.  * stuff.
  61.  *
  62.  * Revision 1.4  2000/03/02 19:54:49  roddey
  63.  * This checkin includes many changes done while waiting for the
  64.  * 1.1.0 code to be finished. I can't list them all here, but a list is
  65.  * available elsewhere.
  66.  *
  67.  * Revision 1.3  2000/02/24 20:05:26  abagchi
  68.  * Swat for removing Log from API docs
  69.  *
  70.  * Revision 1.2  2000/02/06 07:48:05  rahulj
  71.  * Year 2K copyright swat.
  72.  *
  73.  * Revision 1.1.1.1  1999/11/09 01:05:47  twl
  74.  * Initial checkin
  75.  *
  76.  * Revision 1.2  1999/11/08 20:45:20  rahul
  77.  * Swat for adding in Product name and CVS comment log variable.
  78.  *
  79.  */
  80. #if !defined(XMLMSGLOADER_HPP)
  81. #define XMLMSGLOADER_HPP
  82. #include <util/XercesDefs.hpp>
  83. //
  84. //  This header defines an abstract message loading API. This is the API via
  85. //  which the parser system loads translatable text, and there can be multiple
  86. //  actual implementations of this mechanism. The API is very simple because
  87. //  there can be many kinds of underlying systems on which implementations are
  88. //  based and we don't want to get into portability trouble by being overly
  89. //  smart.
  90. //
  91. //  Each instance of the message loader loads a file of messages, which are
  92. //  accessed by key and which are associated with a particular language. The
  93. //  actual source information may be in many forms, but by the time it is
  94. //  extracted for use it will be in Unicode format. The language is always
  95. //  the default language for the local machine.
  96. //
  97. //  Msg loader derivatives are not required to be thread safe. The parser will
  98. //  never use a single instance in more than one thread.
  99. //
  100. class XMLUTIL_EXPORT XMLMsgLoader
  101. {
  102. public :
  103.     // -----------------------------------------------------------------------
  104.     //  Class specific types
  105.     //
  106.     //  XMLMsgId
  107.     //      A simple typedef to give us flexibility about the representation
  108.     //      of a message id.
  109.     // -----------------------------------------------------------------------
  110.     typedef unsigned int    XMLMsgId;
  111.     // -----------------------------------------------------------------------
  112.     //  Public Constructors and Destructor
  113.     // -----------------------------------------------------------------------
  114.     virtual ~XMLMsgLoader();
  115.     // -----------------------------------------------------------------------
  116.     //  The virtual message loader API
  117.     // -----------------------------------------------------------------------
  118.     virtual bool loadMsg
  119.     (
  120.         const   XMLMsgId        msgToLoad
  121.         ,       XMLCh* const    toFill
  122.         , const unsigned int    maxChars
  123.     ) = 0;
  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.     ) = 0;
  134.     virtual bool loadMsg
  135.     (
  136.         const   XMLMsgId        msgToLoad
  137.         ,       XMLCh* const    toFill
  138.         , const unsigned int    maxChars
  139.         , const char* const     repText1
  140.         , const char* const     repText2 = 0
  141.         , const char* const     repText3 = 0
  142.         , const char* const     repText4 = 0
  143.     ) = 0;
  144.     // -----------------------------------------------------------------------
  145.     //  Getter methods
  146.     // -----------------------------------------------------------------------
  147.     const XMLCh* getLanguageName() const;
  148. protected :
  149.     // -----------------------------------------------------------------------
  150.     //  Hidden Constructors
  151.     // -----------------------------------------------------------------------
  152.     XMLMsgLoader();
  153.     // -----------------------------------------------------------------------
  154.     //  Protected helper methods
  155.     // -----------------------------------------------------------------------
  156.     void setLanguageName(XMLCh* const nameToAdopt);
  157. private :
  158.     // -----------------------------------------------------------------------
  159.     //  Unimplemented constructors and operators
  160.     // -----------------------------------------------------------------------
  161.     XMLMsgLoader(const XMLMsgLoader&);
  162.     void operator=(const XMLMsgLoader&);
  163.     // -----------------------------------------------------------------------
  164.     //  Private data members
  165.     //
  166.     //  fLanguage
  167.     //      This is the language that is represented by this instance of the
  168.     //      loader. The derived class must pass this through for storage and
  169.     //      we adopt it and delete it when we go.
  170.     // -----------------------------------------------------------------------
  171.     XMLCh*  fLanguage;
  172. };
  173. // ---------------------------------------------------------------------------
  174. //  XMLMsgLoader: Public Constructors and Destructor
  175. // ---------------------------------------------------------------------------
  176. inline XMLMsgLoader::~XMLMsgLoader()
  177. {
  178.     delete [] fLanguage;
  179. }
  180. // ---------------------------------------------------------------------------
  181. //  XMLMsgLoader: Hidden Constructors
  182. // ---------------------------------------------------------------------------
  183. inline XMLMsgLoader::XMLMsgLoader() :
  184.     fLanguage(0)
  185. {
  186. }
  187. // ---------------------------------------------------------------------------
  188. //  XMLMsgLoader: Getter methods
  189. // ---------------------------------------------------------------------------
  190. inline const XMLCh* XMLMsgLoader::getLanguageName() const
  191. {
  192.     return fLanguage;
  193. }
  194. // ---------------------------------------------------------------------------
  195. //  XMLMsgLoader: Protected helper methods
  196. // ---------------------------------------------------------------------------
  197. inline void XMLMsgLoader::setLanguageName(XMLCh* const nameToAdopt)
  198. {
  199.     delete [] fLanguage;
  200.     fLanguage = nameToAdopt;
  201. }
  202. #endif