GME  13
Transcoder.h
Go to the documentation of this file.
00001 #ifndef XML_TRANS_H
00002 #define XML_TRANS_H
00003 
00004 #include <fstream> // fstream.h
00005 #include    <xercesc/sax/HandlerBase.hpp>
00006 #include    <xercesc/framework/XMLFormatter.hpp>
00007 
00008 XERCES_CPP_NAMESPACE_USE
00009 
00010 class Transcoder : private XMLFormatTarget, private std::ofstream
00011 {
00012 public:
00013     // -----------------------------------------------------------------------
00014     //  Constructors
00015     // -----------------------------------------------------------------------
00016     Transcoder();
00017     ~Transcoder();
00018 
00019         void init( const TCHAR *, const TCHAR * const);
00020         void finalize();
00021         enum Modes
00022         {
00023                 NoEscape, // normal transcoding 
00024                 StdEscape // additionally escaping special characters like &<>'"
00025         };
00026 
00027     // -----------------------------------------------------------------------
00028     //  Implementations of the format target interface
00029     // -----------------------------------------------------------------------
00030     void writeChars(const   XMLByte* const  toWrite, const XMLSize_t count, XMLFormatter* const   formatter);
00031         
00032         Transcoder& operator << ( Modes mode);
00033         Transcoder& operator << ( const XMLCh* const toWrite);
00034         Transcoder& operator << ( const char * const toWrite);
00035         Transcoder& operator << ( const char toWrite);
00036         Transcoder& operator << ( const std::tstring& toWrite);
00037 
00038 private :
00039     XMLFormatter* m_pFormatter;
00040 };
00041 
00042 
00043 #endif // XML_TRANS_H