Thread portable class


Gate portable class


Timer class


Pool class


Terimber 2.0


About C++


Downloads Products & Services Support Clients Open Source About



Home / Open source / Terimber 2.0

xml_document Class Reference

xml document class as a root class for xml document structure More...

#include <sxml.h>

Inheritance diagram for xml_document:

xml_container xml_grammar xml_tree_node xml_node

List of all members.

Public Member Functions

 xml_document (mem_pool_t &small_manager, mem_pool_t &big_manager, size_t xml_size, const xml_grammar *grammar)
 constructor
 ~xml_document ()
 destructor
content_interfacefind_model (const elementDecl *decl)
 finds validation model by element declaration
void add_model (const elementDecl *decl, content_interface *model)
 adds validation model for element declaration
xml_forceinline byte_allocatorget_data_allocator ()
 returns data allocator
xml_forceinline byte_allocatorget_model_allocator ()
 returns model allocator
xml_forceinline byte_allocatorget_tmp_allocator ()
 returns temporary allocator
xml_forceinline mem_pool_tget_small_manager ()
 returns small memory pool
xml_forceinline mem_pool_tget_big_manager ()
 retunrs big memory pool
xml_forceinline bool is_on_fly () const
 checks if grammar is built on the fly
xml_forceinline xml_elementget_root_element ()
 gets root element
xml_forceinline const xml_elementget_root_element () const
 gets const root element
void add_escaped_symbols ()
 adds xml escaped symbols to the internal map
xml_forceinline const string_tget_doc_name () const
 gets document name
bool set_doc_name (const char *name)
 sets document name
bool check_root ()
 checks if root is detected
void clear ()
 clears internal resources
void clear_root ()
 clears root
void container_reset ()
 resets stack container
void container_push (xml_element *el)
 push new element to the stack
xml_elementcontainer_pop ()
 removes element from the stack
bool container_peak ()
 checks if element stack is not empty
void container_start_doctype ()
 adds to the stack DTD node
void container_stop_doctype ()
 removes from the stack DTD node
void validate (xml_element &el)
 validates element according to the provided document grammar
xml_forceinline void add_entity_desc (const entityDecl &decl)
 adds entity node declaration to the grammar
xml_forceinline void add_notation_desc (const notationDecl &decl)
 adds notation node declaration to the grammar
xml_forceinline void add_element_desc (const elementDecl &decl)
 adds element node declaration to the grammar
xml_forceinline xml_value_nodeadd_comment (const char *value, xml_tree_node *sibling=0, bool after=true)
 adds comment to the document
xml_forceinline xml_value_nodeadd_cdata (const char *value, xml_tree_node *sibling=0, bool after=true)
 adds cdata to the document
xml_forceinline xml_value_nodeadd_pi (const char *name, const char *value, xml_tree_node *sibling=0, bool after=true)
 adds pi to the document
xml_forceinline xml_value_nodeadd_text (const char *value, xml_tree_node *sibling=0, bool after=true)
 adds text node to the list document
xml_elementadd_element (const char *name, xml_tree_node *sibling=0, bool after=true)
 adds element to the document
xml_value_nodeadd_attribute (xml_element &el, const char *name, const char *value, xml_tree_node *sibling=0, bool after=true)
 adds attribute to the document
void update_attribute (xml_element *el, xml_value_node *att, const char *value)
 updates attribute value
void add_def_attributes (xml_element &el, attr_states_map_t &attrStates)
 adds default attributes if they aren't in the parsing document
terimber_xml_value find_attribute_value (const xml_element &el, const char *name) const
 finds attribute value by attribute name if not assigned returns default value (be careful, value allocated on temporary allocator) if not found return empty xml value
xml_value_nodefind_attribute (const xml_element &el, const char *name)
 finds attribute by name, if not returns NULL

Public Attributes

size_t _standalone
 standalone flag

Private Member Functions

void validate_attributes (xml_element &el)
 validates attributes according to the provided document grammar
void validate_children (xml_element &el)
 validates children nodes according to the provided document grammar
void assign_attribute_value (xml_element &el, const attributeDecl &attr_decl, xml_value_node *att, const char *value)
 assigns attribute value

Private Attributes

xml_container_stack_t _container_stack
 stack of xml containers
byte_allocator _model_allocator
 validation model allocator
xml_container_stack_allocator_t _stack_allocator
 stack allocator
bool _on_fly
 building grammar on the fly flag
model_map_t _model_map
 model map
xml_element _root
 root element
xml_container _doc_type
 DTD container.


Detailed Description

xml document class as a root class for xml document structure

Definition at line 285 of file sxml.h.


Constructor & Destructor Documentation

xml_document::xml_document ( mem_pool_t small_manager,
mem_pool_t big_manager,
size_t  xml_size,
const xml_grammar grammar 
)

constructor

Parameters:
small_manager  small memory pool
big_manager  big memory pool
xml_size  xml size - just a tip
grammar  optional external xml grammar

Definition at line 135 of file sxml.cpp.

References xml_node::_decl, xml_grammar::_doc_name, exception::_throw(), container_reset(), xml_grammar::copy(), and xml_grammar::find_element_decl().

xml_document::~xml_document (  ) 

destructor

Definition at line 158 of file sxml.cpp.


Member Function Documentation

content_interface * xml_document::find_model ( const elementDecl decl  ) 

finds validation model by element declaration

Parameters:
decl  pointer to the element declaration

Definition at line 218 of file sxml.cpp.

References _model_map, base_map< K, T, Pr, M >::end(), and base_map< K, T, Pr, M >::find().

Referenced by validate_children().

void xml_document::add_model ( const elementDecl decl,
content_interface model 
)

adds validation model for element declaration

Parameters:
decl  pointer to the element declaration
model  pointer to the validation model

Definition at line 225 of file sxml.cpp.

References _model_allocator, _model_map, base_map< K, T, Pr, M >::end(), base_map< K, T, Pr, M >::find(), _map< K, T, A, Pr, M >::insert(), and xml_exception_throw().

Referenced by validate_children().

xml_forceinline byte_allocator & xml_document::get_data_allocator (  ) 

returns data allocator

Reimplemented from xml_grammar.

Definition at line 334 of file sxml.hpp.

References xml_grammar::_data_allocator.

Referenced by xml_designer_impl::update_value().

xml_forceinline byte_allocator & xml_document::get_model_allocator (  ) 

xml_forceinline byte_allocator & xml_document::get_tmp_allocator (  ) 

returns temporary allocator

Reimplemented from xml_grammar.

Definition at line 348 of file sxml.hpp.

References xml_grammar::_tmp_allocator.

Referenced by xml_processor::parseElement(), xml_processor::parseMisc(), xml_processor::parseProlog(), and dtd_processor::parseSubSet().

xml_forceinline mem_pool_t & xml_document::get_small_manager (  ) 

returns small memory pool

Definition at line 355 of file sxml.hpp.

References xml_grammar::_small_manager.

xml_forceinline mem_pool_t & xml_document::get_big_manager (  ) 

retunrs big memory pool

Definition at line 362 of file sxml.hpp.

References xml_grammar::_big_manager.

xml_forceinline bool xml_document::is_on_fly (  )  const

checks if grammar is built on the fly

Definition at line 376 of file sxml.hpp.

References _on_fly.

Referenced by add_attribute(), xml_processor::parseAttributes(), xml_processor::parseDocTypeDecl(), and xml_persistor::persistDocType().

xml_forceinline xml_element & xml_document::get_root_element (  ) 

gets root element

Definition at line 383 of file sxml.hpp.

References _root.

Referenced by xml_designer_impl::merge(), xml_processor::parseDocument(), and xml_designer_impl::select_root().

xml_forceinline const xml_element & xml_document::get_root_element (  )  const

gets const root element

Definition at line 390 of file sxml.hpp.

References _root.

void xml_document::add_escaped_symbols (  ) 

xml_forceinline const string_t & xml_document::get_doc_name (  )  const

gets document name

Definition at line 369 of file sxml.hpp.

References xml_grammar::_doc_name.

Referenced by xml_designer_impl::get_name().

bool xml_document::set_doc_name ( const char *  name  ) 

sets document name

Parameters:
name  document name

Definition at line 772 of file sxml.cpp.

References xml_node::_decl, xml_grammar::_doc_name, _on_fly, _root, and base_string< T >::length().

Referenced by add_element(), and xml_processor::parseDocTypeDecl().

bool xml_document::check_root (  ) 

void xml_document::clear_root (  ) 

clears root

Definition at line 806 of file sxml.cpp.

References xml_grammar::_doc_name, xml_tree_node::_parent, _root, and xml_element::clear().

Referenced by xml_designer_impl::remove_node().

void xml_document::container_reset (  ) 

resets stack container

element stack function

Definition at line 814 of file sxml.cpp.

References _container_stack, _stack_allocator, base_stack< T >::clear(), rep_allocator::clear_extra(), and _stack< T, A >::push().

Referenced by clear(), xml_processor::parse(), and xml_document().

void xml_document::container_push ( xml_element el  ) 

push new element to the stack

Parameters:
el  pointeher to the element

Definition at line 822 of file sxml.cpp.

References _container_stack, _stack_allocator, and _stack< T, A >::push().

Referenced by xml_designer_impl::_import_node(), and xml_processor::parseStartTag().

xml_element * xml_document::container_pop (  ) 

bool xml_document::container_peak (  ) 

checks if element stack is not empty

Definition at line 855 of file sxml.cpp.

References _container_stack, xml_node::_decl, and base_stack< T >::top().

Referenced by xml_processor::parseDocument(), and xml_processor::parseElement().

void xml_document::container_start_doctype (  ) 

void xml_document::container_stop_doctype (  ) 

removes from the stack DTD node

Definition at line 835 of file sxml.cpp.

References _on_fly, and container_pop().

Referenced by xml_designer_impl::_load(), and xml_processor::parseDocTypeDecl().

void xml_document::validate ( xml_element el  ) 

validates element according to the provided document grammar

Parameters:
el  element to validate

Definition at line 235 of file sxml.cpp.

References validate_attributes(), and validate_children().

Referenced by xml_designer_impl::_validate(), xml_processor::parseEndTag(), and xml_processor::parseStartTag().

xml_forceinline void xml_document::add_entity_desc ( const entityDecl decl  ) 

adds entity node declaration to the grammar

Parameters:
decl  entity node declaration

Definition at line 467 of file sxml.hpp.

References _container_stack, xml_grammar::_data_allocator, xml_container::add_node(), byte_allocator::allocate(), check_pointer(), base_stack< T >::top(), and xml_tree_node::xml_tree_node().

Referenced by dtd_processor::parseEntity().

xml_forceinline void xml_document::add_notation_desc ( const notationDecl decl  ) 

adds notation node declaration to the grammar

Parameters:
decl  notation node declaration

Definition at line 479 of file sxml.hpp.

References _container_stack, xml_grammar::_data_allocator, xml_container::add_node(), byte_allocator::allocate(), check_pointer(), base_stack< T >::top(), and xml_tree_node::xml_tree_node().

xml_forceinline void xml_document::add_element_desc ( const elementDecl decl  ) 

adds element node declaration to the grammar

Parameters:
decl  element node declaration

Definition at line 491 of file sxml.hpp.

References _container_stack, xml_grammar::_data_allocator, xml_container::add_node(), byte_allocator::allocate(), check_pointer(), base_stack< T >::top(), and xml_tree_node::xml_tree_node().

Referenced by dtd_processor::parseElement().

xml_forceinline xml_value_node * xml_document::add_comment ( const char *  value,
xml_tree_node sibling = 0,
bool  after = true 
)

xml_forceinline xml_value_node * xml_document::add_cdata ( const char *  value,
xml_tree_node sibling = 0,
bool  after = true 
)

xml_forceinline xml_value_node * xml_document::add_pi ( const char *  name,
const char *  value,
xml_tree_node sibling = 0,
bool  after = true 
)

xml_forceinline xml_value_node * xml_document::add_text ( const char *  value,
xml_tree_node sibling = 0,
bool  after = true 
)

xml_value_node * xml_document::add_attribute ( xml_element el,
const char *  name,
const char *  value,
xml_tree_node sibling = 0,
bool  after = true 
)

void xml_document::update_attribute ( xml_element el,
xml_value_node att,
const char *  value 
)

updates attribute value

Parameters:
el  element node
att  attribute node
value  new attribute value

Definition at line 716 of file sxml.cpp.

References assign_attribute_value(), and xml_node::cast_to_attribute().

Referenced by xml_designer_impl::update_value().

void xml_document::add_def_attributes ( xml_element el,
attr_states_map_t attrStates 
)

adds default attributes if they aren't in the parsing document

Parameters:
el  element
attrStates  attribute states map

Definition at line 723 of file sxml.cpp.

References attributeDecl::_defval, namedNode::_name, attributeDecl::_rule, add_attribute(), ATTR_RULE_DEFAULT, ATTR_RULE_FIXED, ATTR_RULE_REQUIRED, base_map< K, T, Pr, M >::begin(), base_map< K, T, Pr, M >::end(), and base_string< T >::length().

Referenced by xml_processor::parseAttributes().

terimber_xml_value xml_document::find_attribute_value ( const xml_element el,
const char *  name 
) const

finds attribute value by attribute name if not assigned returns default value (be careful, value allocated on temporary allocator) if not found return empty xml value

Parameters:
el  element
name  attribute name

Definition at line 749 of file sxml.cpp.

References xml_element::_first_attr, xml_tree_node::_right, xml_value_node::_value, xml_element::cast_decl(), xml_value_node::cast_to_node_value(), and xml_grammar::find_attribute_decl().

xml_value_node * xml_document::find_attribute ( const xml_element el,
const char *  name 
)

finds attribute by name, if not returns NULL

Parameters:
el  element
name  attribute name

Definition at line 760 of file sxml.cpp.

References xml_element::_first_attr, xml_tree_node::_right, xml_element::cast_decl(), xml_value_node::cast_to_node_value(), and xml_grammar::find_attribute_decl().

void xml_document::validate_children ( xml_element el  )  [private]


Member Data Documentation

validation model allocator

Definition at line 482 of file sxml.h.

Referenced by add_model(), clear(), get_model_allocator(), and validate_children().

bool xml_document::_on_fly [private]

building grammar on the fly flag

Definition at line 484 of file sxml.h.

Referenced by add_element(), check_root(), clear(), container_stop_doctype(), is_on_fly(), and set_doc_name().

model map

Definition at line 485 of file sxml.h.

Referenced by add_model(), clear(), and find_model().

root element

Definition at line 486 of file sxml.h.

Referenced by add_element(), check_root(), clear(), clear_root(), get_root_element(), and set_doc_name().

DTD container.

Definition at line 487 of file sxml.h.

Referenced by clear(), and container_start_doctype().


The documentation for this class was generated from the following files:


© Copyright Terimber 2003-.