00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef XMLFileH
00033 #define XMLFileH
00034
00035 #include <zeusbase/System/File.h>
00036 #include <zeusbase/System/XMLDataSource.h>
00037
00038 BEGIN_NAMESPACE_Zeus
00039
00040 class IXMLParser;
00041
00042
00046
00047 zeusbase_class TXMLFile : public TFile
00048 {
00049 public:
00050 TXMLFile(const TString& rFileName);
00051
00052 void closeXML();
00053 Retval createXMLFile(const IString& rstrMainNodeName);
00054 Retval createXMLFile(const IString& rstrMainNodeName, IXMLNode*& rpMainNode);
00055 Retval createXMLFileFromStream(const IString& rStream);
00056 Retval createXMLFileFromStream(const wchar_t* pStream);
00057 Retval createXObjectFile(const IString& rObjectName, const IString& rRootClassName, const IString& rCodeModule);
00058 Retval createXObjectFile(const wchar_t* pObjectName, const wchar_t* pRootClassName, const wchar_t* pCodeModule);
00059
00060
00061 Retval loadXML(NAMESPACE_Zeus::IXMLDocument*& rpDocument);
00062 Retval loadXObjects(IXObject*& rpObject, bool dDoUnfreeze = true, bool bKeepXObjectAfterClosing = false);
00063
00064 TString getDocumentStream() const;
00065
00066
00067 Retval getMainNode(IXMLNode*& rpMainNode);
00068 Retval selectNode(const IString& rXPath, IXMLNode*& rpNode);
00069 Retval selectNode(const wchar_t* pXPath, IXMLNode*& rpNode);
00070 Retval selectNodes(const IString& rXPath, IXPathResults*& rpResults);
00071 Retval selectNodes(const wchar_t* pXPath, IXPathResults*& rpResults);
00072 Retval selectNodeValue(const IString& rXPath, IString& rValue);
00073 Retval selectNodeValue(const wchar_t* pXPath, IString& rValue);
00074 Retval selectObject(const IString& rXObjectPath, IXObject*& rpObject);
00075 Retval selectObject(const wchar_t* pXObjectPath, IXObject*& rpObject);
00076 Retval selectObjects(const IString& rXObjectPath, IXObjectCollection*& rpCollection);
00077 Retval selectObjects(const wchar_t* pXObjectPath, IXObjectCollection*& rpCollection);
00078
00079 Retval selectCastedObject(const IString& rXObjectPath, const InterfaceID& rInterfaceID, IZUnknown*& rpObject);
00080 Retval selectCastedObject(const wchar_t* pXObjectPath, const InterfaceID& rInterfaceID, IZUnknown*& rpObject);
00081
00082 void useNamespace(const IString& rPrefix, const IString& rNamespace);
00083 void useNamespace(const wchar_t* pPrefix, const wchar_t* pNamespace);
00084
00085 Retval useDefaultNamespaceAs(const IString& rstrPrefix);
00086
00087 Retval writeNodeValue(const IString& rXPath, const IString& rValue);
00088 Retval writeNodeValue(const wchar_t* pXPath, const wchar_t* pValue);
00089
00090 Retval save();
00091 Retval saveAs(const IString& rFileName, bool bKeepOrginalFileName);
00092
00093 protected:
00094 virtual ~TXMLFile();
00095
00096 virtual Retval loadXML_internal();
00097
00098 private:
00100 TXMLDataSource m_XMLDocument;
00102 bool m_bCreateIfNotExists;
00103
00104 Retval createXMLFile_internal(IXMLParser& rParser);
00105 };
00106
00107
00108
00111
00112 inline void TXMLFile::closeXML()
00113 {
00114 m_XMLDocument.closeXML();
00115 }
00116
00117
00120
00121 inline Retval TXMLFile::createXMLFileFromStream(const wchar_t* pStream)
00122 {
00123 return createXMLFileFromStream(TString(pStream));
00124 }
00125
00126
00129
00130 inline Retval TXMLFile::createXObjectFile(const wchar_t* pObjectName, const wchar_t* pRootClassName, const wchar_t* pCodeModule)
00131 {
00132 return createXObjectFile(TString(pObjectName), TString(pRootClassName), TString(pCodeModule));
00133 }
00134
00135
00138
00139 inline Retval TXMLFile::selectNode(const wchar_t* pXPath, IXMLNode*& rpNode)
00140 {
00141 return selectNode(TString(pXPath), rpNode);
00142 }
00143
00144
00147
00148 inline Retval TXMLFile::selectNodes(const wchar_t* pXPath, IXPathResults*& rpResults)
00149 {
00150 return selectNodes(TString(pXPath), rpResults);
00151 }
00152
00153
00156
00157 inline Retval TXMLFile::selectNodeValue(const wchar_t* pXPath, IString& rValue)
00158 {
00159 return selectNodeValue(TString(pXPath), rValue);
00160 }
00161
00162
00165
00166 inline Retval TXMLFile::selectObject(const wchar_t* pXObjectPath, IXObject*& rpObject)
00167 {
00168 return selectObject(TString(pXObjectPath), rpObject);
00169 }
00170
00171
00174
00175 inline Retval TXMLFile::selectObjects(const wchar_t* pXObjectPath, IXObjectCollection*& rpCollection)
00176 {
00177 return selectObjects(TString(pXObjectPath), rpCollection);
00178 }
00179
00180
00183
00184 inline Retval TXMLFile::selectCastedObject(const wchar_t* pXObjectPath, const InterfaceID& rInterfaceID, IZUnknown*& rpObject)
00185 {
00186 return selectCastedObject(TString(pXObjectPath), rInterfaceID, rpObject);
00187 }
00188
00189
00192
00193 inline void TXMLFile::useNamespace(const IString& rPrefix, const IString& rNamespace)
00194 {
00195 m_XMLDocument.useNamespace(rPrefix, rNamespace);
00196 }
00197
00198
00201
00202 inline void TXMLFile::useNamespace(const wchar_t* pPrefix, const wchar_t* pNamespace)
00203 {
00204 m_XMLDocument.useNamespace(TString(pPrefix), TString(pNamespace));
00205 }
00206
00207
00210
00211 inline Retval TXMLFile::writeNodeValue(const wchar_t* pXPath, const wchar_t* pValue)
00212 {
00213 return writeNodeValue(TString(pXPath), TString(pValue));
00214 }
00215
00216
00219
00220 inline Retval TXMLFile::loadXML(NAMESPACE_Zeus::IXMLDocument*& rpDocument)
00221 {
00222 Retval retValue = loadXML_internal();
00223
00224 if (retValue == RET_NOERROR)
00225 {
00226 retValue = m_XMLDocument.loadXML(rpDocument);
00227 }
00228 return retValue;
00229 }
00230
00231
00234
00235 inline Retval TXMLFile::loadXObjects(IXObject*& rpObject, bool dDoUnfreeze , bool bKeepXObjectAfterClosing )
00236 {
00237 Retval retValue = loadXML_internal();
00238
00239 if (retValue == RET_NOERROR)
00240 {
00241 retValue = m_XMLDocument.loadXObjects(rpObject, dDoUnfreeze, bKeepXObjectAfterClosing);
00242 }
00243 return retValue;
00244 }
00245
00246
00249
00250 inline TString TXMLFile::getDocumentStream() const
00251 {
00252 TString strRetval;
00253 if (m_XMLDocument.isAvailable())
00254 {
00255 strRetval = m_XMLDocument.getDocumentStream();
00256 }
00257 return strRetval;
00258 }
00259
00260
00263
00264 inline Retval TXMLFile::selectNode(const IString& rXPath, IXMLNode*& rpNode)
00265 {
00266 Retval retValue = loadXML_internal();
00267
00268 if (retValue == RET_NOERROR)
00269 {
00270 retValue = m_XMLDocument.selectNode(rXPath, rpNode);
00271 }
00272 return retValue;
00273 }
00274
00275
00278
00279 inline Retval TXMLFile::selectNodes(const IString& rXPath, IXPathResults*& rpResults)
00280 {
00281 Retval retValue = loadXML_internal();
00282
00283 if (retValue == RET_NOERROR)
00284 {
00285 retValue = m_XMLDocument.selectNodes(rXPath, rpResults);
00286 }
00287 return retValue;
00288 }
00289
00290
00291
00294
00295 inline Retval TXMLFile::selectNodeValue(const IString& rXPath, IString& rValue)
00296 {
00297 Retval retValue = loadXML_internal();
00298
00299 if (retValue == RET_NOERROR)
00300 {
00301 retValue = m_XMLDocument.selectNodeValue(rXPath, rValue);
00302 }
00303 return retValue;
00304 }
00305
00306
00307
00310
00311 inline Retval TXMLFile::selectObject(const IString& rXObjectPath, IXObject*& rpObject)
00312 {
00313 Retval retValue = loadXML_internal();
00314
00315 if (retValue == RET_NOERROR)
00316 {
00317 retValue = m_XMLDocument.selectObject(rXObjectPath, rpObject);
00318 }
00319 return retValue;
00320 }
00321
00322
00325
00326 inline Retval TXMLFile::selectObjects(const IString& rXObjectPath, IXObjectCollection*& rpCollection)
00327 {
00328 Retval retValue = loadXML_internal();
00329
00330 if (retValue == RET_NOERROR)
00331 {
00332 retValue = m_XMLDocument.selectObjects(rXObjectPath, rpCollection);
00333 }
00334 return retValue;
00335 }
00336
00337
00340
00341 inline Retval TXMLFile::selectCastedObject(const IString& rXObjectPath, const InterfaceID& rInterfaceID, IZUnknown*& rpObject)
00342 {
00343 Retval retValue = loadXML_internal();
00344
00345 if (retValue == RET_NOERROR)
00346 {
00347 retValue = m_XMLDocument.selectCastedObject(rXObjectPath, rInterfaceID, rpObject);
00348 }
00349 return retValue;
00350 }
00351
00352
00353
00356
00357 inline Retval TXMLFile::writeNodeValue(const IString& rXPath, const IString& rValue)
00358 {
00359 Retval retValue = loadXML_internal();
00360
00361 if (retValue == RET_NOERROR)
00362 {
00363 retValue = m_XMLDocument.writeNodeValue(rXPath, rValue);
00364 }
00365 return retValue;
00366 }
00367
00368 END_NAMESPACE_Zeus
00369
00370
00371 #endif