#include <xmlstorage.h>

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 | |
| XMLLocation & | get_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 &) | |
Definition at line 2791 of file xmlstorage.h.
| 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(); }

| XMLStorage::ReadBuffer::~ReadBuffer | ( | ) |
| XMLStorage::ReadBuffer::ReadBuffer | ( | const ReadBuffer & | ) | [private] |
| 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;
}

| bool XMLStorage::ReadBuffer::empty | ( | ) | const [inline] |
Definition at line 2797 of file xmlstorage.h.
References _buffer, and _wptr.
Referenced by XMLStorage::ParseContext::process_next().

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


| XMLLocation& XMLStorage::ReadBuffer::get_location | ( | ) | const [inline] |
| 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
}


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

| size_t XMLStorage::ReadBuffer::len | ( | ) | const |
| 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();
}

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

char* XMLStorage::ReadBuffer::_buffer [protected] |
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().
XMLErrorList& XMLStorage::ReadBuffer::_errors [protected] |
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().
XMLLocation& XMLStorage::ReadBuffer::_location [protected] |
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().
1.7.2