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 #ifndef _terimber_xmlimpl_h_
00029 #define _terimber_xmlimpl_h_
00030
00031 #include "allinc.h"
00032 #include "xml/xmlaccss.h"
00033 #include "xml/sxml.h"
00034 #include "xml/storexml.h"
00035
00036 #include "base/common.h"
00037
00038 BEGIN_TERIMBER_NAMESPACE
00039 #pragma pack(4)
00040
00043 class xml_designer_impl : public xml_designer
00044 {
00045 public:
00047 xml_designer_impl(size_t xml_size
00048 );
00050 virtual
00051 ~xml_designer_impl();
00060
00061 virtual
00062 bool
00063 load( const char* name,
00064 const char* grammar
00065 );
00068 virtual
00069 bool
00070 load( const void* buffer,
00071 size_t length,
00072 const char* grammar
00073 );
00076 virtual
00077 bool
00078 load( const char* name,
00079 const void* grammar,
00080 size_t grammar_length
00081 );
00084 virtual
00085 bool
00086 load( const void* buffer,
00087 size_t length,
00088 const void* grammar,
00089 size_t grammar_length
00090 );
00092 virtual
00093 const char*
00094 error() const;
00096 virtual
00097 void
00098 select_document() const;
00100 virtual
00101 bool
00102 select_root() const;
00104 virtual
00105 bool
00106 has_children() const;
00108 virtual
00109 bool
00110 select_first_child() const;
00112 virtual
00113 bool
00114 select_last_child() const;
00116 virtual
00117 bool
00118 select_parent() const;
00121 virtual
00122 bool
00123 has_attributes() const;
00125 virtual
00126 bool
00127 select_first_attribute() const;
00129 virtual
00130 bool
00131 select_last_attribute() const;
00133 virtual
00134 bool
00135 select_attribute_by_name(const char* name
00136 ) const;
00139 virtual
00140 bool
00141 select_next_sibling() const;
00144 virtual
00145 bool
00146 select_prev_sibling() const;
00149 virtual
00150 xmlNodeType
00151 get_type() const;
00157 virtual
00158 const char*
00159 get_name() const;
00167 virtual
00168 const char*
00169 get_value() const;
00173 virtual
00174 const char*
00175 get_xpath() const;
00177 virtual
00178 bool
00179 select_xpath( const char* path
00180 ) const;
00183 virtual
00184 bool
00185 save( const char* name,
00186 bool add_doc_type
00187 ) const;
00191 virtual
00192 bool
00193 save( void* buffer,
00194 size_t& length,
00195 bool add_doc_type
00196 ) const;
00202 virtual
00203 bool
00204 add_child( xmlNodeType type,
00205 const char* name,
00206 const char* value,
00207 bool dont_move
00208 );
00210 virtual
00211 bool
00212 insert_sibling( xmlNodeType type,
00213 const char* name,
00214 const char* value,
00215 bool dont_move
00216 );
00218 virtual
00219 bool
00220 append_sibling( xmlNodeType type,
00221 const char* name,
00222 const char* value,
00223 bool dont_move
00224 );
00226 virtual
00227 bool
00228 remove_node();
00233 virtual
00234 bool
00235 update_value( const char* value
00236 );
00237
00239
00240 virtual
00241 bool merge( const xml_designer* x,
00242 bool recursive
00243 );
00245 virtual
00246 bool
00247 validate( bool recursive
00248 );
00249 protected:
00251 inline
00252 xmlNodeType get_cur_type() const;
00254 inline
00255 bool is_attribute() const;
00257 inline
00258 bool is_element() const;
00260 inline
00261 bool is_container() const;
00262
00263 private:
00265 bool
00266 _import_node( xmlNodeType type,
00267 const char* name,
00268 const char* value,
00269 bool sibling,
00270 bool after,
00271 bool dont_move
00272 );
00274 void
00275 _validate( xml_element* el,
00276 bool recursive
00277 );
00279 bool
00280 _load( byte_source* stream,
00281 byte_source* grammar
00282 );
00283
00284 private:
00285 size_t _xml_size;
00286 mutable mem_pool_t _small_manager;
00287 mutable mem_pool_t _big_manager;
00288 mutable byte_allocator* _tmp_allocator;
00289 xml_document _doc;
00290 mutable string_t _error;
00291 mutable xml_tree_node* _cur_node;
00292 };
00293
00296 class xml_parser_creator : public proto_creator< xml_parser_creator, xml_designer, size_t >
00297 {
00298 public:
00300 xml_parser_creator();
00302 xml_designer*
00303 create( size_t n
00304 );
00306 void destroy( xml_designer* obj
00307 );
00308 private:
00309 xml_factory _factory;
00310 };
00311
00314 typedef smart_pointer< xml_parser_creator > xml_designer_keeper_t;
00315
00318 class xml_designer_creator : public proto_creator< xml_designer_creator, xml_designer, size_t >
00319 {
00320 public:
00322 static
00323 xml_designer*
00324 create( size_t size
00325 );
00327 static
00328 void
00329 activate( xml_designer* obj,
00330 size_t
00331 );
00332 };
00333
00336 typedef pool< xml_designer_creator > xml_pool_t;
00337
00338
00339 #pragma pack()
00340 END_TERIMBER_NAMESPACE
00341
00342 #endif // _terimber_xmlimpl_h_
00343
00344