MTK++ Latest version: 0.2.0

xmlConvertors.h
Go to the documentation of this file.
00001 
00032 #ifndef XMLCONVERTORS_H
00033 #define XMLCONVERTORS_H
00034 
00035 #include <iostream>
00036 #include <sstream>
00037 #include <xercesc/dom/DOMElement.hpp>
00038 #include <xercesc/dom/DOMNode.hpp>
00039 
00040 #if (XERCES_VERSION_MAJOR == 3)
00041 #include <xercesc/dom/DOM.hpp>
00042 #include <xercesc/dom/DOMLSSerializer.hpp>
00043 #include <xercesc/dom/DOM.hpp>
00044 #include <xercesc/dom/impl/DOMLSSerializerImpl.hpp>
00045 #else
00046 #include <xercesc/dom/DOMWriter.hpp>
00047 #include <xercesc/dom/DOM.hpp>
00048 #endif
00049 
00050 #include <xercesc/util/XMLString.hpp>
00051 #include <xercesc/util/PlatformUtils.hpp>
00052 #include <xercesc/framework/XMLFormatter.hpp>
00053 #include <xercesc/framework/LocalFileFormatTarget.hpp>
00054 //using namespace std;
00055 
00056 XERCES_CPP_NAMESPACE_USE
00057 
00058 // ============================================================
00059 // Class : StrX()
00060 // ------------------------------------------------------------
00068 // ============================================================
00069 class StrX{
00070 public :
00071 
00075     StrX(const XMLCh* const toTranscode){
00076         // Call the private transcoding method
00077         fLocalForm = XMLString::transcode(toTranscode);
00078     }
00079 
00081     ~StrX(){
00082         XMLString::release(&fLocalForm);
00083     }
00084     const char* localForm() const{
00085         return fLocalForm;
00086     }
00087 protected:
00088 
00090     char*   fLocalForm;
00091 };
00092 
00093 #define XC(xch) StrX(xch).localForm()
00094 #define CX(str) XStrC(str).unicodeForm()
00095 #define X(str) XStrC(str).unicodeForm()
00096 
00097 // ============================================================
00098 // Class : XStrC()
00099 // ------------------------------------------------------------
00107 // ============================================================
00108 class XStrC{
00109 public :
00110 
00114     XStrC(const char* const toTranscode){
00115         // Call the private transcoding method
00116         fUnicodeForm = XMLString::transcode(toTranscode);
00117     }
00118 
00120     ~XStrC(){
00121         XMLString::release(&fUnicodeForm);
00122     }
00123     const XMLCh* unicodeForm() const{
00124         return fUnicodeForm;
00125     }
00126 
00127 protected:
00129     XMLCh*   fUnicodeForm;
00130 };
00131 
00132 template<typename P>
00133 const char* tocchars(P val){
00134 std::stringstream sval;
00135 sval << val << std::ends;
00136 return (sval.str().c_str());
00137 }
00138 
00139 #endif // XMLCONVERTORS_H
00140 

Generated on Fri Dec 23 2011 09:28:52 for MTK++ by Doxygen 1.7.5.1