Public Member Functions | Protected Attributes | Private Member Functions

XMLStorage::ReadBuffer Struct Reference

#include <xmlstorage.h>

Collaboration diagram for XMLStorage::ReadBuffer:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ReadBuffer (XMLErrorList &errors, XMLLocation &location)
 line buffer for XS-native parser
 ~ReadBuffer ()
void reset ()
bool empty () const
bool append (int c)
const std::string & str (bool utf8)
size_t len () const
bool has_CDEnd () const
XS_String get_tag () const
void get_attributes (XMLNode::AttributeMap &attributes) const
 read attributes and values
XMLLocationget_location () const

Protected Attributes

XMLErrorList_errors
XMLLocation_location
char * _buffer
char * _wptr
size_t _len
std::string _buffer_str

Private Member Functions

 ReadBuffer (const ReadBuffer &)

Detailed Description

Definition at line 2791 of file xmlstorage.h.


Constructor & Destructor Documentation

XMLStorage::ReadBuffer::ReadBuffer ( XMLErrorList errors,
XMLLocation location 
)

line buffer for XS-native parser

Definition at line 73 of file xs-native.cpp.

References _buffer, _len, BUFFER_LEN, and reset().

 :  _errors(errors),
    _location(location)
{
    _buffer = (char*) malloc(BUFFER_LEN);
    _len = BUFFER_LEN;

    reset();
}

Here is the call graph for this function:

XMLStorage::ReadBuffer::~ReadBuffer (  )

Definition at line 83 of file xs-native.cpp.

References _buffer.

{
    free(_buffer);
}
XMLStorage::ReadBuffer::ReadBuffer ( const ReadBuffer  ) [private]

Member Function Documentation

bool XMLStorage::ReadBuffer::append ( int  c )

Definition at line 94 of file xs-native.cpp.

References _buffer, _len, and _wptr.

Referenced by XMLStorage::ParseContext::process_next().

{
    size_t wpos = _wptr-_buffer;

    if (wpos >= _len) {
        size_t new_len = _len << 1;

        void* new_ptr = realloc(_buffer, new_len);

        if (new_ptr) {
            _buffer = (char*)new_ptr;
            _wptr = _buffer + wpos;
            _len = new_len;
        } else
            return false; // memory allocation failure
    }

    *_wptr++ = static_cast<char>(c);

    return true;
}

Here is the caller graph for this function:

bool XMLStorage::ReadBuffer::empty (  ) const [inline]

Definition at line 2797 of file xmlstorage.h.

References _buffer, and _wptr.

Referenced by XMLStorage::ParseContext::process_next().

{return _wptr==_buffer;}

Here is the caller graph for this function:

void XMLStorage::ReadBuffer::get_attributes ( XMLNode::AttributeMap attributes ) const

read attributes and values

Definition at line 168 of file xs-native.cpp.

References _buffer_str, _errors, _location, XMLStorage::DecodeXMLString(), and XMLStorage::get_xmlsym_end_utf8().

Referenced by XMLStorage::ParseContext::process_next().

{
    const char* p = _buffer_str.c_str();

     // find end of tag name
    if (*p == '<')
        ++p;

    if (*p == '/')
        ++p;
    else if (*p == '?')
        ++p;

    p = get_xmlsym_end_utf8(p);

     // read attributes from buffer
    while(*p && *p!='>' && *p!='/') {
        while(isspace((unsigned char)*p))
            ++p;

        if (*p=='?' || *p=='>' || *p=='/')
            break;

        const char* attr_name = p;

        p = get_xmlsym_end_utf8(p);

        if (*p != '=') {
            _errors.push_back(XMLError(_location, "missing attribute assignment"));
            break;
        }

        size_t attr_len = p - attr_name;

        if (*++p!='"' && *p!='\'') {
            _errors.push_back(XMLError(_location, "missing attribute value quote"));
            break;
        }

        char delim = *p;
        const char* value = ++p;

        while(*p && *p!=delim)
            ++p;

        size_t value_len = p - value;

        if (*p)
            ++p;    // '"' oder '\''
        else
            _errors.push_back(XMLError(_location, "unterminated attribute quote"));

#ifdef XS_STRING_UTF8
        XS_String name_str(attr_name, attr_len);
#else
        XS_String name_str;
        assign_utf8(name_str, attr_name, attr_len);
#endif

        attributes[name_str] = DecodeXMLString(std::string(value, value_len));
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

XMLLocation& XMLStorage::ReadBuffer::get_location (  ) const [inline]

Definition at line 2804 of file xmlstorage.h.

References _location.

{return _location;}
XS_String XMLStorage::ReadBuffer::get_tag (  ) const

Definition at line 143 of file xs-native.cpp.

References _buffer_str, XMLStorage::from_utf8(), and XMLStorage::get_xmlsym_end_utf8().

Referenced by XMLStorage::ParseContext::process_next().

{
    const char* p = _buffer_str.c_str();

    if (*p == '<')
        ++p;

    if (*p == '/')
        ++p;

    const char* q = p;

    if (*q == '?')
        ++q;

    q = get_xmlsym_end_utf8(q);

#ifdef XS_STRING_UTF8
    return XS_String(p, q-p);
#else
    return from_utf8(p, q-p);
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool XMLStorage::ReadBuffer::has_CDEnd (  ) const

Definition at line 135 of file xs-native.cpp.

References _wptr, and CDATA_END.

Referenced by XMLStorage::ParseContext::process_next().

{
    //if (_wptr-_buffer < 3)
    //  return false;

    return !strncmp(_wptr-3, CDATA_END, 3);
}

Here is the caller graph for this function:

size_t XMLStorage::ReadBuffer::len (  ) const

Definition at line 130 of file xs-native.cpp.

References _buffer, and _wptr.

{
    return _wptr - _buffer;
}
void XMLStorage::ReadBuffer::reset (  )

Definition at line 88 of file xs-native.cpp.

References _buffer, _buffer_str, and _wptr.

Referenced by XMLStorage::ParseContext::process_next(), and ReadBuffer().

{
    _wptr = _buffer;
    _buffer_str.erase();
}

Here is the caller graph for this function:

const std::string & XMLStorage::ReadBuffer::str ( bool  utf8 )

Definition at line 116 of file xs-native.cpp.

References _buffer, _buffer_str, and _wptr.

Referenced by XMLStorage::ParseContext::process_next().

{
#if defined(_WIN32) && !defined(XS_STRING_UTF8)
    if (utf8)
#endif
        _buffer_str.assign(_buffer, _wptr-_buffer);
#if defined(_WIN32) && !defined(XS_STRING_UTF8)
    else
        _buffer_str = get_utf8(_buffer, _wptr-_buffer);
#endif

    return _buffer_str;
}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 2809 of file xmlstorage.h.

Referenced by append(), empty(), len(), ReadBuffer(), reset(), str(), and ~ReadBuffer().

std::string XMLStorage::ReadBuffer::_buffer_str [protected]

Definition at line 2812 of file xmlstorage.h.

Referenced by get_attributes(), get_tag(), reset(), and str().

Definition at line 2807 of file xmlstorage.h.

Referenced by get_attributes().

size_t XMLStorage::ReadBuffer::_len [protected]

Definition at line 2811 of file xmlstorage.h.

Referenced by append(), and ReadBuffer().

Definition at line 2808 of file xmlstorage.h.

Referenced by get_attributes(), and get_location().

char* XMLStorage::ReadBuffer::_wptr [protected]

Definition at line 2810 of file xmlstorage.h.

Referenced by append(), empty(), has_CDEnd(), len(), reset(), and str().


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