CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/CondTools/Ecal/interface/XercesString.h

Go to the documentation of this file.
00001 #ifndef XERCES_STRINGS_H
00002 #define XERCES_STRINGS_H
00003 
00004 #include <string>
00005 #include <boost/scoped_array.hpp>
00006 #include <xercesc/util/XMLString.hpp>
00007 #include <iostream>
00008 
00009 
00025 namespace xuti {
00026   
00028   typedef std::basic_string<XMLCh> XercesString;
00029   
00030   // Converts from a narrow-character string to a wide-character string.
00031   inline XercesString fromNative(const char* str){
00032     boost::scoped_array<XMLCh> ptr(xercesc::XMLString::transcode(str));
00033     return XercesString(ptr.get( ));
00034   }
00035   
00036   // Converts from a narrow-character string to a wide-charactr string.
00037   inline XercesString fromNative(const std::string& str){
00038     return fromNative(str.c_str( ));
00039   }
00040   
00041   // Converts from a wide-character string to a narrow-character string.
00042   inline std::string toNative(const XMLCh* str){
00043     boost::scoped_array<char> ptr(xercesc::XMLString::transcode(str));
00044     return std::string(ptr.get( ));
00045   }
00046   
00047   // Converts from a wide-character string to a narrow-character string.
00048   inline std::string toNative(const XercesString& str){
00049     return toNative(str.c_str( ));
00050   }
00051 
00052 
00053 } // namespace 
00054 
00055 #endif // #ifndef XERCES_STRINGS_H