line buffer for XS-native parser More...

Public Member Functions | |
| this () | |
| void | reset () |
| void | append (char c) |
| char[] | str () |
| size_t | len () |
| bool | has_CDEnd () |
| char[] | get_tag () |
| void | get_attributes (out XMLNode.AttributeMap attributes) |
| read attributes and values | |
Protected Attributes | |
| char[] | _buffer |
| int | _idx_write |
| char[] | _buffer_str |
line buffer for XS-native parser
Definition at line 1584 of file xmlstorage.d.
| xmlstorage::Buffer::this | ( | ) | [inline] |
Definition at line 1586 of file xmlstorage.d.
References xmlstorage::BUFFER_LEN.
{
_buffer.length = BUFFER_LEN;
reset();
}
| void xmlstorage::Buffer::append | ( | char | c ) | [inline] |
Definition at line 1599 of file xmlstorage.d.
Referenced by xmlstorage::XMLReaderBase::parse().
{
if (_idx_write >= _buffer.length)
_buffer.length = _buffer.length << 1;
_buffer[_idx_write++] = c;
}

| void xmlstorage::Buffer::get_attributes | ( | out XMLNode.AttributeMap | attributes ) | [inline] |
read attributes and values
Definition at line 1650 of file xmlstorage.d.
References xmlstorage::DecodeXMLString(), and xmlstorage::isxmlsym().
Referenced by xmlstorage::XMLReaderBase::parse().
{
int i;
// skip opening tag characters
if (_buffer_str.length>=1 && _buffer_str[0]=='<') {
if (_buffer_str.length>=2 && (_buffer_str[1]=='/' || _buffer_str[i]=='?'))
i = 2;
else
i = 1;
} else
i = 0;
// find end of tag name
while(i<_buffer_str.length && isxmlsym(_buffer_str[i]))
++i;
// read attributes from buffer
while(i<_buffer_str.length && _buffer_str[i]!='>' && _buffer_str[i]!='/') {
while(isspace(cast(dchar)_buffer_str[i]))
++i;
int attr_idx = i;
while(isxmlsym(_buffer_str[i]))
++i;
if (i>=_buffer_str.length || _buffer_str[i] != '=')
break; //@TODO error handling
int attr_end = i;
if (++i>=_buffer_str.length || _buffer_str[i]!='"' && _buffer_str[i]!='\'')
break; //@TODO error handling
char delim = _buffer_str[i];
int value_idx = ++i;
while(i<_buffer_str.length && _buffer_str[i]!=delim)
++i;
int value_end = i;
if (i < _buffer_str.length)
++i; // '"'
char[] name_str = _buffer_str[attr_idx .. attr_end];
char[] value_str = _buffer_str[value_idx .. value_end];
attributes[name_str.dup] = DecodeXMLString(value_str).dup;
}
}


| char [] xmlstorage::Buffer::get_tag | ( | ) | [inline] |
Definition at line 1624 of file xmlstorage.d.
References xmlstorage::isxmlsym().
Referenced by xmlstorage::XMLReaderBase::parse().
{
int i;
// skip opening tag characters
if (_buffer_str.length>=1 && _buffer_str[0]=='<') {
if (_buffer_str.length>=2 && _buffer_str[1]=='/')
i = 2;
else
i = 1;
} else
i = 0;
int j = i;
if (j<_buffer_str.length && _buffer_str[j]=='?')
++j;
// find end of tag name
while(j<_buffer_str.length && isxmlsym(_buffer_str[j]))
++j;
return _buffer_str[i..j];
}


| bool xmlstorage::Buffer::has_CDEnd | ( | ) | [inline] |
Definition at line 1619 of file xmlstorage.d.
Referenced by xmlstorage::XMLReaderBase::parse().
{
return _idx_write>=3 && _buffer[0..2]=="]]>";
}

| size_t xmlstorage::Buffer::len | ( | ) | [inline] |
Definition at line 1614 of file xmlstorage.d.
{
return _idx_write;
}
| void xmlstorage::Buffer::reset | ( | ) | [inline] |
Definition at line 1593 of file xmlstorage.d.
Referenced by xmlstorage::XMLReaderBase::parse().
{
_idx_write = 0;
_buffer_str.length = 0;
}

| char [] xmlstorage::Buffer::str | ( | ) | [inline] |
Definition at line 1607 of file xmlstorage.d.
Referenced by xmlstorage::XMLReaderBase::parse().
{
_buffer_str = _buffer[0 .. _idx_write];
return _buffer_str;
}

char [] xmlstorage::Buffer::_buffer [protected] |
Definition at line 1704 of file xmlstorage.d.
char [] xmlstorage::Buffer::_buffer_str [protected] |
Definition at line 1706 of file xmlstorage.d.
int xmlstorage::Buffer::_idx_write [protected] |
Definition at line 1705 of file xmlstorage.d.
1.7.2