📄 transservice.hpp
字号:
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *//* * $Id: TransService.hpp 568078 2007-08-21 11:43:25Z amassari $ */#ifndef TRANSSERVICE_HPP#define TRANSSERVICE_HPP#include <xercesc/util/XMemory.hpp>#include <xercesc/util/PlatformUtils.hpp>#include <xercesc/framework/XMLRecognizer.hpp>#include <xercesc/util/RefHashTableOf.hpp>#include <xercesc/util/RefVectorOf.hpp>XERCES_CPP_NAMESPACE_BEGIN// Forward references//class XMLPlatformUtils;class XMLLCPTranscoder;class XMLTranscoder;class ENameMap;//// This class is an abstract base class which are used to abstract the// transcoding services that Xerces uses. The parser's actual transcoding// needs are small so it is desirable to allow different implementations// to be provided.//// The transcoding service has to provide a couple of required string// and character operations, but its most important service is the creation// of transcoder objects. There are two types of transcoders, which are// discussed below in the XMLTranscoder class' description.//class XMLUTIL_EXPORT XMLTransService : public XMemory{public : // ----------------------------------------------------------------------- // Class specific types // ----------------------------------------------------------------------- enum Codes { Ok , UnsupportedEncoding , InternalFailure , SupportFilesNotFound }; struct TransRec { XMLCh intCh; XMLByte extCh; }; // ----------------------------------------------------------------------- // Public constructors and destructor // ----------------------------------------------------------------------- virtual ~XMLTransService(); // ----------------------------------------------------------------------- // Non-virtual API // ----------------------------------------------------------------------- XMLTranscoder* makeNewTranscoderFor ( const XMLCh* const encodingName , XMLTransService::Codes& resValue , const unsigned int blockSize , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); XMLTranscoder* makeNewTranscoderFor ( const char* const encodingName , XMLTransService::Codes& resValue , const unsigned int blockSize , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); XMLTranscoder* makeNewTranscoderFor ( XMLRecognizer::Encodings encodingEnum , XMLTransService::Codes& resValue , const unsigned int blockSize , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); // ----------------------------------------------------------------------- // The virtual transcoding service API // ----------------------------------------------------------------------- virtual int compareIString ( const XMLCh* const comp1 , const XMLCh* const comp2 ) = 0; virtual int compareNIString ( const XMLCh* const comp1 , const XMLCh* const comp2 , const unsigned int maxChars ) = 0; virtual const XMLCh* getId() const = 0; virtual bool isSpace(const XMLCh toCheck) const = 0; virtual XMLLCPTranscoder* makeNewLCPTranscoder() = 0; virtual bool supportsSrcOfs() const = 0; virtual void upperCase(XMLCh* const toUpperCase) const = 0; virtual void lowerCase(XMLCh* const toLowerCase) const = 0; // ----------------------------------------------------------------------- // Allow users to add their own encodings to the intrinsinc mapping // table // Usage: // XMLTransService::addEncoding ( // gMyEncodingNameString // , new ENameMapFor<MyTransClassType>(gMyEncodingNameString) // ); // ----------------------------------------------------------------------- static void addEncoding(const XMLCh* const encoding, ENameMap* const ownMapping);protected : // ----------------------------------------------------------------------- // Hidden constructors // ----------------------------------------------------------------------- XMLTransService(); // ----------------------------------------------------------------------- // Protected virtual methods. // -----------------------------------------------------------------------#ifdef OS390 friend class Uniconv390TransService;#endif virtual XMLTranscoder* makeNewXMLTranscoder ( const XMLCh* const encodingName , XMLTransService::Codes& resValue , const unsigned int blockSize , MemoryManager* const manager ) = 0; // ----------------------------------------------------------------------- // Protected init method for platform utils to call // ----------------------------------------------------------------------- friend class XMLPlatformUtils; virtual void initTransService(); // ----------------------------------------------------------------------- // protected static members // gMappings // This is a hash table of ENameMap objects. It is created and filled // in when the platform init calls our initTransService() method. // // gMappingsRecognizer // This is an array of ENameMap objects, predefined for those // already recognized by XMLRecognizer::Encodings. // static RefHashTableOf<ENameMap>* gMappings; static RefVectorOf<ENameMap>* gMappingsRecognizer;private : // ----------------------------------------------------------------------- // Unimplemented constructors and operators // ----------------------------------------------------------------------- XMLTransService(const XMLTransService&); XMLTransService& operator=(const XMLTransService&); // ----------------------------------------------------------------------- // Hidden method to enable/disable strict IANA encoding check // Caller: XMLPlatformUtils // ----------------------------------------------------------------------- void strictIANAEncoding(const bool newState); bool isStrictIANAEncoding(); static void reinitMappings(); static void reinitMappingsRecognizer();};/** * <code>DOMString</code> is the generic string class that stores all strings * used in the DOM C++ API. * * Though this class supports most of the common string operations to manipulate * strings, it is not meant to be a comphrehensive string class. *//** * <code>XMLTranscoder</code> is for transcoding non-local code * page encodings, i.e. named encodings. These are used internally * by the scanner to internalize raw XML into the internal Unicode * format, and by writer classes to convert that internal Unicode * format (which comes out of the parser) back out to a format that * the receiving client code wants to use. */class XMLUTIL_EXPORT XMLTranscoder : public XMemory{public : /** * This enum is used by the <code>transcodeTo()</code> method * to indicate how to react to unrepresentable characters. The * <code>transcodeFrom()</code> method always works the * same. It will consider any invalid data to be an error and * throw. */ enum UnRepOpts { UnRep_Throw /**< Throw an exception */ , UnRep_RepChar /**< Use the replacement char */ }; /** @name Destructor. */ //@{ /** * Destructor for XMLTranscoder *
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -