#include <xmlstorage.h>
Public Types | |
typedef XMLReader | super |
Public Member Functions | |
XMLStreamReader (std::istream &in) | |
XMLStreamReader (LPCTSTR path) | |
~XMLStreamReader () | |
const XMLNode * | operator-> () const |
operator const XMLNode * () const | |
XS_String | str () const |
XS_String | operator[] (const XS_String &attr_name) const |
Return the value of an attribute in the current node. | |
bool | go_down () |
Go down to first child. | |
bool | go_down (const XS_String &child_name) |
Search for child and go down. | |
bool | go (const XPath &xpath) |
move X-Path like to position in XML tree | |
bool | back () |
Move back to the next higher nesting level. | |
bool | first_child (LPCXSSTR node_name=NULL) |
Move to the first child node with the specified name. | |
bool | next () |
Move to the next sibling node independent from its name. | |
bool | next_skip_others (const XS_String &node_name) |
Move to the next sibling node with the specified name. | |
bool | next_stop_on_others (LPCXSSTR node_name=NULL) |
Move to the next sibling node with the specified name. | |
bool | find (const XPathElement &xelem) |
bool | find_relative (const XPath &xpath) |
XPath find function. | |
const XMLErrorList & | get_errors () const |
Public Attributes | |
int | _level |
Protected Member Functions | |
bool | find_node (LPCXSSTR target_tag, int target_level, int min_level, bool stop_on_others) |
virtual void | StartElementHandler (const XS_String &name, const XMLNode::AttributeMap &attr) |
virtual void | EndElementHandler () |
virtual void | DefaultHandler (const std::string &s) |
Protected Attributes | |
XMLNode | _node |
Definition at line 3022 of file xmlstorage.h.
Definition at line 3024 of file xmlstorage.h.
XMLStorage::XMLStreamReader::XMLStreamReader | ( | std::istream & | in ) | [inline] |
Definition at line 3026 of file xmlstorage.h.
: _pInFile(NULL), _state_rdr(NULL, in), _level(0), _node(XS_EMPTY_STR) { }
XMLStorage::XMLStreamReader::XMLStreamReader | ( | LPCTSTR | path ) | [inline] |
Definition at line 3034 of file xmlstorage.h.
References XMLStorage::XMLStateReader::_parse_ctx, XMLStorage::ParseContext::_reader, and XMLStorage::XMLReaderBase::setSystemId().
: _pInFile(new tifstream(path)), _state_rdr(NULL, *_pInFile), _level(0), _node(XS_EMPTY_STR) { #ifdef UNICODE _state_rdr._parse_ctx._reader.setSystemId(std::string(XS_String(path)).c_str()); #else _state_rdr._parse_ctx._reader.setSystemId(path); #endif }
XMLStorage::XMLStreamReader::~XMLStreamReader | ( | ) | [inline] |
Definition at line 3047 of file xmlstorage.h.
{
delete _pInFile;
}
bool XMLStorage::XMLStreamReader::back | ( | ) | [inline] |
Move back to the next higher nesting level.
Remark: This implementation does _not_ jump more than one level up like XMLPos.node() when using go() to move down more than one level at a time.
Definition at line 3118 of file xmlstorage.h.
References _level, and find_node().
{ if (find_node(NULL, -1, _level+1, false)) // if (find_node(NULL, _level-1, _level-1, false)) return true; else { assert(_level>=0); // tried to move out of the tree hierarchy return false; } }
void XMLStorage::XMLStreamReader::DefaultHandler | ( | const std::string & | s ) | [protected, virtual] |
Definition at line 1245 of file xmlstorage.cpp.
{ _content.append(EncodeXMLString(s)); }
void XMLStorage::XMLStreamReader::EndElementHandler | ( | ) | [protected, virtual] |
Definition at line 1236 of file xmlstorage.cpp.
{ _node.clear(); _node.get_attributes().clear(); _content.erase(); --_level; }
bool XMLStorage::XMLStreamReader::find | ( | const XPathElement & | xelem ) | [inline] |
Definition at line 3166 of file xmlstorage.h.
References XMLStorage::XPathElement::_child_name, _node, first_child(), XMLStorage::XPathElement::matches(), and next_skip_others().
{ int n = 0; if (first_child(xelem._child_name)) { if (xelem.matches(_node, n)) return true; while(next_skip_others(xelem._child_name)) if (xelem.matches(_node, n)) return true; } return false; }
bool XMLStorage::XMLStreamReader::find_node | ( | LPCXSSTR | target_tag, |
int | target_level, | ||
int | min_level, | ||
bool | stop_on_others | ||
) | [protected] |
Definition at line 1150 of file xmlstorage.cpp.
Referenced by back(), first_child(), next(), next_skip_others(), and next_stop_on_others().
{ bool found = false; for(; _state_rdr.has_next(); _state_rdr.next()) { switch(_state_rdr._state) { case XMLStateReader::XSS_START_ELEMENT: { // stop parsing if we found the target node and its content is already processed. if (found) goto break_parsingLoop; // check for match in target level and eventually node name if (_level+1 == target_level) { if (target_tag==NULL || _state_rdr._node_name==target_tag) found = true; else if (stop_on_others) return false; } StartElementHandler(_state_rdr._node_name, _state_rdr._attrs); break;} case XMLStateReader::XSS_ELEMENT: // stop parsing if we found the target node and its content is already processed. if (found) goto break_parsingLoop; // check for match in target level and eventually node name if (_level+1 == target_level) { if (target_tag==NULL || _state_rdr._node_name==target_tag) found = true; else if (stop_on_others) return false; } StartElementHandler(_state_rdr._node_name, _state_rdr._attrs); // fall through... case XMLStateReader::XSS_END_ELEMENT: { // stop parsing if we found the target node and its content is already processed. if (found) goto break_parsingLoop; // stop before leaving the targeted level range; used by next_stop_on_others() if (_level == min_level) return false; EndElementHandler(); // stop searching if the current level leaves the target range; used by back() if (_level < min_level) { _state_rdr.next(); return false; } break;} case XMLStateReader::XSS_CHARACTERS: // case XMLStateReader::XSS_COMMENT: // case XMLStateReader::XSS_SPACE: // case XMLStateReader::XSS_CDATA: DefaultHandler(_state_rdr.get_encoded_content()); break; // case XMLStateReader::XSS_PROCESSING_INSTRUCTION: // XmlDeclHandler(); // break; } } break_parsingLoop: if (found) { _node.set_encoded_content(_content); _content.erase(); return true; } else return false; }
bool XMLStorage::XMLStreamReader::find_relative | ( | const XPath & | xpath ) |
XPath find function.
Definition at line 1138 of file xmlstorage.cpp.
Referenced by go().
{ for(XPath::const_iterator it=xpath.begin(); it!=xpath.end(); ++it) { const XPathElement& xelem = *it; if (!find(xelem)) return false; } return true; }
bool XMLStorage::XMLStreamReader::first_child | ( | LPCXSSTR | node_name = NULL ) |
[inline] |
Move to the first child node with the specified name.
Definition at line 3133 of file xmlstorage.h.
References _level, and find_node().
Referenced by find(), and go_down().
const XMLErrorList& XMLStorage::XMLStreamReader::get_errors | ( | ) | const [inline] |
Definition at line 3184 of file xmlstorage.h.
References XMLStorage::XMLReaderBase::get_errors().
{return _state_rdr.get_errors();}
bool XMLStorage::XMLStreamReader::go | ( | const XPath & | xpath ) | [inline] |
move X-Path like to position in XML tree
Definition at line 3103 of file xmlstorage.h.
References XMLStorage::XPath::_absolute, and find_relative().
{ // Absolute paths are not supported. if (xpath._absolute) return false; return find_relative(xpath); }
bool XMLStorage::XMLStreamReader::go_down | ( | ) | [inline] |
Go down to first child.
Definition at line 3087 of file xmlstorage.h.
References first_child().
{ return first_child(); }
bool XMLStorage::XMLStreamReader::go_down | ( | const XS_String & | child_name ) | [inline] |
Search for child and go down.
child_name |
Definition at line 3097 of file xmlstorage.h.
References first_child().
{ return first_child(child_name); }
bool XMLStorage::XMLStreamReader::next | ( | ) | [inline] |
Move to the next sibling node independent from its name.
Definition at line 3142 of file xmlstorage.h.
References _level, and find_node().
Referenced by XMLStorage::XMLStreamChildrenIterator::const_iterator::search_next().
bool XMLStorage::XMLStreamReader::next_skip_others | ( | const XS_String & | node_name ) | [inline] |
Move to the next sibling node with the specified name.
Definition at line 3151 of file xmlstorage.h.
References _level, and find_node().
Referenced by find(), and XMLStorage::XMLStreamChildrenFilter::const_iterator::search_next().
bool XMLStorage::XMLStreamReader::next_stop_on_others | ( | LPCXSSTR | node_name = NULL ) |
[inline] |
Move to the next sibling node with the specified name.
Definition at line 3160 of file xmlstorage.h.
References _level, and find_node().
XMLStorage::XMLStreamReader::operator const XMLNode * | ( | ) | const [inline] |
const XMLNode* XMLStorage::XMLStreamReader::operator-> | ( | ) | const [inline] |
Return the value of an attribute in the current node.
attr_name |
Definition at line 3078 of file xmlstorage.h.
References _node.
{ return _node[attr_name]; }
void XMLStorage::XMLStreamReader::StartElementHandler | ( | const XS_String & | name, |
const XMLNode::AttributeMap & | attr | ||
) | [protected, virtual] |
Definition at line 1227 of file xmlstorage.cpp.
{ _node.assign(name); _node.get_attributes() = attr; _content.erase(); ++_level; }
XS_String XMLStorage::XMLStreamReader::str | ( | ) | const [inline] |
Definition at line 3068 of file xmlstorage.h.
References _node.
Referenced by XMLStorage::XMLStreamChildrenFilter::const_iterator::operator!=(), XMLStorage::XMLStreamChildrenIterator::const_iterator::operator!=(), XMLStorage::XMLStreamChildrenFilter::const_iterator::operator*(), XMLStorage::XMLStreamChildrenIterator::const_iterator::operator*(), XMLStorage::XMLStreamChildrenFilter::const_iterator::operator==(), and XMLStorage::XMLStreamChildrenIterator::const_iterator::operator==().
{ return _node; }
Definition at line 3186 of file xmlstorage.h.
Referenced by back(), first_child(), next(), next_skip_others(), next_stop_on_others(), XMLStorage::XMLStreamChildrenFilter::const_iterator::search_next(), and XMLStorage::XMLStreamChildrenIterator::const_iterator::search_next().
XMLNode XMLStorage::XMLStreamReader::_node [protected] |
Definition at line 3196 of file xmlstorage.h.
Referenced by find(), operator const XMLNode *(), operator->(), operator[](), and str().
ROS Explorer Source Code Documentation
generated on 02.01.2013 by ![]() |