File indexing completed on 2025-01-18 10:15:16
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_XMLUTF8TRANSCODER_HPP)
0023 #define XERCESC_INCLUDE_GUARD_XMLUTF8TRANSCODER_HPP
0024
0025 #include <xercesc/util/XercesDefs.hpp>
0026 #include <xercesc/util/TransService.hpp>
0027 #include <xercesc/util/UTFDataFormatException.hpp>
0028
0029 XERCES_CPP_NAMESPACE_BEGIN
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039 class XMLUTIL_EXPORT XMLUTF8Transcoder : public XMLTranscoder
0040 {
0041 public :
0042
0043
0044
0045 XMLUTF8Transcoder
0046 (
0047 const XMLCh* const encodingName
0048 , const XMLSize_t blockSize
0049 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
0050 );
0051
0052 virtual ~XMLUTF8Transcoder();
0053
0054
0055
0056
0057
0058 virtual XMLSize_t transcodeFrom
0059 (
0060 const XMLByte* const srcData
0061 , const XMLSize_t srcCount
0062 , XMLCh* const toFill
0063 , const XMLSize_t maxChars
0064 , XMLSize_t& bytesEaten
0065 , unsigned char* const charSizes
0066 );
0067
0068 virtual XMLSize_t transcodeTo
0069 (
0070 const XMLCh* const srcData
0071 , const XMLSize_t srcCount
0072 , XMLByte* const toFill
0073 , const XMLSize_t maxBytes
0074 , XMLSize_t& charsEaten
0075 , const UnRepOpts options
0076 );
0077
0078 virtual bool canTranscodeTo
0079 (
0080 const unsigned int toCheck
0081 );
0082
0083
0084 private :
0085
0086 inline void checkTrailingBytes(
0087 const XMLByte toCheck
0088 , const unsigned int trailingBytes
0089 , const unsigned int position
0090 ) const;
0091
0092 private :
0093
0094
0095
0096 XMLUTF8Transcoder(const XMLUTF8Transcoder&);
0097 XMLUTF8Transcoder& operator=(const XMLUTF8Transcoder&);
0098 };
0099
0100 inline
0101 void XMLUTF8Transcoder::checkTrailingBytes(const XMLByte toCheck
0102 , const unsigned int trailingBytes
0103 , const unsigned int position) const
0104 {
0105
0106 if((toCheck & 0xC0) != 0x80)
0107 {
0108 char len[2] = {(char)(trailingBytes+0x31), 0};
0109 char pos[2] = {(char)(position+0x31), 0};
0110 char byte[2] = {(char)toCheck,0};
0111 ThrowXMLwithMemMgr3(UTFDataFormatException, XMLExcepts::UTF8_FormatError, pos, byte, len, getMemoryManager());
0112 }
0113
0114 }
0115
0116 XERCES_CPP_NAMESPACE_END
0117
0118 #endif