Home / Open source / Terimber 2.0
xml_document Class Referencexml document class as a root class for xml document structure
More...
#include <sxml.h>
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_interface * | find_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_allocator & | get_data_allocator () |
| returns data allocator
|
xml_forceinline byte_allocator & | get_model_allocator () |
| returns model allocator
|
xml_forceinline byte_allocator & | get_tmp_allocator () |
| returns temporary allocator
|
xml_forceinline mem_pool_t & | get_small_manager () |
| returns small memory pool
|
xml_forceinline mem_pool_t & | get_big_manager () |
| retunrs big memory pool
|
xml_forceinline bool | is_on_fly () const |
| checks if grammar is built on the fly
|
xml_forceinline xml_element & | get_root_element () |
| gets root element
|
xml_forceinline const xml_element & | get_root_element () const |
| gets const root element
|
void | add_escaped_symbols () |
| adds xml escaped symbols to the internal map
|
xml_forceinline const string_t & | get_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_element * | container_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_node * | add_comment (const char *value, xml_tree_node *sibling=0, bool after=true) |
| adds comment to the document
|
xml_forceinline xml_value_node * | add_cdata (const char *value, xml_tree_node *sibling=0, bool after=true) |
| adds cdata to the document
|
xml_forceinline xml_value_node * | add_pi (const char *name, const char *value, xml_tree_node *sibling=0, bool after=true) |
| adds pi to the document
|
xml_forceinline xml_value_node * | add_text (const char *value, xml_tree_node *sibling=0, bool after=true) |
| adds text node to the list document
|
xml_element * | add_element (const char *name, xml_tree_node *sibling=0, bool after=true) |
| adds element to the document
|
xml_value_node * | add_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_node * | find_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 |
( |
|
) |
|
Member Function Documentation
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_model_allocator |
( |
|
) |
|
xml_forceinline mem_pool_t & xml_document::get_small_manager |
( |
|
) |
|
xml_forceinline mem_pool_t & xml_document::get_big_manager |
( |
|
) |
|
xml_forceinline bool xml_document::is_on_fly |
( |
|
) |
const |
xml_forceinline xml_element & xml_document::get_root_element |
( |
|
) |
|
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 |
( |
|
) |
|
adds xml escaped symbols to the internal map
Definition at line 188 of file sxml.cpp.
References entityDecl::_is_encoded_char, entityDecl::_value, xml_grammar::add_entity_decl(), str_amp, str_apos, str_ch_amp, str_ch_apos, str_ch_gt, str_ch_lt, str_ch_quote, str_gt, str_lt, and str_quote.
Referenced by xml_designer_impl::_load(), and xml_processor::parse().
xml_forceinline const string_t & xml_document::get_doc_name |
( |
|
) |
const |
bool xml_document::set_doc_name |
( |
const char * |
name |
) |
|
bool xml_document::check_root |
( |
|
) |
|
void xml_document::clear |
( |
|
) |
|
clears internal resources
Reimplemented from xml_container.
Definition at line 163 of file sxml.cpp.
References xml_grammar::_data_allocator, xml_node::_decl, _doc_type, xml_grammar::_doctype_decl, _model_allocator, _model_map, _on_fly, xml_tree_node::_parent, _root, _standalone, xml_grammar::_tmp_allocator, xml_element::clear(), xml_grammar::clear(), xml_container::clear(), base_map< K, T, Pr, M >::clear(), byte_allocator::clear_extra(), container_reset(), xml_grammar::get_document_decl(), and os_minus_one.
Referenced by xml_designer_impl::_load().
void xml_document::clear_root |
( |
|
) |
|
void xml_document::container_reset |
( |
|
) |
|
bool xml_document::container_peak |
( |
|
) |
|
void xml_document::container_start_doctype |
( |
|
) |
|
void xml_document::container_stop_doctype |
( |
|
) |
|
xml_forceinline void xml_document::add_entity_desc |
( |
const entityDecl & |
decl |
) |
|
xml_forceinline void xml_document::add_notation_desc |
( |
const notationDecl & |
decl |
) |
|
xml_forceinline void xml_document::add_element_desc |
( |
const elementDecl & |
decl |
) |
|
adds comment to the document
- Parameters:
-
value |
comment text |
sibling |
optional sibling node |
after |
optional insertion flag |
Definition at line 400 of file sxml.hpp.
References xml_grammar::_comment_decl, _container_stack, xml_grammar::_data_allocator, xml_value_node::_value, xml_container::add_node(), byte_allocator::allocate(), xml_container::append_node(), check_pointer(), xml_container::insert_node(), _terimber_xml_value_::strVal, and base_stack< T >::top().
Referenced by xml_designer_impl::_import_node(), and byte_manager::parseComment().
adds cdata to the document
- Parameters:
-
value |
CDATA text |
sibling |
optional sibling node |
after |
optional insertion flag |
Definition at line 415 of file sxml.hpp.
References xml_grammar::_cdata_decl, _container_stack, xml_grammar::_data_allocator, xml_value_node::_value, xml_container::add_node(), byte_allocator::allocate(), xml_container::append_node(), check_pointer(), xml_container::insert_node(), _terimber_xml_value_::strVal, and base_stack< T >::top().
Referenced by xml_designer_impl::_import_node(), and xml_processor::parseCDATA().
xml_forceinline xml_value_node * xml_document::add_pi |
( |
const char * |
name, |
|
|
const char * |
value, |
|
|
xml_tree_node * |
sibling = 0 , |
|
|
bool |
after = true | |
|
) |
| | |
adds pi to the document
- Parameters:
-
name |
PI name |
value |
PI value |
sibling |
optional sibling node |
after |
optional insertion flag |
Definition at line 430 of file sxml.hpp.
References _container_stack, xml_grammar::_data_allocator, exception::_throw(), xml_value_node::_value, xml_container::add_node(), xml_grammar::add_pi_decl(), byte_allocator::allocate(), xml_container::append_node(), check_pointer(), xml_container::insert_node(), os_minus_one, str_xml, str_template::strnocasecmp(), _terimber_xml_value_::strVal, and base_stack< T >::top().
Referenced by xml_designer_impl::_import_node(), and byte_manager::parsePI().
adds text node to the list document
- Parameters:
-
value |
Text value |
sibling |
optional sibling node |
after |
optional insertion flag |
Definition at line 452 of file sxml.hpp.
References _container_stack, xml_grammar::_data_allocator, xml_grammar::_text_decl, xml_value_node::_value, xml_container::add_node(), byte_allocator::allocate(), xml_container::append_node(), check_pointer(), xml_container::insert_node(), _terimber_xml_value_::strVal, and base_stack< T >::top().
Referenced by xml_designer_impl::_import_node(), and xml_processor::_parseCharData().
adds element to the document
- Parameters:
-
name |
element name |
sibling |
optional sibling node |
after |
optional insertion flag |
Definition at line 358 of file sxml.cpp.
References _container_stack, elementDecl::_content, xml_grammar::_data_allocator, xml_node::_decl, _on_fly, _root, exception::_throw(), elementDecl::_token, xml_grammar::add_element_decl(), xml_container::add_node(), byte_allocator::allocate(), xml_container::append_node(), xml_element::cast_decl(), xml_element::cast_to_element(), check_pointer(), check_root(), CONTENT_ANY, CONTENT_CHILDREN, dfa_token::find_any_resursively(), xml_container::insert_node(), set_doc_name(), and base_stack< T >::top().
Referenced by xml_designer_impl::_import_node(), and xml_processor::parseStartTag().
adds attribute to the document
- Parameters:
-
el |
xml element |
name |
attribute name |
value |
attribute value |
sibling |
optional sibling node |
after |
optional insertion flag |
Definition at line 399 of file sxml.cpp.
References xml_grammar::_data_allocator, xml_node::_decl, xml_element::_first_attr, namedNode::_name, xml_tree_node::_right, xml_element::add_attribute(), xml_grammar::add_attribute_decl(), byte_allocator::allocate(), xml_element::append_attribute(), assign_attribute_value(), xml_element::cast_decl(), check_pointer(), xml_element::insert_attribute(), is_on_fly(), and xml_exception_throw().
Referenced by xml_designer_impl::_import_node(), add_def_attributes(), and xml_processor::parseAttributes().
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().
void xml_document::validate_attributes |
( |
xml_element & |
el |
) |
[private] |
validates attributes according to the provided document grammar
- Parameters:
-
Definition at line 242 of file sxml.cpp.
References elementDecl::_attributes, xml_node::_decl, xml_element::_first_attr, namedNode::_name, xml_tree_node::_right, xml_value_node::_value, ATTR_RULE_DEFAULT, ATTR_RULE_FIXED, ATTR_RULE_REQUIRED, ATTR_TYPE_CDATA, attributeRule_MAX, attributeRule_MIN, base_map< K, T, Pr, M >::begin(), xml_element::cast_decl(), xml_value_node::cast_to_node_value(), compare_value(), base_map< size_t, attributeDecl, less< size_t >, M >::const_iterator, base_map< K, T, Pr, M >::end(), xml_element::has_attributes(), _terimber_xml_value_::strVal, and xml_exception_throw().
Referenced by validate().
void xml_document::validate_children |
( |
xml_element & |
el |
) |
[private] |
validates children nodes according to the provided document grammar
- Parameters:
-
Definition at line 303 of file sxml.cpp.
References elementDecl::_content, xml_node::_decl, _model_allocator, namedNode::_name, elementDecl::_token, add_model(), byte_allocator::allocate(), xml_element::cast_decl(), check_pointer(), CONTENT_ANY, CONTENT_CHILDREN, CONTENT_EMPTY, CONTENT_MIXED, contentSpec_MAX, contentSpec_MIN, find_model(), xml_container::has_children(), content_interface::validate(), and xml_exception_throw().
Referenced by validate().
assigns attribute value
- Parameters:
-
el |
element |
attr_decl |
attribute declaration |
att |
attribute node |
value |
attribute value |
Definition at line 422 of file sxml.cpp.
References attributeDecl::_atype, attributeDecl::_ctype, xml_grammar::_data_allocator, xml_node::_decl, attributeRefDecl::_declared, attributeDecl::_enum, entityDecl::_is_in_subset, namedNode::_name, attributeRefDecl::_refered, xml_grammar::_tmp_allocator, entityDecl::_value, xml_value_node::_value, xml_grammar::add_reference_decl(), byte_allocator::allocate(), ATTR_TYPE_CDATA, ATTR_TYPE_ENTITIES, ATTR_TYPE_ENTITY, ATTR_TYPE_ENUMERATION, ATTR_TYPE_ID, ATTR_TYPE_IDREF, ATTR_TYPE_IDREFS, ATTR_TYPE_NMTOKEN, ATTR_TYPE_NMTOKENS, ATTR_TYPE_NOTATION, attributeType_MAX, attributeType_MIN, base_list< T >::begin(), xml_node::cast_to_attribute(), ch_null, ch_space, copy_string(), base_list< T >::empty(), base_list< T >::end(), xml_grammar::find_entity_decl(), xml_grammar::find_notation_decl(), xml_grammar::find_reference_decl(), is_name_char(), is_name_first_char(), base_string< T >::length(), _terimber_xml_value_::lVal, os_minus_one, parse_value(), str_template::strcmp(), _terimber_xml_value_::strVal, tokenValues(), and xml_exception_throw().
Referenced by add_attribute(), and update_attribute().
Member Data Documentation
stack of xml containers
Definition at line 481 of file sxml.h.
Referenced by add_cdata(), add_comment(), add_element(), add_element_desc(), add_entity_desc(), add_notation_desc(), add_pi(), add_text(), container_peak(), container_pop(), container_push(), container_reset(), and container_start_doctype().
The documentation for this class was generated from the following files:
|
|