File indexing completed on 2025-01-18 10:15:11
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 #if !defined(XERCESC_INCLUDE_GUARD_ICONVGNUTRANSSERVICE_HPP)
0023 #define XERCESC_INCLUDE_GUARD_ICONVGNUTRANSSERVICE_HPP
0024
0025 #include <xercesc/util/TransService.hpp>
0026 #include <xercesc/util/Mutexes.hpp>
0027
0028 #include <iconv.h>
0029
0030 XERCES_CPP_NAMESPACE_BEGIN
0031
0032
0033
0034
0035
0036 class XMLUTIL_EXPORT IconvGNUWrapper
0037 {
0038 public:
0039
0040
0041
0042 IconvGNUWrapper
0043 (
0044 iconv_t cd_from,
0045 iconv_t cd_to,
0046 size_t uchsize,
0047 unsigned int ubo,
0048 MemoryManager* manager
0049 );
0050 virtual ~IconvGNUWrapper();
0051
0052
0053 void mbcToXMLCh (const char *mbc, XMLCh *toRet) const;
0054
0055
0056 void xmlChToMbc (XMLCh xch, char *mbc) const;
0057
0058
0059
0060 XMLCh* mbsToXML (
0061 const char* mbs_str,
0062 XMLCh* xml_str,
0063 size_t cnt
0064 ) const;
0065
0066
0067
0068
0069 char* xmlToMbs
0070 (
0071 const XMLCh* xml_str,
0072 char* mbs_str,
0073 size_t cnt
0074 ) const;
0075
0076
0077 inline iconv_t cdTo () const { return fCDTo; }
0078 inline iconv_t cdFrom () const { return fCDFrom; }
0079 inline size_t uChSize () const { return fUChSize; }
0080 inline unsigned int UBO () const { return fUBO; }
0081
0082 protected:
0083
0084
0085
0086
0087
0088 XMLCh toUpper (const XMLCh ch);
0089
0090
0091 XMLCh toLower (const XMLCh ch);
0092
0093
0094 size_t iconvFrom
0095 (
0096 const char *fromPtr,
0097 size_t *fromLen,
0098 char **toPtr,
0099 size_t toLen
0100 );
0101
0102
0103 size_t iconvTo
0104 (
0105 const char *fromPtr,
0106 size_t *fromLen,
0107 char **toPtr,
0108 size_t toLen
0109 );
0110
0111 protected:
0112
0113
0114 IconvGNUWrapper(MemoryManager* manager);
0115
0116
0117 inline void setCDTo (iconv_t cd) { fCDTo = cd; }
0118 inline void setCDFrom (iconv_t cd) { fCDFrom = cd; }
0119 inline void setUChSize (size_t sz) { fUChSize = sz; }
0120 inline void setUBO (unsigned int u) { fUBO = u; }
0121
0122 private:
0123
0124
0125
0126 IconvGNUWrapper(const IconvGNUWrapper&);
0127 IconvGNUWrapper& operator=(const IconvGNUWrapper&);
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141 size_t fUChSize;
0142 unsigned int fUBO;
0143 iconv_t fCDTo;
0144 iconv_t fCDFrom;
0145
0146 protected:
0147 XMLMutex fMutex;
0148 };
0149
0150
0151
0152
0153
0154
0155
0156 class XMLUTIL_EXPORT IconvGNUTransService : public XMLTransService, IconvGNUWrapper
0157 {
0158 public :
0159
0160
0161
0162 IconvGNUTransService(MemoryManager* manager);
0163 ~IconvGNUTransService();
0164
0165
0166
0167
0168
0169 virtual int compareIString
0170 (
0171 const XMLCh* const comp1
0172 , const XMLCh* const comp2
0173 );
0174
0175 virtual int compareNIString
0176 (
0177 const XMLCh* const comp1
0178 , const XMLCh* const comp2
0179 , const XMLSize_t maxChars
0180 );
0181
0182 virtual const XMLCh* getId() const;
0183
0184 virtual XMLLCPTranscoder* makeNewLCPTranscoder(MemoryManager* manager);
0185
0186 virtual bool supportsSrcOfs() const;
0187
0188 virtual void upperCase(XMLCh* const toUpperCase);
0189 virtual void lowerCase(XMLCh* const toUpperCase);
0190
0191 protected :
0192
0193
0194
0195 virtual XMLTranscoder* makeNewXMLTranscoder
0196 (
0197 const XMLCh* const encodingName
0198 , XMLTransService::Codes& resValue
0199 , const XMLSize_t blockSize
0200 , MemoryManager* const manager
0201 );
0202
0203
0204 private :
0205
0206
0207
0208 IconvGNUTransService(const IconvGNUTransService&);
0209 IconvGNUTransService& operator=(const IconvGNUTransService&);
0210
0211
0212
0213
0214
0215
0216
0217
0218 const char* fUnicodeCP;
0219
0220 };
0221
0222
0223
0224
0225
0226
0227
0228 class XMLUTIL_EXPORT IconvGNUTranscoder : public XMLTranscoder, IconvGNUWrapper
0229 {
0230 public :
0231
0232
0233
0234 IconvGNUTranscoder(const XMLCh* const encodingName
0235 , const XMLSize_t blockSize
0236 , iconv_t cd_from
0237 , iconv_t cd_to
0238 , size_t uchsize
0239 , unsigned int ubo
0240 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
0241 );
0242 ~IconvGNUTranscoder();
0243
0244
0245
0246
0247
0248 virtual XMLSize_t transcodeFrom
0249 (
0250 const XMLByte* const srcData
0251 , const XMLSize_t srcCount
0252 , XMLCh* const toFill
0253 , const XMLSize_t maxChars
0254 , XMLSize_t& bytesEaten
0255 , unsigned char* const charSizes
0256 );
0257
0258 virtual XMLSize_t transcodeTo
0259 (
0260 const XMLCh* const srcData
0261 , const XMLSize_t srcCount
0262 , XMLByte* const toFill
0263 , const XMLSize_t maxBytes
0264 , XMLSize_t& charsEaten
0265 , const UnRepOpts options
0266 );
0267
0268 virtual bool canTranscodeTo
0269 (
0270 const unsigned int toCheck
0271 );
0272
0273 private :
0274
0275
0276
0277 IconvGNUTranscoder();
0278 IconvGNUTranscoder(const IconvGNUTranscoder&);
0279 IconvGNUTranscoder& operator=(const IconvGNUTranscoder&);
0280 };
0281
0282
0283
0284
0285
0286
0287 class XMLUTIL_EXPORT IconvGNULCPTranscoder : public XMLLCPTranscoder, IconvGNUWrapper
0288 {
0289 public :
0290
0291
0292
0293
0294 IconvGNULCPTranscoder
0295 (
0296 iconv_t from,
0297 iconv_t to,
0298 size_t uchsize,
0299 unsigned int ubo,
0300 MemoryManager* manager
0301 );
0302
0303 protected:
0304 IconvGNULCPTranscoder();
0305
0306 public:
0307
0308 ~IconvGNULCPTranscoder();
0309
0310
0311
0312
0313
0314 virtual char* transcode(const XMLCh* const toTranscode,
0315 MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
0316
0317 virtual XMLCh* transcode(const char* const toTranscode,
0318 MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
0319
0320
0321
0322
0323
0324 virtual XMLSize_t calcRequiredSize(const char* const srcText
0325 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
0326
0327 virtual XMLSize_t calcRequiredSize(const XMLCh* const srcText
0328 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
0329
0330 virtual bool transcode
0331 (
0332 const char* const toTranscode
0333 , XMLCh* const toFill
0334 , const XMLSize_t maxChars
0335 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
0336 );
0337
0338 virtual bool transcode
0339 (
0340 const XMLCh* const toTranscode
0341 , char* const toFill
0342 , const XMLSize_t maxChars
0343 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
0344 );
0345
0346
0347 private :
0348
0349
0350
0351 IconvGNULCPTranscoder(const IconvGNULCPTranscoder&);
0352 IconvGNULCPTranscoder& operator=(const IconvGNULCPTranscoder&);
0353 };
0354
0355 XERCES_CPP_NAMESPACE_END
0356
0357 #endif
0358
0359