00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154 #ifndef TRANSSERVICE_HPP
00155 #define TRANSSERVICE_HPP
00156
00157 #include <xercesc/util/XMemory.hpp>
00158 #include <xercesc/util/PlatformUtils.hpp>
00159 #include <xercesc/framework/XMLRecognizer.hpp>
00160 #include <xercesc/util/RefHashTableOf.hpp>
00161 #include <xercesc/util/RefVectorOf.hpp>
00162
00163 XERCES_CPP_NAMESPACE_BEGIN
00164
00165
00166
00167 class XMLLCPTranscoder;
00168 class XMLTranscoder;
00169 class ENameMap;
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183 class XMLTransService : public XMemory
00184 {
00185 public :
00186
00187
00188
00189 enum Codes
00190 {
00191 Ok
00192 , UnsupportedEncoding
00193 , InternalFailure
00194 , SupportFilesNotFound
00195 };
00196
00197 struct TransRec
00198 {
00199 XMLCh intCh;
00200 XMLByte extCh;
00201 };
00202
00203
00204
00205
00206
00207 virtual ~XMLTransService();
00208
00209
00210
00211
00212
00213 XMLTranscoder* makeNewTranscoderFor
00214 (
00215 const XMLCh* const encodingName
00216 , XMLTransService::Codes& resValue
00217 , const unsigned int blockSize
00218 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
00219 );
00220
00221 XMLTranscoder* makeNewTranscoderFor
00222 (
00223 const char* const encodingName
00224 , XMLTransService::Codes& resValue
00225 , const unsigned int blockSize
00226 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
00227 );
00228
00229 XMLTranscoder* makeNewTranscoderFor
00230 (
00231 XMLRecognizer::Encodings encodingEnum
00232 , XMLTransService::Codes& resValue
00233 , const unsigned int blockSize
00234 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
00235 );
00236
00237
00238
00239
00240
00241 virtual int compareIString
00242 (
00243 const XMLCh* const comp1
00244 , const XMLCh* const comp2
00245 ) = 0;
00246
00247 virtual int compareNIString
00248 (
00249 const XMLCh* const comp1
00250 , const XMLCh* const comp2
00251 , const unsigned int maxChars
00252 ) = 0;
00253
00254 virtual const XMLCh* getId() const = 0;
00255
00256 virtual bool isSpace(const XMLCh toCheck) const = 0;
00257
00258 virtual XMLLCPTranscoder* makeNewLCPTranscoder() = 0;
00259
00260 virtual bool supportsSrcOfs() const = 0;
00261
00262 virtual void upperCase(XMLCh* const toUpperCase) const = 0;
00263 virtual void lowerCase(XMLCh* const toLowerCase) const = 0;
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274 static void addEncoding(const XMLCh* const encoding, ENameMap* const ownMapping);
00275
00276
00277 protected :
00278
00279
00280
00281 XMLTransService();
00282
00283
00284
00285
00286
00287 virtual XMLTranscoder* makeNewXMLTranscoder
00288 (
00289 const XMLCh* const encodingName
00290 , XMLTransService::Codes& resValue
00291 , const unsigned int blockSize
00292 , MemoryManager* const manager
00293 ) = 0;
00294
00295
00296
00297
00298 friend class XMLPlatformUtils;
00299 virtual void initTransService();
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312 static RefHashTableOf<ENameMap>* gMappings;
00313 static RefVectorOf<ENameMap>* gMappingsRecognizer;
00314
00315 private :
00316
00317
00318
00319 XMLTransService(const XMLTransService&);
00320 XMLTransService& operator=(const XMLTransService&);
00321
00322
00323
00324
00325
00326 void strictIANAEncoding(const bool newState);
00327 bool isStrictIANAEncoding();
00328 static void reinitMappings();
00329 static void reinitMappingsRecognizer();
00330
00331 };
00332
00333
00334
00351 class XMLTranscoder : public XMemory
00352 {
00353 public :
00354
00362 enum UnRepOpts
00363 {
00364 UnRep_Throw
00365 , UnRep_RepChar
00366 };
00367
00368
00371
00376 virtual ~XMLTranscoder();
00378
00379
00380
00383
00403 virtual unsigned int transcodeFrom
00404 (
00405 const XMLByte* const srcData
00406 , const unsigned int srcCount
00407 , XMLCh* const toFill
00408 , const unsigned int maxChars
00409 , unsigned int& bytesEaten
00410 , unsigned char* const charSizes
00411 ) = 0;
00412
00426 virtual unsigned int transcodeTo
00427 (
00428 const XMLCh* const srcData
00429 , const unsigned int srcCount
00430 , XMLByte* const toFill
00431 , const unsigned int maxBytes
00432 , unsigned int& charsEaten
00433 , const UnRepOpts options
00434 ) = 0;
00435
00441 virtual bool canTranscodeTo
00442 (
00443 const unsigned int toCheck
00444 ) const = 0;
00445
00447
00450
00455 unsigned int getBlockSize() const;
00456
00462 const XMLCh* getEncodingName() const;
00464
00467
00475 MemoryManager* getMemoryManager() const;
00476
00478
00479 protected :
00480
00481
00482
00483 XMLTranscoder
00484 (
00485 const XMLCh* const encodingName
00486 , const unsigned int blockSize
00487 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
00488 );
00489
00490
00491
00492
00493
00494
00495
00496
00497 void checkBlockSize(const unsigned int toCheck);
00498
00499
00500 private :
00501
00502
00503
00504 XMLTranscoder(const XMLTranscoder&);
00505 XMLTranscoder& operator=(const XMLTranscoder&);
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517 unsigned int fBlockSize;
00518 XMLCh* fEncodingName;
00519 MemoryManager* fMemoryManager;
00520 };
00521
00522
00523
00524
00525
00526
00527
00528
00529 class XMLLCPTranscoder : public XMemory
00530 {
00531 public :
00532
00533
00534
00535 virtual ~XMLLCPTranscoder();
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548 virtual unsigned int calcRequiredSize(const char* const srcText
00549 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager) = 0;
00550
00551 virtual unsigned int calcRequiredSize(const XMLCh* const srcText
00552 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager) = 0;
00553
00554 virtual char* transcode(const XMLCh* const toTranscode) = 0;
00555 virtual char* transcode(const XMLCh* const toTranscode,
00556 MemoryManager* const manager) = 0;
00557
00558 virtual XMLCh* transcode(const char* const toTranscode) = 0;
00559 virtual XMLCh* transcode(const char* const toTranscode,
00560 MemoryManager* const manager) = 0;
00561
00562 virtual bool transcode
00563 (
00564 const char* const toTranscode
00565 , XMLCh* const toFill
00566 , const unsigned int maxChars
00567 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
00568 ) = 0;
00569
00570 virtual bool transcode
00571 (
00572 const XMLCh* const toTranscode
00573 , char* const toFill
00574 , const unsigned int maxBytes
00575 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
00576 ) = 0;
00577
00578
00579 protected :
00580
00581
00582
00583 XMLLCPTranscoder();
00584
00585
00586 private :
00587
00588
00589
00590 XMLLCPTranscoder(const XMLLCPTranscoder&);
00591 XMLLCPTranscoder& operator=(const XMLLCPTranscoder&);
00592 };
00593
00594
00595
00596
00597
00598 inline MemoryManager* XMLTranscoder::getMemoryManager() const
00599 {
00600 return fMemoryManager;
00601 }
00602
00603
00604
00605
00606 inline unsigned int XMLTranscoder::getBlockSize() const
00607 {
00608 return fBlockSize;
00609 }
00610
00611 inline const XMLCh* XMLTranscoder::getEncodingName() const
00612 {
00613 return fEncodingName;
00614 }
00615
00616 XERCES_CPP_NAMESPACE_END
00617
00618 #endif