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
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef XMLStreamH
00043 #define XMLStreamH
00044
00045
00046 #include <zeusbase/System/XMLDataSource.h>
00047 #include <zeusbase/System/ZObject.h>
00048
00049 BEGIN_NAMESPACE_Zeus
00050
00051 class IXMLParser;
00052
00053
00054
00059
00060 zeusbase_class TXMLStream : public TZObject
00061 {
00062 public:
00063 TXMLStream(const IString& rData);
00064
00065 void closeXML();
00066
00067
00068 Retval loadXML(NAMESPACE_Zeus::IXMLDocument*& rpDocument);
00069 Retval loadXObjects(IXObject*& rpObject, bool dDoUnfreeze = true, bool bKeepXObjectAfterClosing = false);
00070
00071 TString getDocumentStream() const;
00072
00073
00074 Retval selectNode(const IString& rXPath, IXMLNode*& rpNode);
00075 Retval selectNode(const wchar_t* pXPath, IXMLNode*& rpNode);
00076 Retval selectNodes(const IString& rXPath, IXPathResults*& rpResults);
00077 Retval selectNodes(const wchar_t* pXPath, IXPathResults*& rpResults);
00078 Retval selectNodeValue(const IString& rXPath, IString& rValue);
00079 Retval selectNodeValue(const wchar_t* pXPath, IString& rValue);
00080 Retval selectObject(const IString& rXObjectPath, IXObject*& rpObject);
00081 Retval selectObject(const wchar_t* pXObjectPath, IXObject*& rpObject);
00082 Retval selectObjects(const IString& rXObjectPath, IXObjectCollection*& rpCollection);
00083 Retval selectObjects(const wchar_t* pXObjectPath, IXObjectCollection*& rpCollection);
00084 Retval selectCastedObject(const IString& rXObjectPath, const InterfaceID& rInterfaceID, IZUnknown*& rpObject);
00085 Retval selectCastedObject(const wchar_t* pXObjectPath, const InterfaceID& rInterfaceID, IZUnknown*& rpObject);
00086
00087 void useNamespace(const IString& rPrefix, const IString& rNamespace);
00088 void useNamespace(const wchar_t* pPrefix, const wchar_t* pNamespace);
00089
00090 Retval writeNodeValue(const IString& rXPath, const IString& rValue);
00091 Retval writeNodeValue(const wchar_t* pXPath, const wchar_t* pValue);
00092
00093 protected:
00094 virtual ~TXMLStream();
00095
00096 virtual Retval loadXML_internal();
00097
00098 private:
00100 TString m_strData;
00102 TXMLDataSource m_XMLDocument;
00103 };
00104
00105
00108
00109 inline void TXMLStream::closeXML()
00110 {
00111 m_XMLDocument.closeXML();
00112 }
00113
00114
00117
00118 inline Retval TXMLStream::selectNode(const wchar_t* pXPath, IXMLNode*& rpNode)
00119 {
00120 return selectNode(TString(pXPath), rpNode);
00121 }
00122
00123
00126
00127 inline Retval TXMLStream::selectNodes(const wchar_t* pXPath, IXPathResults*& rpResults)
00128 {
00129 return selectNodes(TString(pXPath), rpResults);
00130 }
00131
00132
00135
00136 inline Retval TXMLStream::selectNodeValue(const wchar_t* pXPath, IString& rValue)
00137 {
00138 return selectNodeValue(TString(pXPath), rValue);
00139 }
00140
00141
00144
00145 inline Retval TXMLStream::selectObject(const wchar_t* pXObjectPath, IXObject*& rpObject)
00146 {
00147 return selectObject(TString(pXObjectPath), rpObject);
00148 }
00149
00150
00153
00154 inline Retval TXMLStream::selectObjects(const wchar_t* pXObjectPath, IXObjectCollection*& rpCollection)
00155 {
00156 return selectObjects(TString(pXObjectPath), rpCollection);
00157 }
00158
00159
00162
00163 inline Retval TXMLStream::selectCastedObject(const wchar_t* pXObjectPath, const InterfaceID& rInterfaceID, IZUnknown*& rpObject)
00164 {
00165 return selectCastedObject(TString(pXObjectPath), rInterfaceID, rpObject);
00166 }
00167
00168
00171
00172 inline void TXMLStream::useNamespace(const IString& rPrefix, const IString& rNamespace)
00173 {
00174 m_XMLDocument.useNamespace(rPrefix, rNamespace);
00175 }
00176
00177
00180
00181 inline void TXMLStream::useNamespace(const wchar_t* pPrefix, const wchar_t* pNamespace)
00182 {
00183 m_XMLDocument.useNamespace(TString(pPrefix), TString(pNamespace));
00184 }
00185
00186
00189
00190 inline Retval TXMLStream::writeNodeValue(const wchar_t* pXPath, const wchar_t* pValue)
00191 {
00192 return writeNodeValue(TString(pXPath), TString(pValue));
00193 }
00194
00195
00198
00199 inline Retval TXMLStream::loadXML(NAMESPACE_Zeus::IXMLDocument*& rpDocument)
00200 {
00201 Retval retValue = loadXML_internal();
00202
00203 if (retValue == RET_NOERROR)
00204 {
00205 retValue = m_XMLDocument.loadXML(rpDocument);
00206 }
00207 return retValue;
00208 }
00209
00210
00213
00214 inline Retval TXMLStream::loadXObjects(IXObject*& rpObject, bool dDoUnfreeze , bool bKeepXObjectAfterClosing )
00215 {
00216 Retval retValue = loadXML_internal();
00217
00218 if (retValue == RET_NOERROR)
00219 {
00220 retValue = m_XMLDocument.loadXObjects(rpObject, dDoUnfreeze, bKeepXObjectAfterClosing);
00221 }
00222 return retValue;
00223 }
00224
00225
00228
00229 inline TString TXMLStream::getDocumentStream() const
00230 {
00231 TString strRetval;
00232 if (m_XMLDocument.isAvailable())
00233 {
00234 strRetval = m_XMLDocument.getDocumentStream();
00235 }
00236 else
00237 {
00238 strRetval = m_strData;
00239 }
00240 return strRetval;
00241 }
00242
00243
00246
00247 inline Retval TXMLStream::selectNode(const IString& rXPath, IXMLNode*& rpNode)
00248 {
00249 Retval retValue = loadXML_internal();
00250
00251 if (retValue == RET_NOERROR)
00252 {
00253 retValue = m_XMLDocument.selectNode(rXPath, rpNode);
00254 }
00255 return retValue;
00256 }
00257
00258
00261
00262 inline Retval TXMLStream::selectNodes(const IString& rXPath, IXPathResults*& rpResults)
00263 {
00264 Retval retValue = loadXML_internal();
00265
00266 if (retValue == RET_NOERROR)
00267 {
00268 retValue = m_XMLDocument.selectNodes(rXPath, rpResults);
00269 }
00270 return retValue;
00271 }
00272
00273
00274
00277
00278 inline Retval TXMLStream::selectNodeValue(const IString& rXPath, IString& rValue)
00279 {
00280 Retval retValue = loadXML_internal();
00281
00282 if (retValue == RET_NOERROR)
00283 {
00284 retValue = m_XMLDocument.selectNodeValue(rXPath, rValue);
00285 }
00286 return retValue;
00287 }
00288
00289
00290
00293
00294 inline Retval TXMLStream::selectObject(const IString& rXObjectPath, IXObject*& rpObject)
00295 {
00296 Retval retValue = loadXML_internal();
00297
00298 if (retValue == RET_NOERROR)
00299 {
00300 retValue = m_XMLDocument.selectObject(rXObjectPath, rpObject);
00301 }
00302 return retValue;
00303 }
00304
00305
00308
00309 inline Retval TXMLStream::selectObjects(const IString& rXObjectPath, IXObjectCollection*& rpCollection)
00310 {
00311 Retval retValue = loadXML_internal();
00312
00313 if (retValue == RET_NOERROR)
00314 {
00315 retValue = m_XMLDocument.selectObjects(rXObjectPath, rpCollection);
00316 }
00317 return retValue;
00318 }
00319
00320
00323
00324 inline Retval TXMLStream::selectCastedObject(const IString& rXObjectPath, const InterfaceID& rInterfaceID, IZUnknown*& rpObject)
00325 {
00326 Retval retValue = loadXML_internal();
00327
00328 if (retValue == RET_NOERROR)
00329 {
00330 retValue = m_XMLDocument.selectCastedObject(rXObjectPath, rInterfaceID, rpObject);
00331 }
00332 return retValue;
00333 }
00334
00335
00336
00339
00340 inline Retval TXMLStream::writeNodeValue(const IString& rXPath, const IString& rValue)
00341 {
00342 Retval retValue = loadXML_internal();
00343
00344 if (retValue == RET_NOERROR)
00345 {
00346 retValue = m_XMLDocument.writeNodeValue(rXPath, rValue);
00347 }
00348 return retValue;
00349 }
00350
00351
00352 END_NAMESPACE_Zeus
00353
00354 #endif