Public Types | Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | Friends

XMLStorage::XMLStateReader Struct Reference

#include <xmlstorage.h>

Inheritance diagram for XMLStorage::XMLStateReader:
Inheritance graph
[legend]
Collaboration diagram for XMLStorage::XMLStateReader:
Collaboration graph
[legend]

List of all members.

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 XMLFormatget_format () const
const char * get_endl () const
const XMLErrorListget_errors () const
const XMLErrorListget_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

Detailed Description

Definition at line 3076 of file xmlstorage.h.


Member Enumeration Documentation

anonymous enum [protected, inherited]
Enumerator:
TAG_NONE 
TAG_START 
TAG_END 

Definition at line 2670 of file xmlstorage.h.

Enumerator:
XSS_NONE 
XSS_START_ELEMENT 
XSS_END_ELEMENT 
XSS_ELEMENT 
XSS_CHARACTERS 

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
    };

Constructor & Destructor Documentation

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)
    {
    }

Member Function Documentation

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().

{_errors.clear(); _warnings.clear();}

Here is the caller graph for this function:

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.

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;
}

Here is the caller graph for this function:

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();
}

Here is the caller graph for this function:

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";}

Here is the caller graph for this function:

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;}

Here is the caller graph for this function:

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;}

Here is the caller graph for this function:

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();}

Here is the call graph for this function:

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
}

Here is the call graph for this function:

Here is the caller graph for this function:

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();
}

Here is the call graph for this function:

Here is the caller graph for this function:

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);}

Here is the call graph for this function:

Here is the caller graph for this function:

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;
}

Here is the caller graph for this function:


Friends And Related Function Documentation

friend struct ParseContext [friend, inherited]

Definition at line 2701 of file xmlstorage.h.


Member Data Documentation

Definition at line 3109 of file xmlstorage.h.

std::string XMLStorage::XMLReaderBase::_content [protected, inherited]
bool XMLStorage::XMLReaderBase::_endl_defined [protected, inherited]
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]

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.


The documentation for this struct was generated from the following files: