#include <xmlstorage.h>
Public Member Functions | |
ReadBuffer (XMLErrorList &errors, XMLLocation &location) | |
line buffer for XS-native parser | |
~ReadBuffer () | |
void | reset () |
bool | empty () const |
void | 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 |
Definition at line 2703 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 | ( | ) |
void 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) { _len <<= 1; _buffer = (char*) realloc(_buffer, _len); _wptr = _buffer + wpos; } *_wptr++ = static_cast<char>(c); }
bool XMLStorage::ReadBuffer::empty | ( | ) | const [inline] |
Definition at line 2709 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 159 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=='/') 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 134 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 126 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 107 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 2721 of file xmlstorage.h.
Referenced by append(), empty(), len(), ReadBuffer(), reset(), str(), and ~ReadBuffer().
std::string XMLStorage::ReadBuffer::_buffer_str [protected] |
Definition at line 2724 of file xmlstorage.h.
Referenced by get_attributes(), get_tag(), reset(), and str().
XMLErrorList& XMLStorage::ReadBuffer::_errors [protected] |
Definition at line 2719 of file xmlstorage.h.
Referenced by get_attributes().
size_t XMLStorage::ReadBuffer::_len [protected] |
Definition at line 2723 of file xmlstorage.h.
Referenced by append(), and ReadBuffer().
XMLLocation& XMLStorage::ReadBuffer::_location [protected] |
Definition at line 2720 of file xmlstorage.h.
Referenced by get_attributes(), and get_location().
char* XMLStorage::ReadBuffer::_wptr [protected] |
Definition at line 2722 of file xmlstorage.h.
Referenced by append(), empty(), has_CDEnd(), len(), reset(), and str().
ROS Explorer Source Code Documentation
generated on 02.01.2013 by ![]() |