Pol  Rev 533
clib/xmlutil.h
Go to the documentation of this file.
00001 /*
00002 History
00003 =======
00004 
00005 
00006 Notes
00007 =======
00008 
00009 */
00010 
00011 #ifndef CLIB_XMLUTIL_H
00012 #define CLIB_XMLUTIL_H
00013 
00014 // ---------------------------------------------------------------------------
00015 //  This is a simple class that lets us do easy (though not terribly efficient)
00016 //  trancoding of char* data to XMLCh data.
00017 // ---------------------------------------------------------------------------
00018 class XStr
00019 {
00020 public :
00021     // -----------------------------------------------------------------------
00022     //  Constructors and Destructor
00023     // -----------------------------------------------------------------------
00024     explicit XStr(const char* const toTranscode)
00025     {
00026         // Call the private transcoding method
00027         fUnicodeForm = XMLString::transcode(toTranscode);
00028     }
00029     explicit XStr( const std::string& toTranscode )
00030     {
00031         // Call the private transcoding method
00032         fUnicodeForm = XMLString::transcode(toTranscode.c_str() );
00033     }
00034 
00035     ~XStr()
00036     {
00037         XMLString::release(&fUnicodeForm);
00038     }
00039 
00040 
00041     // -----------------------------------------------------------------------
00042     //  Getter methods
00043     // -----------------------------------------------------------------------
00044     const XMLCh* unicodeForm() const
00045     {
00046         return fUnicodeForm;
00047     }
00048 
00049 private :
00050     // -----------------------------------------------------------------------
00051     //  Private data members
00052     //
00053     //  fUnicodeForm
00054     //      This is the Unicode XMLCh format of the string.
00055     // -----------------------------------------------------------------------
00056     XMLCh*   fUnicodeForm;
00057 };
00058 
00059 #define X(str) XStr(str).unicodeForm()
00060 
00061 #endif