[111] | 1 | /* |
---|
| 2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
---|
| 3 | * contributor license agreements. See the NOTICE file distributed with |
---|
| 4 | * this work for additional information regarding copyright ownership. |
---|
| 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
---|
| 6 | * (the "License"); you may not use this file except in compliance with |
---|
| 7 | * the License. You may obtain a copy of the License at |
---|
| 8 | * |
---|
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
---|
| 10 | * |
---|
| 11 | * Unless required by applicable law or agreed to in writing, software |
---|
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
---|
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
| 14 | * See the License for the specific language governing permissions and |
---|
| 15 | * limitations under the License. |
---|
| 16 | */ |
---|
| 17 | |
---|
| 18 | /* |
---|
| 19 | * $Id: Win32TransService.hpp 568078 2007-08-21 11:43:25Z amassari $ |
---|
| 20 | */ |
---|
| 21 | |
---|
| 22 | #ifndef WIN32TRANSSERVICE_HPP |
---|
| 23 | #define WIN32TRANSSERVICE_HPP |
---|
| 24 | |
---|
| 25 | #include <xercesc/util/TransService.hpp> |
---|
| 26 | #include <xercesc/util/RefHashTableOf.hpp> |
---|
| 27 | #include <windows.h> |
---|
| 28 | |
---|
| 29 | XERCES_CPP_NAMESPACE_BEGIN |
---|
| 30 | |
---|
| 31 | class CPMapEntry; |
---|
| 32 | |
---|
| 33 | |
---|
| 34 | |
---|
| 35 | //--------------------------------------------------------------------------- |
---|
| 36 | // |
---|
| 37 | // class Win32TransService |
---|
| 38 | // |
---|
| 39 | //--------------------------------------------------------------------------- |
---|
| 40 | class XMLUTIL_EXPORT Win32TransService : public XMLTransService |
---|
| 41 | { |
---|
| 42 | public : |
---|
| 43 | // ----------------------------------------------------------------------- |
---|
| 44 | // Constructors and Destructor |
---|
| 45 | // ----------------------------------------------------------------------- |
---|
| 46 | Win32TransService(); |
---|
| 47 | virtual ~Win32TransService(); |
---|
| 48 | |
---|
| 49 | |
---|
| 50 | // ----------------------------------------------------------------------- |
---|
| 51 | // Implementation of the virtual transcoding service API |
---|
| 52 | // ----------------------------------------------------------------------- |
---|
| 53 | virtual int compareIString |
---|
| 54 | ( |
---|
| 55 | const XMLCh* const comp1 |
---|
| 56 | , const XMLCh* const comp2 |
---|
| 57 | ); |
---|
| 58 | |
---|
| 59 | virtual int compareNIString |
---|
| 60 | ( |
---|
| 61 | const XMLCh* const comp1 |
---|
| 62 | , const XMLCh* const comp2 |
---|
| 63 | , const unsigned int maxChars |
---|
| 64 | ); |
---|
| 65 | |
---|
| 66 | virtual const XMLCh* getId() const; |
---|
| 67 | |
---|
| 68 | virtual bool isSpace(const XMLCh toCheck) const; |
---|
| 69 | |
---|
| 70 | virtual XMLLCPTranscoder* makeNewLCPTranscoder(); |
---|
| 71 | |
---|
| 72 | virtual bool supportsSrcOfs() const; |
---|
| 73 | |
---|
| 74 | virtual void upperCase(XMLCh* const toUpperCase) const; |
---|
| 75 | virtual void lowerCase(XMLCh* const toLowerCase) const; |
---|
| 76 | |
---|
| 77 | |
---|
| 78 | protected : |
---|
| 79 | // ----------------------------------------------------------------------- |
---|
| 80 | // Protected virtual methods, implemented in Win32TransService2.cpp |
---|
| 81 | // ----------------------------------------------------------------------- |
---|
| 82 | virtual XMLTranscoder* makeNewXMLTranscoder |
---|
| 83 | ( |
---|
| 84 | const XMLCh* const encodingName |
---|
| 85 | , XMLTransService::Codes& resValue |
---|
| 86 | , const unsigned int blockSize |
---|
| 87 | , MemoryManager* const manager |
---|
| 88 | ); |
---|
| 89 | |
---|
| 90 | |
---|
| 91 | private : |
---|
| 92 | // ----------------------------------------------------------------------- |
---|
| 93 | // Unimplemented constructors and operators |
---|
| 94 | // ----------------------------------------------------------------------- |
---|
| 95 | Win32TransService(const Win32TransService&); |
---|
| 96 | Win32TransService& operator=(const Win32TransService&); |
---|
| 97 | |
---|
| 98 | // This is a hash table of entries which map encoding names to their |
---|
| 99 | // Windows specific code pages. The code page allows us to create |
---|
| 100 | // transcoders for those encodings. The encoding names come from XML |
---|
| 101 | // files. |
---|
| 102 | // |
---|
| 103 | // This map is shared unsynchronized among all threads of the process, |
---|
| 104 | // which is cool since it will be read only once its initialized. |
---|
| 105 | |
---|
| 106 | |
---|
| 107 | |
---|
| 108 | static bool isAlias(const HKEY encodingKey |
---|
| 109 | , char* const aliasBuf = 0 |
---|
| 110 | , const unsigned int nameBufSz = 0); |
---|
| 111 | |
---|
| 112 | |
---|
| 113 | RefHashTableOf<CPMapEntry> *fCPMap; |
---|
| 114 | }; |
---|
| 115 | |
---|
| 116 | |
---|
| 117 | |
---|
| 118 | |
---|
| 119 | |
---|
| 120 | |
---|
| 121 | |
---|
| 122 | //--------------------------------------------------------------------------- |
---|
| 123 | // |
---|
| 124 | // class Win32Transcoder |
---|
| 125 | // |
---|
| 126 | //--------------------------------------------------------------------------- |
---|
| 127 | |
---|
| 128 | class XMLUTIL_EXPORT Win32Transcoder : public XMLTranscoder |
---|
| 129 | { |
---|
| 130 | public : |
---|
| 131 | // ----------------------------------------------------------------------- |
---|
| 132 | // Constructors and Destructor |
---|
| 133 | // ----------------------------------------------------------------------- |
---|
| 134 | Win32Transcoder |
---|
| 135 | ( |
---|
| 136 | const XMLCh* const encodingName |
---|
| 137 | , const unsigned int winCP |
---|
| 138 | , const unsigned int ieCP |
---|
| 139 | , const unsigned int blockSize |
---|
| 140 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); |
---|
| 141 | ~Win32Transcoder(); |
---|
| 142 | |
---|
| 143 | |
---|
| 144 | // ----------------------------------------------------------------------- |
---|
| 145 | // Implementation of the virtual transcoder interface |
---|
| 146 | // ----------------------------------------------------------------------- |
---|
| 147 | virtual unsigned int transcodeFrom |
---|
| 148 | ( |
---|
| 149 | const XMLByte* const srcData |
---|
| 150 | , const unsigned int srcCount |
---|
| 151 | , XMLCh* const toFill |
---|
| 152 | , const unsigned int maxChars |
---|
| 153 | , unsigned int& bytesEaten |
---|
| 154 | , unsigned char* const charSizes |
---|
| 155 | ); |
---|
| 156 | |
---|
| 157 | virtual unsigned int transcodeTo |
---|
| 158 | ( |
---|
| 159 | const XMLCh* const srcData |
---|
| 160 | , const unsigned int srcCount |
---|
| 161 | , XMLByte* const toFill |
---|
| 162 | , const unsigned int maxBytes |
---|
| 163 | , unsigned int& charsEaten |
---|
| 164 | , const UnRepOpts options |
---|
| 165 | ); |
---|
| 166 | |
---|
| 167 | virtual bool canTranscodeTo |
---|
| 168 | ( |
---|
| 169 | const unsigned int toCheck |
---|
| 170 | ) const; |
---|
| 171 | |
---|
| 172 | |
---|
| 173 | private : |
---|
| 174 | // ----------------------------------------------------------------------- |
---|
| 175 | // Unimplemented constructors and operators |
---|
| 176 | // ----------------------------------------------------------------------- |
---|
| 177 | Win32Transcoder(const Win32Transcoder&); |
---|
| 178 | Win32Transcoder& operator=(const Win32Transcoder&); |
---|
| 179 | |
---|
| 180 | |
---|
| 181 | // ----------------------------------------------------------------------- |
---|
| 182 | // Private data members |
---|
| 183 | // |
---|
| 184 | // fIECP |
---|
| 185 | // This is the internet explorer code page for this encoding. |
---|
| 186 | // |
---|
| 187 | // fWinCP |
---|
| 188 | // This is the windows code page for this encoding. |
---|
| 189 | // ----------------------------------------------------------------------- |
---|
| 190 | unsigned int fIECP; |
---|
| 191 | unsigned int fWinCP; |
---|
| 192 | }; |
---|
| 193 | |
---|
| 194 | |
---|
| 195 | |
---|
| 196 | |
---|
| 197 | |
---|
| 198 | //--------------------------------------------------------------------------- |
---|
| 199 | // |
---|
| 200 | // class Win32LCPTranscoder |
---|
| 201 | // |
---|
| 202 | //--------------------------------------------------------------------------- |
---|
| 203 | class XMLUTIL_EXPORT Win32LCPTranscoder : public XMLLCPTranscoder |
---|
| 204 | { |
---|
| 205 | public : |
---|
| 206 | // ----------------------------------------------------------------------- |
---|
| 207 | // Constructors and Destructor |
---|
| 208 | // ----------------------------------------------------------------------- |
---|
| 209 | Win32LCPTranscoder(); |
---|
| 210 | ~Win32LCPTranscoder(); |
---|
| 211 | |
---|
| 212 | |
---|
| 213 | // ----------------------------------------------------------------------- |
---|
| 214 | // Implementation of the virtual transcoder interface |
---|
| 215 | // ----------------------------------------------------------------------- |
---|
| 216 | virtual unsigned int calcRequiredSize(const char* const srcText |
---|
| 217 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); |
---|
| 218 | |
---|
| 219 | virtual unsigned int calcRequiredSize(const XMLCh* const srcText |
---|
| 220 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); |
---|
| 221 | |
---|
| 222 | virtual char* transcode(const XMLCh* const toTranscode); |
---|
| 223 | virtual char* transcode(const XMLCh* const toTranscode, |
---|
| 224 | MemoryManager* const manager); |
---|
| 225 | |
---|
| 226 | virtual XMLCh* transcode(const char* const toTranscode); |
---|
| 227 | virtual XMLCh* transcode(const char* const toTranscode, |
---|
| 228 | MemoryManager* const manager); |
---|
| 229 | |
---|
| 230 | virtual bool transcode |
---|
| 231 | ( |
---|
| 232 | const char* const toTranscode |
---|
| 233 | , XMLCh* const toFill |
---|
| 234 | , const unsigned int maxChars |
---|
| 235 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager |
---|
| 236 | ); |
---|
| 237 | |
---|
| 238 | virtual bool transcode |
---|
| 239 | ( |
---|
| 240 | const XMLCh* const toTranscode |
---|
| 241 | , char* const toFill |
---|
| 242 | , const unsigned int maxChars |
---|
| 243 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager |
---|
| 244 | ); |
---|
| 245 | |
---|
| 246 | |
---|
| 247 | private : |
---|
| 248 | // ----------------------------------------------------------------------- |
---|
| 249 | // Unimplemented constructors and operators |
---|
| 250 | // ----------------------------------------------------------------------- |
---|
| 251 | Win32LCPTranscoder(const Win32LCPTranscoder&); |
---|
| 252 | Win32LCPTranscoder& operator=(const Win32LCPTranscoder&); |
---|
| 253 | }; |
---|
| 254 | |
---|
| 255 | XERCES_CPP_NAMESPACE_END |
---|
| 256 | |
---|
| 257 | #endif |
---|