[188] | 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: Iconv390TransService.hpp,v $
|
---|
| 59 | * Revision 1.7 2003/12/24 15:24:15 cargilld
|
---|
| 60 | * More updates to memory management so that the static memory manager.
|
---|
| 61 | *
|
---|
| 62 | * Revision 1.6 2003/05/15 18:47:03 knoaman
|
---|
| 63 | * Partial implementation of the configurable memory manager.
|
---|
| 64 | *
|
---|
| 65 | * Revision 1.5 2003/03/07 18:15:57 tng
|
---|
| 66 | * Return a reference instead of void for operator=
|
---|
| 67 | *
|
---|
| 68 | * Revision 1.4 2003/01/06 21:46:08 tng
|
---|
| 69 | * Since 390 uses ICU or Uniconv390 TransService, change Iconv390 to use intrinsic transcoders only so as to bypass Bug 2393.
|
---|
| 70 | *
|
---|
| 71 | * Revision 1.3 2002/11/04 15:14:33 tng
|
---|
| 72 | * C++ Namespace Support.
|
---|
| 73 | *
|
---|
| 74 | * Revision 1.2 2002/04/09 15:44:00 knoaman
|
---|
| 75 | * Add lower case string support.
|
---|
| 76 | *
|
---|
| 77 | * Revision 1.1.1.1 2002/02/01 22:22:36 peiyongz
|
---|
| 78 | * sane_include
|
---|
| 79 | *
|
---|
| 80 | * Revision 1.3 2000/03/02 19:55:36 roddey
|
---|
| 81 | * This checkin includes many changes done while waiting for the
|
---|
| 82 | * 1.1.0 code to be finished. I can't list them all here, but a list is
|
---|
| 83 | * available elsewhere.
|
---|
| 84 | *
|
---|
| 85 | * Revision 1.2 2000/02/14 17:59:49 abagchi
|
---|
| 86 | * Reused iconv descriptors
|
---|
| 87 | *
|
---|
| 88 | * Revision 1.1 2000/02/08 02:14:11 abagchi
|
---|
| 89 | * Initial checkin
|
---|
| 90 | *
|
---|
| 91 | *
|
---|
| 92 | */
|
---|
| 93 |
|
---|
| 94 | #ifndef ICONV390TRANSSERVICE_HPP
|
---|
| 95 | #define ICONV390TRANSSERVICE_HPP
|
---|
| 96 |
|
---|
| 97 | #include <xercesc/util/TransService.hpp>
|
---|
| 98 | #include <xercesc/util/Mutexes.hpp>
|
---|
| 99 | #include <iconv.h>
|
---|
| 100 |
|
---|
| 101 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
| 102 |
|
---|
| 103 | /* Max encoding name in characters. */
|
---|
| 104 | #define UCNV_MAX_CONVERTER_NAME_LENGTH 60
|
---|
| 105 | typedef struct iconvconverter {
|
---|
| 106 | struct iconvconverter *nextconverter;
|
---|
| 107 | char name [UCNV_MAX_CONVERTER_NAME_LENGTH];
|
---|
| 108 | XMLMutex fMutex;
|
---|
| 109 | iconv_t fIconv390Descriptor;
|
---|
| 110 | int usecount;
|
---|
| 111 | } iconvconverter_t;
|
---|
| 112 |
|
---|
| 113 | class XMLUTIL_EXPORT Iconv390TransService : public XMLTransService
|
---|
| 114 | {
|
---|
| 115 | public :
|
---|
| 116 | // -----------------------------------------------------------------------
|
---|
| 117 | // Constructors and Destructor
|
---|
| 118 | // -----------------------------------------------------------------------
|
---|
| 119 | Iconv390TransService();
|
---|
| 120 | ~Iconv390TransService();
|
---|
| 121 |
|
---|
| 122 |
|
---|
| 123 | // -----------------------------------------------------------------------
|
---|
| 124 | // Implementation of the virtual transcoding service API
|
---|
| 125 | // -----------------------------------------------------------------------
|
---|
| 126 | virtual int compareIString
|
---|
| 127 | (
|
---|
| 128 | const XMLCh* const comp1
|
---|
| 129 | , const XMLCh* const comp2
|
---|
| 130 | );
|
---|
| 131 |
|
---|
| 132 | virtual int compareNIString
|
---|
| 133 | (
|
---|
| 134 | const XMLCh* const comp1
|
---|
| 135 | , const XMLCh* const comp2
|
---|
| 136 | , const unsigned int maxChars
|
---|
| 137 | );
|
---|
| 138 |
|
---|
| 139 | virtual const XMLCh* getId() const;
|
---|
| 140 |
|
---|
| 141 | virtual bool isSpace(const XMLCh toCheck) const;
|
---|
| 142 |
|
---|
| 143 | virtual XMLLCPTranscoder* makeNewLCPTranscoder();
|
---|
| 144 |
|
---|
| 145 | virtual bool supportsSrcOfs() const;
|
---|
| 146 |
|
---|
| 147 | virtual void upperCase(XMLCh* const toUpperCase) const;
|
---|
| 148 | virtual void lowerCase(XMLCh* const toLowerCase) const;
|
---|
| 149 |
|
---|
| 150 | protected :
|
---|
| 151 | // -----------------------------------------------------------------------
|
---|
| 152 | // Protected virtual methods
|
---|
| 153 | // -----------------------------------------------------------------------
|
---|
| 154 | virtual XMLTranscoder* makeNewXMLTranscoder
|
---|
| 155 | (
|
---|
| 156 | const XMLCh* const encodingName
|
---|
| 157 | , XMLTransService::Codes& resValue
|
---|
| 158 | , const unsigned int blockSize
|
---|
| 159 | , MemoryManager* const manager
|
---|
| 160 | );
|
---|
| 161 |
|
---|
| 162 |
|
---|
| 163 | private :
|
---|
| 164 | // -----------------------------------------------------------------------
|
---|
| 165 | // Unimplemented constructors and operators
|
---|
| 166 | // -----------------------------------------------------------------------
|
---|
| 167 | Iconv390TransService(const Iconv390TransService&);
|
---|
| 168 | Iconv390TransService& operator=(const Iconv390TransService&);
|
---|
| 169 | };
|
---|
| 170 |
|
---|
| 171 | class XMLUTIL_EXPORT Iconv390LCPTranscoder : public XMLLCPTranscoder
|
---|
| 172 | {
|
---|
| 173 | public :
|
---|
| 174 | // -----------------------------------------------------------------------
|
---|
| 175 | // Constructors and Destructor
|
---|
| 176 | // -----------------------------------------------------------------------
|
---|
| 177 | Iconv390LCPTranscoder();
|
---|
| 178 | Iconv390LCPTranscoder(iconvconverter_t* const toAdopt);
|
---|
| 179 | ~Iconv390LCPTranscoder();
|
---|
| 180 |
|
---|
| 181 | // -----------------------------------------------------------------------
|
---|
| 182 | // Implementation of the virtual transcoder interface
|
---|
| 183 | // -----------------------------------------------------------------------
|
---|
| 184 | virtual unsigned int calcRequiredSize(const char* const srcText
|
---|
| 185 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
|
---|
| 186 |
|
---|
| 187 | virtual unsigned int calcRequiredSize(const XMLCh* const srcText
|
---|
| 188 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
|
---|
| 189 |
|
---|
| 190 | virtual char* transcode(const XMLCh* const toTranscode);
|
---|
| 191 | virtual char* transcode(const XMLCh* const toTranscode,
|
---|
| 192 | MemoryManager* const manager);
|
---|
| 193 |
|
---|
| 194 | virtual bool transcode
|
---|
| 195 | (
|
---|
| 196 | const XMLCh* const toTranscode
|
---|
| 197 | , char* const toFill
|
---|
| 198 | , const unsigned int maxBytes
|
---|
| 199 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
|
---|
| 200 | );
|
---|
| 201 |
|
---|
| 202 | virtual XMLCh* transcode(const char* const toTranscode);
|
---|
| 203 | virtual XMLCh* transcode(const char* const toTranscode,
|
---|
| 204 | MemoryManager* const manager);
|
---|
| 205 |
|
---|
| 206 | virtual bool transcode
|
---|
| 207 | (
|
---|
| 208 | const char* const toTranscode
|
---|
| 209 | , XMLCh* const toFill
|
---|
| 210 | , const unsigned int maxChars
|
---|
| 211 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
|
---|
| 212 | );
|
---|
| 213 |
|
---|
| 214 |
|
---|
| 215 | private :
|
---|
| 216 | // -----------------------------------------------------------------------
|
---|
| 217 | // Unimplemented constructors and operators
|
---|
| 218 | // -----------------------------------------------------------------------
|
---|
| 219 | Iconv390LCPTranscoder(const Iconv390LCPTranscoder&);
|
---|
| 220 | Iconv390LCPTranscoder& operator=(const Iconv390LCPTranscoder&);
|
---|
| 221 | iconvconverter_t *converter;
|
---|
| 222 | };
|
---|
| 223 |
|
---|
| 224 | XERCES_CPP_NAMESPACE_END
|
---|
| 225 |
|
---|
| 226 | #endif
|
---|