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 XMLStreamH
00033 #define XMLStreamH
00034
00035 #include <zeusbase/System/XMLDataSource.h>
00036 #include <zeusbase/System/ZObject.h>
00037
00038 BEGIN_NAMESPACE_Zeus
00039
00040 class IXMLParser;
00041
00042
00043
00048
00049 zeusbase_class TXMLStream : public TZObject
00050 {
00051 public:
00052 TXMLStream(const IString& rData);
00053
00054 void closeXML();
00055
00056
00057 Retval loadXML(NAMESPACE_Zeus::IXMLDocument*& rpDocument);
00058 Retval loadXObjects(IXObject*& rpObject, bool dDoUnfreeze = true, bool bKeepXObjectAfterClosing = false);
00059
00060 TString getDocumentStream() const;
00061
00062
00063 Retval selectNode(const IString& rXPath, IXMLNode*& rpNode);
00064 Retval selectNode(const wchar_t* pXPath, IXMLNode*& rpNode);
00065 Retval selectNodes(const IString& rXPath, IXPathResults*& rpResults);
00066 Retval selectNodes(const wchar_t* pXPath, IXPathResults*& rpResults);
00067 Retval selectNodeValue(const IString& rXPath, IString& rValue);
00068 Retval selectNodeValue(const wchar_t* pXPath, IString& rValue);
00069 Retval selectObject(const IString& rXObjectPath, IXObject*& rpObject);
00070 Retval selectObject(const wchar_t* pXObjectPath, IXObject*& rpObject);
00071 Retval selectObjects(const IString& rXObjectPath, IXObjectCollection*& rpCollection);
00072 Retval selectObjects(const wchar_t* pXObjectPath, IXObjectCollection*& rpCollection);
00073 Retval selectCastedObject(const IString& rXObjectPath, const InterfaceID& rInterfaceID, IZUnknown*& rpObject);
00074 Retval selectCastedObject(const wchar_t* pXObjectPath, const InterfaceID& rInterfaceID, IZUnknown*& rpObject);
00075
00076 void useNamespace(const IString& rPrefix, const IString& rNamespace);
00077 void useNamespace(const wchar_t* pPrefix, const wchar_t* pNamespace);
00078
00079 Retval writeNodeValue(const IString& rXPath, const IString& rValue);
00080 Retval writeNodeValue(const wchar_t* pXPath, const wchar_t* pValue);
00081
00082 protected:
00083 virtual ~TXMLStream();
00084
00085 virtual Retval loadXML_internal();
00086
00087 private:
00089 TString m_strData;
00091 TXMLDataSource m_XMLDocument;
00092 };
00093
00094
00097
00098 inline void TXMLStream::closeXML()
00099 {
00100 m_XMLDocument.closeXML();
00101 }
00102
00103
00106
00107 inline Retval TXMLStream::selectNode(const wchar_t* pXPath, IXMLNode*& rpNode)
00108 {
00109 return selectNode(TString(pXPath), rpNode);
00110 }
00111
00112
00115
00116 inline Retval TXMLStream::selectNodes(const wchar_t* pXPath, IXPathResults*& rpResults)
00117 {
00118 return selectNodes(TString(pXPath), rpResults);
00119 }
00120
00121
00124
00125 inline Retval TXMLStream::selectNodeValue(const wchar_t* pXPath, IString& rValue)
00126 {
00127 return selectNodeValue(TString(pXPath), rValue);
00128 }
00129
00130
00133
00134 inline Retval TXMLStream::selectObject(const wchar_t* pXObjectPath, IXObject*& rpObject)
00135 {
00136 return selectObject(TString(pXObjectPath), rpObject);
00137 }
00138
00139
00142
00143 inline Retval TXMLStream::selectObjects(const wchar_t* pXObjectPath, IXObjectCollection*& rpCollection)
00144 {
00145 return selectObjects(TString(pXObjectPath), rpCollection);
00146 }
00147
00148
00151
00152 inline Retval TXMLStream::selectCastedObject(const wchar_t* pXObjectPath, const InterfaceID& rInterfaceID, IZUnknown*& rpObject)
00153 {
00154 return selectCastedObject(TString(pXObjectPath), rInterfaceID, rpObject);
00155 }
00156
00157
00160
00161 inline void TXMLStream::useNamespace(const IString& rPrefix, const IString& rNamespace)
00162 {
00163 m_XMLDocument.useNamespace(rPrefix, rNamespace);
00164 }
00165
00166
00169
00170 inline void TXMLStream::useNamespace(const wchar_t* pPrefix, const wchar_t* pNamespace)
00171 {
00172 m_XMLDocument.useNamespace(TString(pPrefix), TString(pNamespace));
00173 }
00174
00175
00178
00179 inline Retval TXMLStream::writeNodeValue(const wchar_t* pXPath, const wchar_t* pValue)
00180 {
00181 return writeNodeValue(TString(pXPath), TString(pValue));
00182 }
00183
00184
00187
00188 inline Retval TXMLStream::loadXML(NAMESPACE_Zeus::IXMLDocument*& rpDocument)
00189 {
00190 Retval retValue = loadXML_internal();
00191
00192 if (retValue == RET_NOERROR)
00193 {
00194 retValue = m_XMLDocument.loadXML(rpDocument);
00195 }
00196 return retValue;
00197 }
00198
00199
00202
00203 inline Retval TXMLStream::loadXObjects(IXObject*& rpObject, bool dDoUnfreeze , bool bKeepXObjectAfterClosing )
00204 {
00205 Retval retValue = loadXML_internal();
00206
00207 if (retValue == RET_NOERROR)
00208 {
00209 retValue = m_XMLDocument.loadXObjects(rpObject, dDoUnfreeze, bKeepXObjectAfterClosing);
00210 }
00211 return retValue;
00212 }
00213
00214
00217
00218 inline TString TXMLStream::getDocumentStream() const
00219 {
00220 TString strRetval;
00221 if (m_XMLDocument.isAvailable())
00222 {
00223 strRetval = m_XMLDocument.getDocumentStream();
00224 }
00225 else
00226 {
00227 strRetval = m_strData;
00228 }
00229 return strRetval;
00230 }
00231
00232
00235
00236 inline Retval TXMLStream::selectNode(const IString& rXPath, IXMLNode*& rpNode)
00237 {
00238 Retval retValue = loadXML_internal();
00239
00240 if (retValue == RET_NOERROR)
00241 {
00242 retValue = m_XMLDocument.selectNode(rXPath, rpNode);
00243 }
00244 return retValue;
00245 }
00246
00247
00250
00251 inline Retval TXMLStream::selectNodes(const IString& rXPath, IXPathResults*& rpResults)
00252 {
00253 Retval retValue = loadXML_internal();
00254
00255 if (retValue == RET_NOERROR)
00256 {
00257 retValue = m_XMLDocument.selectNodes(rXPath, rpResults);
00258 }
00259 return retValue;
00260 }
00261
00262
00263
00266
00267 inline Retval TXMLStream::selectNodeValue(const IString& rXPath, IString& rValue)
00268 {
00269 Retval retValue = loadXML_internal();
00270
00271 if (retValue == RET_NOERROR)
00272 {
00273 retValue = m_XMLDocument.selectNodeValue(rXPath, rValue);
00274 }
00275 return retValue;
00276 }
00277
00278
00279
00282
00283 inline Retval TXMLStream::selectObject(const IString& rXObjectPath, IXObject*& rpObject)
00284 {
00285 Retval retValue = loadXML_internal();
00286
00287 if (retValue == RET_NOERROR)
00288 {
00289 retValue = m_XMLDocument.selectObject(rXObjectPath, rpObject);
00290 }
00291 return retValue;
00292 }
00293
00294
00297
00298 inline Retval TXMLStream::selectObjects(const IString& rXObjectPath, IXObjectCollection*& rpCollection)
00299 {
00300 Retval retValue = loadXML_internal();
00301
00302 if (retValue == RET_NOERROR)
00303 {
00304 retValue = m_XMLDocument.selectObjects(rXObjectPath, rpCollection);
00305 }
00306 return retValue;
00307 }
00308
00309
00312
00313 inline Retval TXMLStream::selectCastedObject(const IString& rXObjectPath, const InterfaceID& rInterfaceID, IZUnknown*& rpObject)
00314 {
00315 Retval retValue = loadXML_internal();
00316
00317 if (retValue == RET_NOERROR)
00318 {
00319 retValue = m_XMLDocument.selectCastedObject(rXObjectPath, rInterfaceID, rpObject);
00320 }
00321 return retValue;
00322 }
00323
00324
00325
00328
00329 inline Retval TXMLStream::writeNodeValue(const IString& rXPath, const IString& rValue)
00330 {
00331 Retval retValue = loadXML_internal();
00332
00333 if (retValue == RET_NOERROR)
00334 {
00335 retValue = m_XMLDocument.writeNodeValue(rXPath, rValue);
00336 }
00337 return retValue;
00338 }
00339
00340
00341 END_NAMESPACE_Zeus
00342
00343 #endif