📄 xmlformatter.hpp
字号:
const XMLCh* getEncodingName() const; /** * @return return the transcoder used internally for transcoding the formatter conent */ inline const XMLTranscoder* getTranscoder() const; //@} // ----------------------------------------------------------------------- // Setter methods // ----------------------------------------------------------------------- /** @name Setter methods */ //@{ /** * @param newFlags set the escape style for the follow-on formatted content */ void setEscapeFlags ( const EscapeFlags newFlags ); /** * @param newFlags set the reaction for unrepresentable character */ void setUnRepFlags ( const UnRepFlags newFlags ); /** * @param newFlags set the escape style for the follow-on formatted content * @see setEscapeFlags */ XMLFormatter& operator<< ( const EscapeFlags newFlags ); /** * @param newFlags set the reaction for unrepresentable character * @see setUnRepFlags */ XMLFormatter& operator<< ( const UnRepFlags newFlags ); //@} // ----------------------------------------------------------------------- // Getter methods // ----------------------------------------------------------------------- /** @name Setter methods */ //@{ /** * @return return the escape style for the formatted content */ EscapeFlags getEscapeFlags() const; /** * @return return the reaction for unrepresentable character */ UnRepFlags getUnRepFlags() const; //@}private : // ----------------------------------------------------------------------- // Unimplemented constructors and operators // ----------------------------------------------------------------------- XMLFormatter(); XMLFormatter(const XMLFormatter&); XMLFormatter& operator=(const XMLFormatter&); // ----------------------------------------------------------------------- // Private class constants // ----------------------------------------------------------------------- enum Constants { kTmpBufSize = 16 * 1024 }; // ----------------------------------------------------------------------- // Private helper methods // ----------------------------------------------------------------------- const XMLByte* getCharRef(unsigned int & count, XMLByte* &ref, const XMLCh * stdRef); void writeCharRef(const XMLCh &toWrite); void writeCharRef(unsigned long toWrite); bool inEscapeList(const XMLFormatter::EscapeFlags escStyle , const XMLCh toCheck); unsigned int handleUnEscapedChars(const XMLCh * srcPtr, const unsigned int count, const UnRepFlags unrepFlags); void specialFormat ( const XMLCh* const toFormat , const unsigned int count , const EscapeFlags escapeFlags ); // ----------------------------------------------------------------------- // Private, non-virtual methods // // fEscapeFlags // The escape flags we were told to use in formatting. These are // defaults set in the ctor, which can be overridden on a particular // call. // // fOutEncoding // This the name of the output encoding. Saved mainly for meaningful // error messages. // // fTarget // This is the target object for the formatting operation. // // fUnRepFlags // The unrepresentable flags that indicate how to react when a // character cannot be represented in the target encoding. // // fXCoder // This the transcoder that we will use. It is created using the // encoding name we were told to use. // // fTmpBuf // An output buffer that we use to transcode chars into before we // send them off to be output. // // fAposRef // fAmpRef // fGTRef // fLTRef // fQuoteRef // These are character refs for the standard char refs, in the // output encoding. They are faulted in as required, by transcoding // them from fixed Unicode versions. // // fIsXML11 // for performance reason, we do not store the actual version string // and do the string comparison again and again. // // ----------------------------------------------------------------------- EscapeFlags fEscapeFlags; XMLCh* fOutEncoding; XMLFormatTarget* fTarget; UnRepFlags fUnRepFlags; XMLTranscoder* fXCoder; XMLByte fTmpBuf[kTmpBufSize + 4]; XMLByte* fAposRef; unsigned int fAposLen; XMLByte* fAmpRef; unsigned int fAmpLen; XMLByte* fGTRef; unsigned int fGTLen; XMLByte* fLTRef; unsigned int fLTLen; XMLByte* fQuoteRef; unsigned int fQuoteLen; bool fIsXML11; MemoryManager* fMemoryManager;};class XMLPARSER_EXPORT XMLFormatTarget : public XMemory{public: // ----------------------------------------------------------------------- // Constructors and Destructor // ----------------------------------------------------------------------- virtual ~XMLFormatTarget() {} // ----------------------------------------------------------------------- // Virtual interface // ----------------------------------------------------------------------- virtual void writeChars ( const XMLByte* const toWrite , const unsigned int count , XMLFormatter* const formatter ) = 0; virtual void flush() {};protected : // ----------------------------------------------------------------------- // Hidden constructors and operators // ----------------------------------------------------------------------- XMLFormatTarget() {};private: // ----------------------------------------------------------------------- // Unimplemented constructors and operators // ----------------------------------------------------------------------- XMLFormatTarget(const XMLFormatTarget&); XMLFormatTarget& operator=(const XMLFormatTarget&);};// ---------------------------------------------------------------------------// XMLFormatter: Getter methods// ---------------------------------------------------------------------------inline const XMLCh* XMLFormatter::getEncodingName() const{ return fOutEncoding;}inline const XMLTranscoder* XMLFormatter::getTranscoder() const{ return fXCoder;}// ---------------------------------------------------------------------------// XMLFormatter: Setter methods// ---------------------------------------------------------------------------inline void XMLFormatter::setEscapeFlags(const EscapeFlags newFlags){ fEscapeFlags = newFlags;}inline void XMLFormatter::setUnRepFlags(const UnRepFlags newFlags){ fUnRepFlags = newFlags;}inline XMLFormatter& XMLFormatter::operator<<(const EscapeFlags newFlags){ fEscapeFlags = newFlags; return *this;}inline XMLFormatter& XMLFormatter::operator<<(const UnRepFlags newFlags){ fUnRepFlags = newFlags; return *this;}// ---------------------------------------------------------------------------// XMLFormatter: Getter methods// ---------------------------------------------------------------------------inline XMLFormatter::EscapeFlags XMLFormatter::getEscapeFlags() const{ return fEscapeFlags;}inline XMLFormatter::UnRepFlags XMLFormatter::getUnRepFlags() const{ return fUnRepFlags;}XERCES_CPP_NAMESPACE_END#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -