Iconv400TransService.hpp
上传用户:zhuqijet
上传日期:2013-06-25
资源大小:10074k
文件大小:10k
源码类别:

词法分析

开发平台:

Visual C++

  1. /*
  2.  * The Apache Software License, Version 1.1
  3.  *
  4.  * Copyright (c) 1999-2002 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.  * @02A           V5R2M0    200419   jrhansen : support lowercase function
  58.  * $Id: Iconv400TransService.hpp,v 1.8 2003/05/17 16:32:17 knoaman Exp $
  59.  */
  60. #ifndef ICONV400TRANSSERVICE_HPP
  61. #define ICONV400TRANSSERVICE_HPP
  62. #include <xercesc/util/Mutexes.hpp>
  63. #include <xercesc/util/TransService.hpp>
  64. #include <qlg.h>
  65. XERCES_CPP_NAMESPACE_BEGIN
  66. struct UConverter;
  67. class XMLUTIL_EXPORT Iconv400TransService : public XMLTransService
  68. {
  69. public :
  70.     // -----------------------------------------------------------------------
  71.     //  Public, static methods
  72.     // -----------------------------------------------------------------------
  73.     // -----------------------------------------------------------------------
  74.     //  Constructors and Destructor
  75.     // -----------------------------------------------------------------------
  76.     Iconv400TransService();
  77.     ~Iconv400TransService();
  78.     // -----------------------------------------------------------------------
  79.     //  Implementation of the virtual transcoding service API
  80.     // -----------------------------------------------------------------------
  81.     virtual int compareIString
  82.     (
  83.         const   XMLCh* const    comp1
  84.         , const XMLCh* const    comp2
  85.     );
  86.     virtual int compareNIString
  87.     (
  88.         const   XMLCh* const    comp1
  89.         , const XMLCh* const    comp2
  90.         , const unsigned int    maxChars
  91.     );
  92.     virtual const XMLCh* getId() const;
  93.     virtual bool isSpace(const XMLCh toCheck) const;
  94.     virtual XMLLCPTranscoder* makeNewLCPTranscoder();
  95.     virtual bool supportsSrcOfs() const;
  96.     virtual void upperCase(XMLCh* const toUpperCase) const;
  97.     virtual void lowerCase(XMLCh* const toLowerCase) const;
  98. protected :
  99.     // -----------------------------------------------------------------------
  100.     //  Protected virtual methods
  101.     // -----------------------------------------------------------------------
  102.     virtual XMLTranscoder* makeNewXMLTranscoder
  103.     (
  104.         const   XMLCh* const            encodingName
  105.         ,       XMLTransService::Codes& resValue
  106.         , const unsigned int            blockSize
  107.         ,       MemoryManager* const    manager
  108.     );
  109. private :
  110.     // -----------------------------------------------------------------------
  111.     //  Unimplemented constructors and operators
  112.     // -----------------------------------------------------------------------
  113.     Iconv400TransService(const Iconv400TransService&);
  114.     Iconv400TransService& operator=(const Iconv400TransService&);
  115.     XMLCh toUnicodeUpper(XMLCh toupper) const;
  116.     XMLCh toUnicodeLower(XMLCh tolower) const;
  117.     Qlg_CCSID_ReqCtlBlk_T convertCtlblkUpper;
  118.     Qlg_CCSID_ReqCtlBlk_T convertCtlblkLower;
  119. };
  120. class XMLUTIL_EXPORT Iconv400Transcoder : public XMLTranscoder
  121. {
  122. public :
  123.     // -----------------------------------------------------------------------
  124.     //  Constructors and Destructor
  125.     // -----------------------------------------------------------------------
  126.     Iconv400Transcoder
  127.     (
  128.         const   XMLCh* const      encodingName
  129.         ,       UConverter* const toAdopt
  130.         , const unsigned int      blockSize
  131.         , MemoryManager* const    manager = XMLPlatformUtils::fgMemoryManager
  132.     );
  133.     ~Iconv400Transcoder();
  134.     // -----------------------------------------------------------------------
  135.     //  Implementation of the virtual transcoder interface
  136.     // -----------------------------------------------------------------------
  137.     virtual unsigned int transcodeFrom
  138.     (
  139.         const   XMLByte* const          srcData
  140.         , const unsigned int            srcCount
  141.         ,       XMLCh* const            toFill
  142.         , const unsigned int            maxChars
  143.         ,       unsigned int&           bytesEaten
  144.         ,       unsigned char* const    charSizes
  145.     );
  146.     virtual unsigned int transcodeTo
  147.     (
  148.         const   XMLCh* const srcData
  149.         , const unsigned int srcCount
  150.         ,       XMLByte* const toFill
  151.         , const unsigned int maxBytes
  152.         ,       unsigned int& charsEaten
  153.         , const UnRepOpts options
  154.     );
  155.     virtual bool canTranscodeTo
  156.     (
  157.         const   unsigned int toCheck
  158.     )   const;
  159. private :
  160.     // -----------------------------------------------------------------------
  161.     //  Unimplemented constructors and operators
  162.     // -----------------------------------------------------------------------
  163.     Iconv400Transcoder();
  164.     Iconv400Transcoder(const Iconv400Transcoder&);
  165.     Iconv400Transcoder& operator=(const Iconv400Transcoder&);
  166.     // -----------------------------------------------------------------------
  167.     //  Private data members
  168.     //
  169.     //  fConverter
  170.     //      This is a pointer to the Iconv400 converter that this transcoder
  171.     //      uses.
  172.     //
  173.     //  fFixed
  174.     //      This is set to true if the encoding is a fixed size one. This
  175.     //      can be used to optimize some operations.
  176.     //
  177.     //  fSrcOffsets
  178.     //      This is an array of longs, which are allocated to the size of
  179.     //      the trancoding block (if any) indicated in the ctor. It is used
  180.     //      to get the character offsets from Iconv400, which are then translated
  181.     //      into an array of char sizes for return.
  182.     // -----------------------------------------------------------------------
  183.     UConverter*     fConverter;
  184.     bool            fFixed;
  185.     long*           fSrcOffsets;
  186. };
  187. class XMLUTIL_EXPORT Iconv400LCPTranscoder : public XMLLCPTranscoder
  188. {
  189. public :
  190.     // -----------------------------------------------------------------------
  191.     //  Constructors and Destructor
  192.     // -----------------------------------------------------------------------
  193.     Iconv400LCPTranscoder(UConverter* const toAdopt);
  194.     ~Iconv400LCPTranscoder();
  195.     // -----------------------------------------------------------------------
  196.     //  Implementation of the virtual transcoder interface
  197.     // -----------------------------------------------------------------------
  198.     virtual unsigned int calcRequiredSize(const char* const srcText);
  199.     virtual unsigned int calcRequiredSize(const XMLCh* const srcText);
  200.     virtual char* transcode(const XMLCh* const toTranscode);
  201.     virtual char* transcode(const XMLCh* const toTranscode,
  202.                             MemoryManager* const manager);
  203.     virtual XMLCh* transcode(const char* const toTranscode);
  204.     virtual XMLCh* transcode(const char* const toTranscode,
  205.                              MemoryManager* const manager);
  206.     virtual bool transcode
  207.     (
  208.         const   char* const     toTranscode
  209.         ,       XMLCh* const    toFill
  210.         , const unsigned int    maxChars
  211.     );
  212.     virtual bool transcode
  213.     (
  214.         const   XMLCh* const    toTranscode
  215.         ,       char* const     toFill
  216.         , const unsigned int    maxChars
  217.     );
  218. private :
  219.     // -----------------------------------------------------------------------
  220.     //  Unimplemented constructors and operators
  221.     // -----------------------------------------------------------------------
  222.     Iconv400LCPTranscoder();
  223.     Iconv400LCPTranscoder(const Iconv400LCPTranscoder&);
  224.     Iconv400LCPTranscoder& operator=(const Iconv400LCPTranscoder&);
  225.     // -----------------------------------------------------------------------
  226.     //  Private data members
  227.     //
  228.     //  fConverter
  229.     //      This is a pointer to the Iconv converter that this transcoder
  230.     //      uses.
  231.     //
  232.     //  fMutex
  233.     //      We have to synchronize threaded calls to the converter.
  234.     // -----------------------------------------------------------------------
  235.     UConverter*     fConverter;
  236.     XMLMutex        fMutex;
  237. };
  238. XERCES_CPP_NAMESPACE_END
  239. #endif