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_xmlmodel_h_
00029 #define _terimber_xmlmodel_h_
00030
00031 #include "xml/sxml.h"
00032 #include "base/bitset.h"
00033
00034 BEGIN_TERIMBER_NAMESPACE
00035 #pragma pack(4)
00036
00039 class content_node
00040 {
00041 public:
00043 virtual
00044 ~content_node() {}
00045
00047 content_node( dfaRule rule
00048 );
00049 inline
00050 void
00051 init( byte_allocator& allocator_,
00052 size_t sizeBit
00053 );
00055 inline
00056 dfaRule
00057 get_rule() const;
00059 inline
00060 const _bitset&
00061 get_firstPos() const;
00063 inline
00064 const _bitset&
00065 get_lastPos() const;
00066
00068 virtual
00069 bool
00070 is_nullable() const = 0;
00071 protected:
00073 virtual
00074 void
00075 calc_pos( _bitset& state,
00076 bool first
00077 ) const = 0;
00078
00079 protected:
00080 dfaRule _rule;
00081 size_t _max_states;
00082 _bitset _firstPos;
00083 _bitset _lastPos;
00084 };
00085
00088 class content_any : public content_node
00089 {
00090 public:
00092 virtual
00093 ~content_any() {}
00094
00096 content_any( dfaRule rule,
00097 size_t pos
00098 );
00100 inline
00101 size_t
00102 get_pos() const;
00104 virtual
00105 bool
00106 is_nullable() const;
00107
00108 protected:
00110 virtual
00111 void
00112 calc_pos( _bitset& state,
00113 bool
00114 ) const;
00115 private:
00116 size_t _pos;
00117 };
00118
00121 class content_leaf : public content_node
00122 {
00123 public:
00125 virtual
00126 ~content_leaf() {}
00127
00128 content_leaf( const elementDecl* decl,
00129 size_t pos
00130 );
00132 inline
00133 const
00134 elementDecl*
00135 get_decl() const;
00137 inline
00138 size_t
00139 get_pos() const;
00141 inline
00142 void
00143 set_pos( size_t pos
00144 );
00145
00147 virtual
00148 bool
00149 is_nullable() const;
00150
00151 protected:
00153 virtual
00154 void
00155 calc_pos( _bitset& state,
00156 bool
00157 ) const;
00158
00159 protected:
00160 const elementDecl* _decl;
00161 size_t _pos;
00162 };
00163
00166 class content_unary : public content_node
00167 {
00168 public:
00170 virtual
00171 ~content_unary() {}
00172
00174 content_unary( dfaRule rule,
00175 content_node* child
00176 );
00177
00179 inline
00180 content_node*
00181 get_child() const;
00183 virtual
00184 bool
00185 is_nullable() const;
00186 protected:
00188 virtual
00189 void
00190 calc_pos( _bitset& state,
00191 bool first
00192 ) const;
00193 private:
00194 content_node* _child;
00195 };
00196
00199 class content_binary : public content_node
00200 {
00201 public:
00203 virtual
00204 ~content_binary() {}
00205
00207 content_binary( dfaRule rule,
00208 content_node* left,
00209 content_node* right
00210 );
00212 inline
00213 content_node*
00214 get_left() const;
00216 inline
00217 content_node*
00218 get_right() const;
00219
00221 virtual
00222 bool
00223 is_nullable() const;
00224
00225 protected:
00227 virtual
00228 void
00229 calc_pos( _bitset& state,
00230 bool first
00231 ) const;
00232 private:
00233 content_node* _left;
00234 content_node* _right;
00235 };
00236
00239 class content_interface
00240 {
00241 public:
00243 virtual
00244 ~content_interface();
00246 virtual
00247 void
00248 validate( const xml_element& _el
00249 ) = 0;
00250 };
00251
00254 class content_mixed : public content_interface
00255 {
00256 public:
00258 content_mixed( const dfa_token* parent,
00259 byte_allocator& tmp_allocator
00260 );
00261
00263 void
00264 validate( const xml_element& _el
00265 );
00266 private:
00268 void
00269 build_mixed_list(const dfa_token* parent
00270 );
00271 private:
00272 byte_allocator& _tmp_allocator;
00273 _list< const dfa_token* > _listToken;
00274 };
00275
00278 class leaf_type
00279 {
00280 public:
00282 leaf_type();
00283 public:
00284 const elementDecl* _decl;
00285 dfaRule _rule;
00286 };
00287
00290 class content_children : public content_interface
00291 {
00292 public:
00294 content_children(const dfa_token* parent,
00295 byte_allocator& tmp_allocator
00296 );
00298 virtual
00299 void
00300 validate( const xml_element& el
00301 );
00302
00303 private:
00305 content_node*
00306 build_children_tree(const dfa_token* parent
00307 );
00309 size_t
00310 post_tree_build_init(content_node* nodeCur,
00311 size_t curIndex
00312 );
00314 void
00315 calc_follow_list(content_node* curNode
00316 );
00318 void
00319 build_dfa( const dfa_token* parent
00320 );
00322 inline
00323 void
00324 make_def_state_list(_vector< size_t >& x
00325 ) const;
00326 private:
00327 byte_allocator& _tmp_allocator;
00328 _vector< content_leaf* > _leafList;
00329 _vector< dfaRule > _leafListType;
00330 _vector< _bitset > _followList;
00331 size_t _leafCount;
00332 size_t _EOCPos;
00333 bool _emptyOk;
00334
00335 _vector< const elementDecl* > _elemMap;
00336 _vector< dfaRule > _elemMapType;
00337 size_t _elemMapSize;
00338 _vector< leaf_type > _leafNameTypeVector;
00339 _vector< _vector< size_t > > _transTable;
00340 size_t _transTableSize;
00341 _vector< bool > _finalStateFlags;
00342 };
00343
00344 #pragma pack()
00345 END_TERIMBER_NAMESPACE
00346
00347 #endif // _terimber_xmlmodel_h_