it_bus_pdk/xml_helper.h

00001 #ifndef _IT_XML_HELPER_
00002 #define _IT_XML_HELPER_
00003 
00004 #include <it_bus/api_defines.h>
00005 #include <it_bus/binary_buffer.h>
00006 #include <it_bus/exception.h>
00007 #include <it_bus/types.h>
00008 
00009 // REVISIT: this header should not refer to any Xerces-C type!
00010 //
00011 namespace xercesc_2_4
00012 {
00013     class DOMElement;
00014     class XercesDOMParser;
00015 }
00016 
00017 namespace IT_Bus
00018 {
00019     class EntityResolverBase;
00020 }
00021 
00022 namespace IT_Bus
00023 {
00024     class IT_BUS_XML_API XercesString
00025     {
00026       public:
00027 
00028         static char* 
00029         replicate(
00030             const char* source
00031         );
00032 
00033         static void 
00034         destroy(
00035             char* source
00036         );
00037     };
00038 
00039     class IT_BUS_XML_API XMLHelper 
00040     {
00041         friend class XMLIterator;
00042 
00043       public:
00044 
00045         XMLHelper();
00046         virtual ~XMLHelper();
00047 
00048         void 
00049         parse_from_url(
00050             const IT_Bus::String& strURL
00051         );
00052         
00053         void 
00054         parse_from_file(
00055             const IT_Bus::String& strFile
00056         );
00057 
00058         void 
00059         parse(
00060             const IT_Bus::BinaryBuffer& vvInputBuffer
00061         );
00062         
00063         void 
00064         serialize(
00065             IT_Bus::BinaryBuffer& vvOutputBuffer
00066         ) const;
00067 
00068         void 
00069         clear();
00070 
00071         operator IT_Bus::String() const;
00072 
00073         void 
00074         set_root_name(
00075             IT_Bus::String Name
00076         );
00077 
00078         IT_Bus::String 
00079         get_root_name();
00080         
00081         bool 
00082         is_root_name(
00083             IT_Bus::String Name
00084         );
00085 
00086         bool 
00087         is_empty();
00088 
00089         void 
00090         add_field(
00091             IT_Bus::String FieldName, 
00092             IT_Bus::String FieldValue
00093         );
00094 
00095         void 
00096         add_field(
00097             IT_Bus::String FieldName
00098         );
00099 
00100         IT_Bus::String 
00101         get_field_as_string(
00102             IT_Bus::String FieldName
00103         ) const;
00104 
00105         void 
00106         set_field_as_string(
00107             IT_Bus::String FieldName, 
00108             IT_Bus::String& FieldValue
00109         );
00110 
00111         const 
00112         IT_Bus::String& 
00113         get_wsdl_location_as_string() const;
00114 
00115         void 
00116         set_wsdl_location_as_string(
00117             const IT_Bus::String& strURL
00118         );
00119 
00120         // REVISIT: Internal use. May change in future.
00121         //
00122         void 
00123         set_entity_resolver(
00124             EntityResolverBase * entityResolverBase
00125         );
00126 
00127         xercesc_2_4::DOMElement *
00128         GetCurrentElement();
00129 
00130         const xercesc_2_4::DOMElement *
00131         GetCurrentElement() const;
00132 
00133       private:
00134 
00135         xercesc_2_4::XercesDOMParser*   m_parser;
00136         IT_Bus::String                  m_wsdl_location; 
00137         IT_Bus::EntityResolverBase      * m_entity_resolver_base; 
00138     };
00139 
00140     class IT_BUS_XML_API XMLIterator
00141     {
00142       public:
00143 
00144         XMLIterator(
00145             XMLHelper& XMLHelper
00146         );
00147 
00148         XMLIterator(
00149             const XMLIterator& Iterator
00150         );
00151 
00152         XMLIterator& 
00153         operator=(
00154             const XMLIterator& Iterator
00155         );
00156 
00157         virtual 
00158         ~XMLIterator();
00159 
00160         bool
00161         move_down();
00162 
00163         bool
00164         move_up();
00165 
00166         bool
00167         move_next();
00168 
00169         bool
00170         move_previous();
00171 
00172         bool
00173         move_first();
00174 
00175         bool
00176         move_last();
00177 
00178         bool 
00179         move_depth_first();
00180 
00181         bool 
00182         move_same_first();
00183 
00184         bool 
00185         move_same_previous();
00186 
00187         bool 
00188         move_same_next();
00189 
00190         bool 
00191         move_same_last();
00192 
00193         const IT_Bus::String &
00194         get_tag_name() const;
00195 
00196         bool 
00197         find_namespace(
00198             const char* szNamespace, 
00199             xercesc_2_4::DOMElement * & elm
00200         );
00201 
00202         bool 
00203         set_namespace(
00204             IT_Bus::String strNamespace
00205         );
00206 
00207         bool 
00208         set_sub_namespace(
00209             IT_Bus::String strNamespace
00210         );
00211 
00212         void 
00213         add_namespace(
00214             IT_Bus::String strNamespace
00215         );
00216 
00217         void 
00218         add_sub_namespace(
00219             IT_Bus::String strSubNamespace
00220         );
00221 
00222         long 
00223         get_count() const;
00224 
00225         void 
00226         get_nv_pair(
00227             long lIndex, 
00228             IT_Bus::String& strName, 
00229             IT_Bus::String& strValue
00230         ) const;
00231 
00232         IT_Bus::String 
00233         get_field_as_string(
00234             IT_Bus::String strFieldName
00235         ) const;
00236 
00237         void 
00238         set_field_as_string(
00239             IT_Bus::String strFieldName, 
00240             IT_Bus::String FieldValue
00241         );
00242 
00243         void 
00244         set_field(
00245             IT_Bus::String strFieldName, 
00246             IT_Bus::BinaryBuffer& FieldValue
00247         );
00248 
00249         void 
00250         serialize(
00251             IT_Bus::BinaryBuffer& vvOutputBuffer
00252         ) const;
00253 
00254         void 
00255         serialize(
00256             IT_Bus::BinaryBuffer& vvOutputBuffer,
00257             IT_Bus::Boolean is_root
00258         ) const;
00259 
00260         void 
00261         serialize_element(
00262             IT_Bus::BinaryBuffer& vvOutputBuffer,
00263             IT_Bus::Boolean is_root
00264         ) const;
00265 
00266         void 
00267         serialize_element(
00268             IT_Bus::BinaryBuffer& vvOutputBuffer,
00269             const IT_Bus::String & location,
00270             IT_Bus::Boolean is_root
00271         ) const;
00272 
00273         operator IT_Bus::String() const;
00274 
00275         void 
00276         add_new();
00277 
00278         long 
00279         get_element_count();
00280 
00281         long 
00282         get_sub_element_count() const;
00283 
00284         void 
00285         get_sub_element(
00286             long dwIndex, 
00287             XMLIterator& iterSubElement
00288         ) const;
00289 
00290         IT_Bus::String 
00291         get_element_value() const;
00292 
00293         XMLHelper& 
00294         get_xml_helper() const;
00295 
00296       private: 
00297 
00298         XMLHelper&                  m_xml_helper;
00299         xercesc_2_4::DOMElement*    m_elm_parent;
00300         xercesc_2_4::DOMElement*    m_elm;
00301         IT_Bus::String              m_tag_name;
00302         IT_Bus::String              m_full_name;
00303         long                        m_same_element_index;
00304         long                        m_node_index;
00305     };
00306 }
00307 
00308 IT_Bus::String 
00309 IT_BUS_XML_API 
00310 it_format_for_display(
00311     IT_Bus::XMLIterator iterData, 
00312     long dwIndentLevel = 0
00313 );
00314 
00315 #endif /*_IT_XML_HELPER_*/

Generated on Tue Mar 20 15:27:53 2007 for Artix by  doxygen 1.5.1-p1