XML reader base class. More...
#include <xmlstorage.h>
Public Member Functions | |
XMLReaderBase (XMLNode *node) | |
virtual | ~XMLReaderBase () |
bool | parse () |
void | read () |
read XML stream into XML tree below _pos | |
std::string | get_position () const |
const XMLFormat & | get_format () const |
const char * | get_endl () const |
const XMLErrorList & | get_errors () const |
const XMLErrorList & | get_warnings () const |
void | clear_errors () |
XMLLocation | get_location () const |
void | setSystemId (const char *systemId) |
std::string | get_encoded_content () const |
Protected Types | |
enum | { TAG_NONE, TAG_START, TAG_END } |
Protected Member Functions | |
virtual int | get ()=0 |
int | eat_endl () |
void | finish_read () |
virtual void | XmlDeclHandler (const char *version, const char *encoding, int standalone) |
store XML version and encoding into XML reader | |
virtual void | StartElementHandler (const XS_String &name, const XMLNode::AttributeMap &attributes) |
notifications about XML start tag | |
virtual void | EndElementHandler () |
notifications about XML end tag | |
virtual void | DefaultHandler (const std::string &s) |
store content, white space and comments | |
Protected Attributes | |
XMLPos | _pos |
std::string | _content |
enum XMLStorage::XMLReaderBase:: { ... } | _last_tag |
XMLErrorList | _errors |
XMLErrorList | _warnings |
XMLFormat | _format |
bool | _endl_defined |
XMLLocation | _location |
Friends | |
struct | ParseContext |
XML reader base class.
Definition at line 2485 of file xmlstorage.h.
anonymous enum [protected] |
XMLStorage::XMLReaderBase::XMLReaderBase | ( | XMLNode * | node ) | [inline] |
Definition at line 2535 of file xmlstorage.h.
References _last_tag, and TAG_NONE.
: _pos(node), _endl_defined(false) { _last_tag = TAG_NONE; }
XMLStorage::XMLReaderBase::~XMLReaderBase | ( | ) | [virtual] |
Definition at line 52 of file xs-native.cpp.
{ }
void XMLStorage::XMLReaderBase::clear_errors | ( | ) | [inline] |
Definition at line 2560 of file xmlstorage.h.
References _errors, and _warnings.
Referenced by XMLStorage::XMLDoc::read().
void XMLStorage::XMLReaderBase::DefaultHandler | ( | const std::string & | s ) | [protected, virtual] |
store content, white space and comments
Reimplemented in XMLStorage::XMLStateReader.
Definition at line 451 of file xs-native.cpp.
References _content.
Referenced by XMLStorage::ParseContext::process_next().
{ _content.append(s); }
int XMLStorage::XMLReaderBase::eat_endl | ( | ) | [protected] |
Definition at line 436 of file xs-native.cpp.
Referenced by XMLStorage::ParseContext::process_next().
{ int c = get(); if (c == '\r') c = get(); if (c == '\n') c = get(); return c; }
void XMLStorage::XMLReaderBase::EndElementHandler | ( | ) | [protected, virtual] |
notifications about XML end tag
Reimplemented in XMLStorage::XMLStateReader.
Definition at line 979 of file xmlstorage.cpp.
References XMLStorage::XMLNode::_content, CDATA_END, and CDATA_START.
Referenced by XMLStorage::ParseContext::process_next().
{ const char* s = _content.c_str(); const char* e = s + _content.length(); const char* p; if (!strncmp(s,CDATA_START,9) && !strncmp(e-3,CDATA_END,3)) { s += 9; p = (e-=3); _pos->_cdata_content = true; } else { // search for content end leaving only white space for _end_leading for(p=e; p>s; --p) if (!isspace((unsigned char)p[-1])) break; _pos->_cdata_content = false; } if (p != s) { if (_pos->_children.empty()) // no children in current node? _pos->_content.append(s, p-s); else if (_last_tag == TAG_START) _pos->_content.append(s, p-s); else _pos->_children.back()->_trailing.append(s, p-s); } if (p != e) _pos->_end_leading.assign(p, e-p); _pos.back(); _last_tag = TAG_END; _content.erase(); }
void XMLStorage::XMLReaderBase::finish_read | ( | ) | [protected] |
Definition at line 909 of file xmlstorage.cpp.
References XMLStorage::XMLNode::_content.
Referenced by read().
{ if (_pos != NULL) { if (_pos->_children.empty()) _pos->_trailing.append(_content); else _pos->_children.back()->_trailing.append(_content); } _content.erase(); }
virtual int XMLStorage::XMLReaderBase::get | ( | ) | [protected, pure virtual] |
Implemented in XMLStorage::XMLReader.
Referenced by XMLStorage::ParseContext::ParseContext(), XMLStorage::ParseContext::process_next(), and XMLStorage::ParseContext::read_bom().
std::string XMLStorage::XMLReaderBase::get_encoded_content | ( | ) | const [inline] |
const char* XMLStorage::XMLReaderBase::get_endl | ( | ) | const [inline] |
Definition at line 2555 of file xmlstorage.h.
References XMLStorage::XMLFormat::_endl, _endl_defined, and _format.
Referenced by XMLStorage::XMLDoc::read().
{return _endl_defined? _format._endl: "\n";}
const XMLErrorList& XMLStorage::XMLReaderBase::get_errors | ( | ) | const [inline] |
Definition at line 2557 of file xmlstorage.h.
References _errors.
Referenced by XMLStorage::XMLStreamReader::get_errors(), and XMLStorage::XMLDoc::read().
{return _errors;}
const XMLFormat& XMLStorage::XMLReaderBase::get_format | ( | ) | const [inline] |
Definition at line 2554 of file xmlstorage.h.
References _format.
Referenced by XMLStorage::XMLDoc::read().
{return _format;}
XMLLocation XMLStorage::XMLReaderBase::get_location | ( | ) | const [inline] |
std::string XMLStorage::XMLReaderBase::get_position | ( | ) | const [inline] |
Definition at line 2552 of file xmlstorage.h.
References _location, and XMLStorage::XMLLocation::str().
{return _location.str();}
const XMLErrorList& XMLStorage::XMLReaderBase::get_warnings | ( | ) | const [inline] |
bool XMLStorage::XMLReaderBase::parse | ( | ) |
Definition at line 426 of file xs-native.cpp.
References XMLStorage::ParseContext::proceed().
Referenced by read().
{ ParseContext ctx(*this); while(ctx.proceed()) { } return true; //TODO return false on invalid XML }
void XMLStorage::XMLReaderBase::read | ( | ) |
read XML stream into XML tree below _pos
Definition at line 57 of file xs-native.cpp.
References _errors, finish_read(), and parse().
Referenced by XMLStorage::XMLDoc::read().
{ if (!parse()) { XMLError error("XML parsing error"); //error._line = ; //error._column = ; _errors.push_back(error); } finish_read(); }
void XMLStorage::XMLReaderBase::setSystemId | ( | const char * | systemId ) | [inline] |
Definition at line 2564 of file xmlstorage.h.
References _location, and XMLStorage::XMLLocation::set_path().
Referenced by XMLStorage::XMLDoc::read(), and XMLStorage::XMLStreamReader::XMLStreamReader().
{_location.set_path(systemId);}
void XMLStorage::XMLReaderBase::StartElementHandler | ( | const XS_String & | name, |
const XMLNode::AttributeMap & | attributes | ||
) | [protected, virtual] |
notifications about XML start tag
Reimplemented in XMLStorage::XMLStateReader.
Definition at line 936 of file xmlstorage.cpp.
References XMLStorage::XMLNode::_attributes, XMLStorage::XMLNode::_content, and XMLStorage::XMLNode::XMLNode().
Referenced by XMLStorage::ParseContext::process_next().
{ const char* s = _content.c_str(); const char* e = s + _content.length(); const char* p = s; // search for content end leaving only white space for leading for(p=e; p>s; --p) if (!isspace((unsigned char)p[-1])) break; if (p != s) { if (_pos->_children.empty()) { // no children in last node? if (_last_tag == TAG_START) _pos->_content.append(s, p-s); else if (_last_tag == TAG_END) _pos->_trailing.append(s, p-s); else // TAG_NONE at root node p = s; } else _pos->_children.back()->_trailing.append(s, p-s); } std::string leading; if (p != e) leading.assign(p, e-p); XMLNode* node = new XMLNode(name, leading); _pos.add_down(node); #ifdef XMLNODE_LOCATION node->_location = get_location(); #endif node->_attributes = attributes; _last_tag = TAG_START; _content.erase(); }
void XMLStorage::XMLReaderBase::XmlDeclHandler | ( | const char * | version, |
const char * | encoding, | ||
int | standalone | ||
) | [protected, virtual] |
store XML version and encoding into XML reader
Definition at line 923 of file xmlstorage.cpp.
Referenced by XMLStorage::ParseContext::process_next().
{ if (version) _format._version = version; if (encoding) _format._encoding = encoding; _format._standalone = standalone; }
friend struct ParseContext [friend] |
Definition at line 2613 of file xmlstorage.h.
std::string XMLStorage::XMLReaderBase::_content [protected] |
Definition at line 2581 of file xmlstorage.h.
Referenced by DefaultHandler(), and get_encoded_content().
bool XMLStorage::XMLReaderBase::_endl_defined [protected] |
Definition at line 2588 of file xmlstorage.h.
Referenced by get_endl(), and XMLStorage::ParseContext::process_next().
XMLErrorList XMLStorage::XMLReaderBase::_errors [protected] |
Definition at line 2584 of file xmlstorage.h.
Referenced by clear_errors(), get_errors(), and read().
XMLFormat XMLStorage::XMLReaderBase::_format [protected] |
Definition at line 2587 of file xmlstorage.h.
Referenced by get_endl(), get_format(), XMLStorage::ParseContext::process_next(), and XMLStorage::ParseContext::read_bom().
enum { ... } XMLStorage::XMLReaderBase::_last_tag [protected] |
Referenced by XMLReaderBase().
XMLLocation XMLStorage::XMLReaderBase::_location [protected] |
Definition at line 2591 of file xmlstorage.h.
Referenced by XMLStorage::XMLReader::get(), get_location(), get_position(), and setSystemId().
XMLPos XMLStorage::XMLReaderBase::_pos [protected] |
Definition at line 2579 of file xmlstorage.h.
XMLErrorList XMLStorage::XMLReaderBase::_warnings [protected] |
Definition at line 2585 of file xmlstorage.h.
Referenced by clear_errors(), and get_warnings().
ROS Explorer Source Code Documentation
generated on 02.01.2013 by ![]() |