Home / Open source / Terimber 2.0
xml_designer_impl Class Referenceimplements abstract xml_designer interface
More...
#include <xmlimpl.h>
List of all members.
|
Public Member Functions |
| xml_designer_impl (size_t xml_size) |
| constructor
|
virtual | ~xml_designer_impl () |
| destructor
|
virtual bool | load (const char *name, const char *grammar) |
| load xml from file if the name is not null and the grammar is not null then parse external xml according to the provided external grammar if the name is not null and the grammar is null then parse external xml according to the internal grammar if specified if the name is null and the grammar is not null then parse external grammar and clear internal document if the name is null and the grammar is not null
|
virtual bool | load (const void *buffer, size_t length, const char *grammar) |
| loads xml from memory DTD data comes from file
|
virtual bool | load (const char *name, const void *grammar, size_t grammar_length) |
| loads xml from file DTD data comes from memory
|
virtual bool | load (const void *buffer, size_t length, const void *grammar, size_t grammar_length) |
| loads xml from memory DTD data comes from memory
|
virtual const char * | error () const |
| returns the last error
|
virtual void | select_document () const |
| resets navigator to the document
|
virtual bool | select_root () const |
| resets navigator to the root element
|
virtual bool | has_children () const |
| checks the presence of children
|
virtual bool | select_first_child () const |
| navigates to the next level looking for the first child
|
virtual bool | select_last_child () const |
| navigates to the next level looking for the last child
|
virtual bool | select_parent () const |
| navigates up a level
|
virtual bool | has_attributes () const |
| checks the attributes' presence
|
virtual bool | select_first_attribute () const |
| navigates to the first attribute
|
virtual bool | select_last_attribute () const |
| navigates to the last attribute
|
virtual bool | select_attribute_by_name (const char *name) const |
| navigates to the attribute by name
|
virtual bool | select_next_sibling () const |
| navigates through the same level go to the next node for attributes and nodes
|
virtual bool | select_prev_sibling () const |
| navigates through the same level go to the previous node for attributes and nodes
|
virtual xmlNodeType | get_type () const |
| returns type of the current node
|
virtual const char * | get_name () const |
| returns name of the current node text, comment, cdata - name == null element, attribute - name == name document, doc_type - document name processing instruction - name == target
|
virtual const char * | get_value () const |
| returns value of the current node for attributes this is an attribute value for element this is a text for processing instruction - instruction text for cdata, comment - text NB!!! value is allocated on temporary allocator char pointer will be valid until next function call
|
virtual const char * | get_xpath () const |
| returns the xpath (a/b/c format, where a root element c is current element) of the current node NB!!! value is allocated on temporary allocator char pointer will be valid until next function call
|
virtual bool | select_xpath (const char *path) const |
| global navigation looking for element specified according to format (a/b/c)
|
virtual bool | save (const char *name, bool add_doc_type) const |
| saves xml to file adding DTD is optional
|
virtual bool | save (void *buffer, size_t &length, bool add_doc_type) const |
| saves xml to memory adding DTD is optional if buffer is null, the function returns the required memory size through length
|
virtual bool | add_child (xmlNodeType type, const char *name, const char *value, bool dont_move) |
| add node as a child to the current node
|
virtual bool | insert_sibling (xmlNodeType type, const char *name, const char *value, bool dont_move) |
| inserts node before current node beneath the same parent
|
virtual bool | append_sibling (xmlNodeType type, const char *name, const char *value, bool dont_move) |
| appends node after current node beneath the same parent
|
virtual bool | remove_node () |
| removes the current node
|
virtual bool | update_value (const char *value) |
| updates the current node attribute value == value processing instruction value = text cdata, text, comment value == text
|
virtual bool | merge (const xml_designer *x, bool recursive) |
| adds beneath the current node an external xml fragment starting with the current node
|
virtual bool | validate (bool recursive) |
| validates the xml node accorging to the current grammar
|
Protected Member Functions |
xmlNodeType | get_cur_type () const |
| gets the selected node type
|
bool | is_attribute () const |
| checks if the selected node is an attribute
|
bool | is_element () const |
| checks if the selected node is an element
|
bool | is_container () const |
| checks if the selected node is a container (element or document)
|
Private Member Functions |
bool | _import_node (xmlNodeType type, const char *name, const char *value, bool sibling, bool after, bool dont_move) |
| inserts new xml node into document
|
void | _validate (xml_element *el, bool recursive) |
| validates element
|
bool | _load (byte_source *stream, byte_source *grammar) |
| parses xml document from abstract streams for xml and DTD sources
|
Private Attributes |
size_t | _xml_size |
| xml size - just a tip
|
mem_pool_t | _small_manager |
| small memory pool
|
mem_pool_t | _big_manager |
| big memory pool
|
byte_allocator * | _tmp_allocator |
| temporary allocator
|
xml_document | _doc |
| xml document
|
string_t | _error |
| last error
|
xml_tree_node * | _cur_node |
| selected node
|
Detailed Description
implements abstract xml_designer interface
Definition at line 43 of file xmlimpl.h.
Constructor & Destructor Documentation
BEGIN_TERIMBER_NAMESPACE xml_designer_impl::xml_designer_impl |
( |
size_t |
xml_size |
) |
|
xml_designer_impl::~xml_designer_impl |
( |
|
) |
[virtual] |
Member Function Documentation
bool xml_designer_impl::load |
( |
const char * |
name, |
|
|
const char * |
grammar | |
|
) |
| | [virtual] |
load xml from file if the name is not null and the grammar is not null then parse external xml according to the provided external grammar if the name is not null and the grammar is null then parse external xml according to the internal grammar if specified if the name is null and the grammar is not null then parse external grammar and clear internal document if the name is null and the grammar is not null
- Parameters:
-
name |
xml file name |
grammar |
external DTD file |
Implements xml_designer.
Definition at line 88 of file xmlimpl.cpp.
References _big_manager, _error, _load(), _small_manager, _xml_size, and stream_input_common::open().
Referenced by xmlconfig::xmlconfig().
bool xml_designer_impl::load |
( |
const void * |
buffer, |
|
|
size_t |
length, |
|
|
const char * |
grammar | |
|
) |
| | [virtual] |
bool xml_designer_impl::load |
( |
const char * |
name, |
|
|
const void * |
grammar, |
|
|
size_t |
grammar_length | |
|
) |
| | [virtual] |
bool xml_designer_impl::load |
( |
const void * |
buffer, |
|
|
size_t |
length, |
|
|
const void * |
grammar, |
|
|
size_t |
grammar_length | |
|
) |
| | [virtual] |
const char * xml_designer_impl::error |
( |
|
) |
const [virtual] |
void xml_designer_impl::select_document |
( |
|
) |
const [virtual] |
bool xml_designer_impl::select_root |
( |
|
) |
const [virtual] |
bool xml_designer_impl::has_children |
( |
|
) |
const [virtual] |
bool xml_designer_impl::select_first_child |
( |
|
) |
const [virtual] |
bool xml_designer_impl::select_last_child |
( |
|
) |
const [virtual] |
bool xml_designer_impl::select_parent |
( |
|
) |
const [virtual] |
bool xml_designer_impl::has_attributes |
( |
|
) |
const [virtual] |
bool xml_designer_impl::select_first_attribute |
( |
|
) |
const [virtual] |
bool xml_designer_impl::select_last_attribute |
( |
|
) |
const [virtual] |
bool xml_designer_impl::select_attribute_by_name |
( |
const char * |
name |
) |
const [virtual] |
bool xml_designer_impl::select_next_sibling |
( |
|
) |
const [virtual] |
bool xml_designer_impl::select_prev_sibling |
( |
|
) |
const [virtual] |
xmlNodeType xml_designer_impl::get_type |
( |
|
) |
const [virtual] |
const char * xml_designer_impl::get_name |
( |
|
) |
const [virtual] |
returns name of the current node text, comment, cdata - name == null element, attribute - name == name document, doc_type - document name processing instruction - name == target
Implements xml_designer.
Definition at line 335 of file xmlimpl.cpp.
References _cur_node, xml_node::_decl, _doc, namedNode::_name, ATTRIBUTE_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, get_cur_type(), xml_document::get_doc_name(), and PROCESSING_INSTRUCTION_NODE.
Referenced by xmlconfig::getlist(), xmlconfig::setlist(), and xmlconfig::xmlconfig().
const char * xml_designer_impl::get_value |
( |
|
) |
const [virtual] |
returns value of the current node for attributes this is an attribute value for element this is a text for processing instruction - instruction text for cdata, comment - text NB!!! value is allocated on temporary allocator char pointer will be valid until next function call
Implements xml_designer.
Definition at line 352 of file xmlimpl.cpp.
References _cur_node, _tmp_allocator, ATTRIBUTE_NODE, xml_node::cast_to_attribute(), xml_value_node::cast_to_node_value(), CDATA_SECTION_NODE, COMMENT_NODE, get_cur_type(), attributeDecl::persist_attribute(), persist_value(), PROCESSING_INSTRUCTION_NODE, byte_allocator::reset(), TEXT_NODE, and vt_string.
Referenced by xmlconfig::get(), xmlconfig::getlist(), and xmlconfig::setlist().
const char * xml_designer_impl::get_xpath |
( |
|
) |
const [virtual] |
returns the xpath (a/b/c format, where a root element c is current element) of the current node NB!!! value is allocated on temporary allocator char pointer will be valid until next function call
Implements xml_designer.
Definition at line 376 of file xmlimpl.cpp.
References _cur_node, xml_node::_decl, _doc, namedNode::_name, xml_tree_node::_parent, _tmp_allocator, byte_allocator::allocate(), base_list< T >::begin(), ch_forward_slash, base_list< T >::end(), is_element(), _list< T, A >::push_front(), and byte_allocator::reset().
bool xml_designer_impl::select_xpath |
( |
const char * |
path |
) |
const [virtual] |
global navigation looking for element specified according to format (a/b/c)
- Parameters:
-
Implements xml_designer.
Definition at line 416 of file xmlimpl.cpp.
References _cur_node, xml_node::_decl, _doc, _error, xml_tree_node::_right, _tmp_allocator, base_string< T >::assign(), ch_back_slash, ch_forward_slash, ELEMENT_NODE, base_list< T >::empty(), xml_grammar::find_element_decl(), base_list< T >::front(), nodeDecl::get_type(), _list< T, A >::pop_front(), _list< T, A >::push_back(), and byte_allocator::reset().
Referenced by xmlconfig::get(), xmlconfig::getlist(), xmlconfig::set(), xmlconfig::setlist(), and xmlconfig::xmlconfig().
bool xml_designer_impl::save |
( |
const char * |
name, |
|
|
bool |
add_doc_type | |
|
) |
| | const [virtual] |
bool xml_designer_impl::save |
( |
void * |
buffer, |
|
|
size_t & |
length, |
|
|
bool |
add_doc_type | |
|
) |
| | const [virtual] |
bool xml_designer_impl::add_child |
( |
xmlNodeType |
type, |
|
|
const char * |
name, |
|
|
const char * |
value, |
|
|
bool |
dont_move | |
|
) |
| | [virtual] |
bool xml_designer_impl::insert_sibling |
( |
xmlNodeType |
type, |
|
|
const char * |
name, |
|
|
const char * |
value, |
|
|
bool |
dont_move | |
|
) |
| | [virtual] |
inserts node before current node beneath the same parent
- Parameters:
-
type |
xml node type |
name |
name |
value |
value |
dont_move |
do not navigate from current position |
Implements xml_designer.
Definition at line 557 of file xmlimpl.cpp.
References _import_node().
bool xml_designer_impl::append_sibling |
( |
xmlNodeType |
type, |
|
|
const char * |
name, |
|
|
const char * |
value, |
|
|
bool |
dont_move | |
|
) |
| | [virtual] |
appends node after current node beneath the same parent
- Parameters:
-
type |
xml node type |
name |
name |
value |
value |
dont_move |
do not navigate from current position |
Implements xml_designer.
Definition at line 563 of file xmlimpl.cpp.
References _import_node().
bool xml_designer_impl::remove_node |
( |
|
) |
[virtual] |
removes the current node
Implements xml_designer.
Definition at line 569 of file xmlimpl.cpp.
References _cur_node, xml_node::_decl, _doc, _error, xml_tree_node::_parent, ATTRIBUTE_NODE, xml_container::cast_to_container(), xml_element::cast_to_element(), xml_document::clear_root(), DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, nodeDecl::get_type(), xml_element::remove_attribute(), and xml_container::remove_node().
bool xml_designer_impl::update_value |
( |
const char * |
value |
) |
[virtual] |
updates the current node attribute value == value processing instruction value = text cdata, text, comment value == text
- Parameters:
-
Implements xml_designer.
Definition at line 602 of file xmlimpl.cpp.
References _cur_node, xml_node::_decl, _doc, _error, xml_tree_node::_parent, xml_value_node::_value, ATTRIBUTE_NODE, xml_element::cast_to_element(), xml_value_node::cast_to_node_value(), CDATA_SECTION_NODE, COMMENT_NODE, copy_string(), xml_document::get_data_allocator(), nodeDecl::get_type(), os_minus_one, PROCESSING_INSTRUCTION_NODE, _terimber_xml_value_::strVal, TEXT_NODE, xml_document::update_attribute(), and exception::what().
Referenced by xmlconfig::set(), and xmlconfig::setlist().
bool xml_designer_impl::merge |
( |
const xml_designer * |
x, |
|
|
bool |
recursive | |
|
) |
| | [virtual] |
adds beneath the current node an external xml fragment starting with the current node
- Parameters:
-
x |
source xml document |
recursive |
merge recursively |
Implements xml_designer.
Definition at line 633 of file xmlimpl.cpp.
References _cur_node, xml_node::_decl, _doc, _error, add_child(), DOCUMENT_NODE, ELEMENT_NODE, xml_designer::get_name(), xml_document::get_root_element(), xml_designer::get_type(), nodeDecl::get_type(), xml_designer::get_value(), xml_designer::select_first_attribute(), xml_designer::select_first_child(), xml_designer::select_next_sibling(), select_parent(), and xml_designer::select_parent().
bool xml_designer_impl::validate |
( |
bool |
recursive |
) |
[virtual] |
BEGIN_TERIMBER_NAMESPACE xmlNodeType xml_designer_impl::get_cur_type |
( |
|
) |
const [inline, protected] |
bool xml_designer_impl::is_attribute |
( |
|
) |
const [inline, protected] |
bool xml_designer_impl::is_element |
( |
|
) |
const [inline, protected] |
bool xml_designer_impl::is_container |
( |
|
) |
const [inline, protected] |
bool xml_designer_impl::_import_node |
( |
xmlNodeType |
type, |
|
|
const char * |
name, |
|
|
const char * |
value, |
|
|
bool |
sibling, |
|
|
bool |
after, |
|
|
bool |
dont_move | |
|
) |
| | [private] |
inserts new xml node into document
- Parameters:
-
type |
node type |
name |
node name |
value |
node value |
sibling |
insert as a sibling to the selected node or as a child |
after |
insert before or after selected node |
dont_move |
do not navigate to the new node |
Definition at line 763 of file xmlimpl.cpp.
References _cur_node, xml_node::_decl, _doc, _error, xml_tree_node::_parent, xml_document::add_attribute(), xml_document::add_cdata(), xml_document::add_comment(), xml_document::add_element(), xml_document::add_pi(), xml_document::add_text(), ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, xml_document::container_pop(), xml_document::container_push(), DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, nodeDecl::get_type(), PROCESSING_INSTRUCTION_NODE, TEXT_NODE, and exception::what().
Referenced by add_child(), append_sibling(), and insert_sibling().
void xml_designer_impl::_validate |
( |
xml_element * |
el, |
|
|
bool |
recursive | |
|
) |
| | [private] |
parses xml document from abstract streams for xml and DTD sources
- Parameters:
-
stream |
optional xml stream |
grammar |
optional DTD stream |
Definition at line 883 of file xmlimpl.cpp.
References _big_manager, _cur_node, _doc, _error, _small_manager, _xml_size, xml_document::add_escaped_symbols(), xml_document::clear(), xml_document::container_start_doctype(), xml_document::container_stop_doctype(), xml_processor::get_error(), xml_processor::parse(), dtd_processor::parse(), and exception::what().
Referenced by load().
Member Data Documentation
xml document
Definition at line 289 of file xmlimpl.h.
Referenced by _import_node(), _load(), _validate(), get_name(), get_xpath(), merge(), remove_node(), save(), select_attribute_by_name(), select_document(), select_root(), select_xpath(), update_value(), and xml_designer_impl().
selected node
Definition at line 291 of file xmlimpl.h.
Referenced by _import_node(), _load(), get_cur_type(), get_name(), get_value(), get_xpath(), has_attributes(), has_children(), merge(), remove_node(), select_attribute_by_name(), select_document(), select_first_attribute(), select_first_child(), select_last_attribute(), select_last_child(), select_next_sibling(), select_parent(), select_prev_sibling(), select_root(), select_xpath(), update_value(), validate(), and xml_designer_impl().
The documentation for this class was generated from the following files:
|
|