#include <xmlstorage.h>


Public Types | |
| enum | XML_STATE { XSS_NONE, XSS_START_ELEMENT, XSS_END_ELEMENT, XSS_ELEMENT, XSS_CHARACTERS } |
Public Member Functions | |
| XMLStateReader (XMLNode *node, std::istream &in) | |
| bool | has_next () |
| void | next () |
| virtual void | StartElementHandler (const XS_String &name, const XMLNode::AttributeMap &attr) |
| 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 | |
| int | get () |
| read one character from XML stream | |
| bool | parse (bool force_utf8=false) |
| void | read (bool force_utf8=false) |
| 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 |
Public Attributes | |
| ParseContext | _parse_ctx |
| enum XML_STATE | _state |
| XS_String | _node_name |
| XMLNode::AttributeMap | _attrs |
Protected Types | |
| enum | { TAG_NONE, TAG_START, TAG_END } |
Protected Member Functions | |
| 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 | |
Protected Attributes | |
| std::istream & | _in |
| int | _last_crlf |
| XMLPos | _pos |
| std::string | _content |
| enum XMLStorage::XMLReaderBase:: { ... } | _last_tag |
| XMLErrorList | _errors |
| XMLErrorList | _warnings |
| XMLFormat | _format |
| bool | _endl_defined |
| XMLLocation | _location |
Friends | |
| struct | ParseContext |
Definition at line 3076 of file xmlstorage.h.
anonymous enum [protected, inherited] |
Definition at line 3078 of file xmlstorage.h.
{
XSS_NONE,
XSS_START_ELEMENT,
XSS_END_ELEMENT,
XSS_ELEMENT,
XSS_CHARACTERS,
// XSS_COMMENT,
// XSS_SPACE,
// XSS_CDATA,
// XSS_PROCESSING_INSTRUCTION
};
| XMLStorage::XMLStateReader::XMLStateReader | ( | XMLNode * | node, |
| std::istream & | in | ||
| ) | [inline] |
Definition at line 3090 of file xmlstorage.h.
: XMLReader(node, in), _parse_ctx(*this), _state(XSS_NONE) { }
| void XMLStorage::XMLReaderBase::clear_errors | ( | ) | [inline, inherited] |
Definition at line 2648 of file xmlstorage.h.
References XMLStorage::XMLReaderBase::_errors, and XMLStorage::XMLReaderBase::_warnings.
Referenced by XMLStorage::XMLDoc::read().

| void XMLStorage::XMLStateReader::DefaultHandler | ( | const std::string & | s ) | [virtual] |
store content, white space and comments
Reimplemented from XMLStorage::XMLReaderBase.
Definition at line 1292 of file xmlstorage.cpp.
{
_content.append(EncodeXMLString(s));
assert(_state==XSS_NONE);
_state = XSS_CHARACTERS;
}
| int XMLStorage::XMLReaderBase::eat_endl | ( | ) | [protected, inherited] |
Definition at line 445 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::XMLStateReader::EndElementHandler | ( | ) | [virtual] |
notifications about XML end tag
Reimplemented from XMLStorage::XMLReaderBase.
Definition at line 1278 of file xmlstorage.cpp.
{
// _node_name.erase();
// _attrs.clear();
_content.erase();
if (_state == XSS_START_ELEMENT)
_state = XSS_ELEMENT;
else {
assert(_state==XSS_NONE);
_state = XSS_END_ELEMENT;
}
}
| void XMLStorage::XMLReaderBase::finish_read | ( | ) | [protected, inherited] |
Definition at line 908 of file xmlstorage.cpp.
References XMLStorage::XMLNode::_content.
Referenced by XMLStorage::XMLReaderBase::read().
{
if (_pos != NULL) {
if (_pos->_children.empty())
_pos->_trailing.append(_content);
else
_pos->_children.back()->_trailing.append(_content);
}
_content.erase();
}

| int XMLStorage::XMLReader::get | ( | ) | [inline, virtual, inherited] |
read one character from XML stream
Implements XMLStorage::XMLReaderBase.
Definition at line 2762 of file xmlstorage.h.
References XMLStorage::XMLLocation::_column, XMLStorage::XMLReader::_in, XMLStorage::XMLReader::_last_crlf, XMLStorage::XMLLocation::_line, and XMLStorage::XMLReaderBase::_location.
{
int c = _in.get();
// // increment line counter on LF
// if (c == '\n') {
// _location._column = 1;
// ++_location._line;
// increment line counter on LF, CR, CR/LF or LF/CR line endings
if (c=='\n' || c=='\r') {
if (!_last_crlf || c==_last_crlf) {
_location._column = 1;
++_location._line;
_last_crlf = c;
} else
_last_crlf = 0;
} else {
++_location._column;
_last_crlf = 0;
}
return c;
}
| std::string XMLStorage::XMLReaderBase::get_encoded_content | ( | ) | const [inline, inherited] |
Definition at line 2664 of file xmlstorage.h.
References XMLStorage::XMLReaderBase::_content.
{return _content;}
| const char* XMLStorage::XMLReaderBase::get_endl | ( | ) | const [inline, inherited] |
Definition at line 2643 of file xmlstorage.h.
References XMLStorage::XMLFormat::_endl, XMLStorage::XMLReaderBase::_endl_defined, and XMLStorage::XMLReaderBase::_format.
Referenced by XMLStorage::XMLDoc::read().
{return _endl_defined? _format._endl: "\n";}

| const XMLErrorList& XMLStorage::XMLReaderBase::get_errors | ( | ) | const [inline, inherited] |
Definition at line 2645 of file xmlstorage.h.
References XMLStorage::XMLReaderBase::_errors.
Referenced by XMLStorage::XMLStreamReader::get_errors(), and XMLStorage::XMLDoc::read().
{return _errors;}

| const XMLFormat& XMLStorage::XMLReaderBase::get_format | ( | ) | const [inline, inherited] |
Definition at line 2642 of file xmlstorage.h.
References XMLStorage::XMLReaderBase::_format.
Referenced by XMLStorage::XMLDoc::read().
{return _format;}

| XMLLocation XMLStorage::XMLReaderBase::get_location | ( | ) | const [inline, inherited] |
Definition at line 2651 of file xmlstorage.h.
References XMLStorage::XMLReaderBase::_location.
{return _location;}
| std::string XMLStorage::XMLReaderBase::get_position | ( | ) | const [inline, inherited] |
Definition at line 2640 of file xmlstorage.h.
References XMLStorage::XMLReaderBase::_location, and XMLStorage::XMLLocation::str().
{return _location.str();}

| const XMLErrorList& XMLStorage::XMLReaderBase::get_warnings | ( | ) | const [inline, inherited] |
Definition at line 2646 of file xmlstorage.h.
References XMLStorage::XMLReaderBase::_warnings.
{return _warnings;}
| bool XMLStorage::XMLStateReader::has_next | ( | ) |
Definition at line 1251 of file xmlstorage.cpp.
{
while(_state == XSS_NONE)
if (!_parse_ctx.proceed())
break;
return _state != XSS_NONE;
}
| void XMLStorage::XMLStateReader::next | ( | ) |
Definition at line 1260 of file xmlstorage.cpp.
{
_state = XSS_NONE;
_node_name.erase();
_parse_ctx.proceed();
}
| bool XMLStorage::XMLReaderBase::parse | ( | bool | force_utf8 = false ) |
[inherited] |
Definition at line 435 of file xs-native.cpp.
References XMLStorage::ParseContext::proceed().
Referenced by XMLStorage::XMLReaderBase::read().
{
ParseContext ctx(*this, force_utf8);
while(ctx.proceed()) {
}
return true; //TODO return false on invalid XML
}


| void XMLStorage::XMLReaderBase::read | ( | bool | force_utf8 = false ) |
[inherited] |
read XML stream into XML tree below _pos
Definition at line 57 of file xs-native.cpp.
References XMLStorage::XMLReaderBase::_errors, XMLStorage::XMLReaderBase::finish_read(), and XMLStorage::XMLReaderBase::parse().
Referenced by XMLStorage::XMLDoc::read().
{
if (!parse(force_utf8)) {
XMLError error("XML parsing error");
//error._line = ;
//error._column = ;
_errors.push_back(error);
}
finish_read();
}


| void XMLStorage::XMLReaderBase::setSystemId | ( | const char * | systemId ) | [inline, inherited] |
Definition at line 2652 of file xmlstorage.h.
References XMLStorage::XMLReaderBase::_location, and XMLStorage::XMLLocation::set_path().
Referenced by XMLStorage::XMLDoc::read(), and XMLStorage::XMLStreamReader::XMLStreamReader().
{_location.set_path(systemId);}


| void XMLStorage::XMLStateReader::StartElementHandler | ( | const XS_String & | name, |
| const XMLNode::AttributeMap & | attributes | ||
| ) | [virtual] |
notifications about XML start tag
Reimplemented from XMLStorage::XMLReaderBase.
Definition at line 1268 of file xmlstorage.cpp.
{
_node_name = name;
_attrs = attr;
_content.erase();
assert(_state==XSS_NONE);
_state = XSS_START_ELEMENT;
}
| void XMLStorage::XMLReaderBase::XmlDeclHandler | ( | const char * | version, |
| const char * | encoding, | ||
| int | standalone | ||
| ) | [protected, virtual, inherited] |
store XML version and encoding into XML reader
Definition at line 922 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, inherited] |
Definition at line 2701 of file xmlstorage.h.
Definition at line 3109 of file xmlstorage.h.
std::string XMLStorage::XMLReaderBase::_content [protected, inherited] |
Definition at line 2669 of file xmlstorage.h.
Referenced by XMLStorage::XMLReaderBase::DefaultHandler(), and XMLStorage::XMLReaderBase::get_encoded_content().
bool XMLStorage::XMLReaderBase::_endl_defined [protected, inherited] |
Definition at line 2676 of file xmlstorage.h.
Referenced by XMLStorage::XMLReaderBase::get_endl(), and XMLStorage::ParseContext::process_next().
XMLErrorList XMLStorage::XMLReaderBase::_errors [protected, inherited] |
Definition at line 2672 of file xmlstorage.h.
Referenced by XMLStorage::XMLReaderBase::clear_errors(), XMLStorage::XMLReaderBase::get_errors(), and XMLStorage::XMLReaderBase::read().
XMLFormat XMLStorage::XMLReaderBase::_format [protected, inherited] |
Definition at line 2675 of file xmlstorage.h.
Referenced by XMLStorage::XMLReaderBase::get_endl(), XMLStorage::XMLReaderBase::get_format(), XMLStorage::ParseContext::process_next(), and XMLStorage::ParseContext::read_bom().
std::istream& XMLStorage::XMLReader::_in [protected, inherited] |
Definition at line 2787 of file xmlstorage.h.
Referenced by XMLStorage::XMLReader::get().
int XMLStorage::XMLReader::_last_crlf [protected, inherited] |
Definition at line 2788 of file xmlstorage.h.
Referenced by XMLStorage::XMLReader::get().
enum { ... } XMLStorage::XMLReaderBase::_last_tag [protected, inherited] |
Referenced by XMLStorage::XMLReaderBase::XMLReaderBase().
XMLLocation XMLStorage::XMLReaderBase::_location [protected, inherited] |
Definition at line 2679 of file xmlstorage.h.
Referenced by XMLStorage::XMLReader::get(), XMLStorage::XMLReaderBase::get_location(), XMLStorage::XMLReaderBase::get_position(), and XMLStorage::XMLReaderBase::setSystemId().
Definition at line 3108 of file xmlstorage.h.
Definition at line 3105 of file xmlstorage.h.
Referenced by XMLStorage::XMLStreamReader::XMLStreamReader().
XMLPos XMLStorage::XMLReaderBase::_pos [protected, inherited] |
Definition at line 2667 of file xmlstorage.h.
Definition at line 3107 of file xmlstorage.h.
XMLErrorList XMLStorage::XMLReaderBase::_warnings [protected, inherited] |
Definition at line 2673 of file xmlstorage.h.
Referenced by XMLStorage::XMLReaderBase::clear_errors(), and XMLStorage::XMLReaderBase::get_warnings().
1.7.2