Classes | |
class | tifstream |
utility input file stream More... | |
class | tofstream |
utility output file stream More... | |
class | XMLError |
XML Error with message and location. More... | |
class | XMLErrorList |
list of XMLError entries More... | |
class | StyleSheet |
XML Stylesheet entry. More... | |
class | StyleSheetList |
list of StyleSheet entries More... | |
class | DocType |
XML document type description. More... | |
class | XMLFormat |
Management of XML file headers and formating. More... | |
class | XMLNode |
in memory representation of an XML node More... | |
class | XMLChildrenFilter |
iterator access to children nodes with name filtering More... | |
class | XMLPos |
iterator for XML trees More... | |
class | XMLBool |
type converter for boolean data More... | |
class | XMLBoolRef |
type converter for boolean data with write access More... | |
class | XMLInt |
type converter for integer data More... | |
class | XMLIntRef |
type converter for integer data with write access More... | |
class | XMLDouble |
type converter for numeric data More... | |
class | XMLDoubleRef |
type converter for numeric data with write access More... | |
class | XMLString |
type converter for string data More... | |
class | XMLStringRef |
type converter for string data with write access More... | |
class | Buffer |
line buffer for XS-native parser More... | |
class | XMLReaderBase |
XML reader base class. More... | |
class | XMLReader |
XML reader class. More... | |
class | XMLDoc |
XML document holder. More... | |
class | XMLMessage |
XML message wrapper. More... | |
class | XMLMessageFromString |
helper structure to read XML messages from strings More... | |
class | XMLMessageReader |
Reader for XML Messages. More... | |
class | XMLWriter |
on the fly XML writer More... | |
Enumerations | |
enum | PRETTY_FLAGS { PRETTY_PLAIN = 0, PRETTY_LINEFEED = 1, PRETTY_INDENT = 2 } |
enum | WRITE_MODE { FORMAT_PLAIN, FORMAT_SMART, FORMAT_ORIGINAL, FORMAT_PRETTY } |
Functions | |
int | isxmlsym (byte c) |
class | list (T) |
class | stack (T) |
version (XMLNODE_LOCATION) | |
void read_option() | T (out T var, XMLPos cfg, char[] key) |
void read_option() | T (out int var, XMLPos cfg, char[] key) |
char[] | unescape (in char[] str, char b, char e) |
remove escape characters from string | |
char[] | unescape (in char[] s) |
char[] | EncodeXMLString (in char[] str, bool cdata=false) |
encode XML string literals | |
bool | icmpLiteral (in char[] str, in char[] lit_str, inout int i) |
char[] | DecodeXMLString (in char[] str) |
decode XML string literals | |
Variables | |
const | BUFFER_LEN = 2048 |
const char[] | XS_TRUE = "true" |
const char[] | XS_FALSE = "false" |
const char[] | XS_INTFMT = "%d" |
const char[] | XS_FLOATFMT = "%d" |
const char[] | XS_EMPTY = "" |
const char[] | XML_INDENT_SPACE = " " |
Definition at line 283 of file xmlstorage.d.
{ PRETTY_PLAIN = 0, PRETTY_LINEFEED = 1, PRETTY_INDENT = 2 };
Definition at line 490 of file xmlstorage.d.
{ FORMAT_PLAIN, /// write XML without any white space FORMAT_SMART, /// preserve original white space and comments if present; pretty print otherwise FORMAT_ORIGINAL, /// write XML stream preserving original white space and comments FORMAT_PRETTY /// pretty print node to stream without preserving original white space };
char [] xmlstorage::DecodeXMLString | ( | in char[] | str ) |
decode XML string literals
Definition at line 2588 of file xmlstorage.d.
References icmpLiteral().
Referenced by xmlstorage::Buffer::get_attributes(), and xmlstorage::XMLNode::get_content().
{ char[] buffer; buffer.length = str.length; size_t o = 0; bool modified = false; for(int i=0; i<str.length; ++i) { if (str[i] == '&') { char[] cur = str[i+1..length]; if (icmpLiteral(cur, "lt;", i)) {buffer[o++] = '<'; modified = true;} else if (icmpLiteral(cur, "gt;", i)) {buffer[o++] = '>'; modified = true;} else if (icmpLiteral(cur, "amp;", i)) {buffer[o++] = '&'; modified = true;} else if (icmpLiteral(cur, "quot;", i)) {buffer[o++] = '\"'; modified = true;} else if (icmpLiteral(cur, "apos;", i)) {buffer[o++] = '\''; modified = true;} else buffer[o++] = str[i]; } else if (i+9<=str.length && !icmp(str[i..i+9], "<![CDATA[")) { // search for CDEnd "]]>" for(int e=i+9; ; ++e) { if (e+3 > str.length) { buffer[o++] = str[i]; break; } if (str[e..e+3] == "]]>") { i += 9; size_t l = e - i; buffer[o..o+l] = str[i..i+l]; o += l; i += l + 2; modified = true; break; } } } else buffer[o++] = str[i]; } return modified? buffer[0..o]: str; }
char [] xmlstorage::EncodeXMLString | ( | in char[] | str, |
bool | cdata = false |
||
) |
encode XML string literals
Definition at line 2487 of file xmlstorage.d.
References BUFFER_LEN.
Referenced by xmlstorage::XMLNode::plain_write_worker(), xmlstorage::XMLNode::pretty_write_worker(), xmlstorage::XMLWriter::set_content(), xmlstorage::XMLNode::set_content(), xmlstorage::XMLNode::smart_write_worker(), xmlstorage::XMLWriter::write_attributes(), xmlstorage::XMLWriter::write_post(), xmlstorage::XMLWriter::write_pre(), and xmlstorage::XMLNode::write_worker().
{ char[] s = str; size_t l = str.length; if (cdata) { // encode the whole string in a CDATA section char[] ret = "<![CDATA["; ret ~= str; ret ~= "]]>"; return ret; } else if (l <= BUFFER_LEN) { char[] buffer; buffer.length = 6*str.length; // worst case """ / "'" int w = 0; foreach(char c; s) switch(c) { case '&': buffer[w++] = '&'; buffer[w++] = 'a'; buffer[w++] = 'm'; buffer[w++] = 'p'; buffer[w++] = ';'; // "&" break; case '<': buffer[w++] = '&'; buffer[w++] = 'l'; buffer[w++] = 't'; buffer[w++] = ';'; // "<" break; case '>': buffer[w++] = '&'; buffer[w++] = 'g'; buffer[w++] = 't'; buffer[w++] = ';'; // ">" break; case '"': buffer[w++] = '&'; buffer[w++] = 'q'; buffer[w++] = 'u'; buffer[w++] = 'o'; buffer[w++] = 't'; buffer[w++] = ';'; // """ break; case '\'': buffer[w++] = '&'; buffer[w++] = 'a'; buffer[w++] = 'p'; buffer[w++] = 'o'; buffer[w++] = 's'; buffer[w++] = ';'; // "'" break; default: if (cast(dchar)c<20 && c!='\t' && c!='\r' && c!='\n') { char[] b = format("&%d;", cast(int)c); foreach(cc; b) buffer[w++] = cc; } else buffer[w++] = c; } buffer.length = w; return buffer; } else { // l > BUFFER_LEN // alternative code for larger strings using a memory stream Stream o = new MemoryStream; foreach(c; str) switch(c) { case '&': o.writeString("&"); break; case '<': o.writeString("<"); break; case '>': o.writeString(">"); break; case '"': o.writeString("""); break; case '\'': o.writeString("'"); break; default: if (cast(dchar)c<20 && c!='\t' && c!='\r' && c!='\n') o.writeString(format("&%d;", cast(int)c)); else o.write(c); } return o.toString(); } }
bool xmlstorage::icmpLiteral | ( | in char[] | str, |
in char[] | lit_str, | ||
inout int | i | ||
) |
Definition at line 2578 of file xmlstorage.d.
Referenced by DecodeXMLString().
{ if (str.length>=lit_str.length && !icmp(str[0..lit_str.length], lit_str)) { i += lit_str.length; return true; } else return false; }
int xmlstorage::isxmlsym | ( | byte | c ) |
Definition at line 60 of file xmlstorage.d.
Referenced by xmlstorage::Buffer::get_attributes(), xmlstorage::Buffer::get_tag(), and xmlstorage::DocType::parse().
{ return isalnum(c) || c=='_' || c=='-'; }
class xmlstorage::list | ( | T | ) |
Definition at line 92 of file xmlstorage.d.
References T().
{ public: void push_back(T entry) { _entries.length = _entries.length + 1; _entries[_entries.length-1] = entry; } T front() { assert(_entries.length>0); return _entries[0]; } T back() { assert(_entries.length>0); return _entries[_entries.length-1]; } bool empty() { return !_entries.length; } int length() { return _entries.length; } void clear() { foreach(entry; _entries) delete entry; _entries = null; } int opApply(int delegate(inout T) dg) { int result = 0; foreach(e; _entries) { result = dg(e); if (result) break; } return result; } protected: T[] _entries; };
class xmlstorage::stack | ( | T | ) |
Definition at line 150 of file xmlstorage.d.
References T().
Referenced by xmlstorage::XMLWriter::this(), and xmlstorage::XMLPos::this().
{ public: void push(T entry) { _entries.length = _entries.length + 1; _entries[_entries.length-1] = entry; } T pop() { assert(_entries.length>0); T ret = _entries[_entries.length-1]; _entries.length = _entries.length - 1; return ret; } T top() { assert(_entries.length>0); return _entries[_entries.length-1]; } bool empty() { return !_entries.length; } int length() { return _entries.length; } void clear() { foreach(entry; _entries) delete entry; _entries = null; } protected: T[] _entries; };
void read_option() xmlstorage::T | ( | out T | var, |
XMLPos | cfg, | ||
char[] | key | ||
) |
Definition at line 1565 of file xmlstorage.d.
Referenced by list(), and stack().
{ char[] val = cfg.get(key); if (!val.empty()) var = val; }
void read_option() xmlstorage::T | ( | out int | var, |
XMLPos | cfg, | ||
char[] | key | ||
) |
Definition at line 1573 of file xmlstorage.d.
{ char[] val = cfg.get(key); if (!val.empty()) var = atoi(val); }
char [] xmlstorage::unescape | ( | in char[] | s ) |
Definition at line 2480 of file xmlstorage.d.
References unescape().
{ return unescape(s, '"', '"'); }
char [] xmlstorage::unescape | ( | in char[] | str, |
char | b, | ||
char | e | ||
) |
remove escape characters from string
Definition at line 2472 of file xmlstorage.d.
Referenced by xmlstorage::XMLNode::get_child_relative(), and unescape().
{ if (str.length>0 && str[0]==b && str[length-1]==e) return str[1 .. length-1]; else return str; }
xmlstorage::version | ( | XMLNODE_LOCATION | ) |
location of XML Node including XML file name
Definition at line 250 of file xmlstorage.d.
Referenced by xmlstorage::XMLDoc::read(), xmlstorage::XMLReaderBase::StartElementHandler(), and xmlstorage::XMLNode::this().
{ /// location of XML Node including XML file name class XMLLocation { this() { _display_path = null; _line = 0; _column = 0; } this(in char[] display_path, int line, int column) { _display_path = display_path; _line = line; _column = column; } char[] str() { return ""; //TODO } protected: char[] _display_path; // character pointer for fast reference int _line; int _column; }; } // XMLNODE_LOCATION
const xmlstorage::BUFFER_LEN = 2048 |
Definition at line 49 of file xmlstorage.d.
Referenced by EncodeXMLString(), and xmlstorage::Buffer::this().
const char [] xmlstorage::XML_INDENT_SPACE = " " |
Definition at line 199 of file xmlstorage.d.
Referenced by xmlstorage::XMLNode::pretty_write_worker(), xmlstorage::XMLNode::smart_write_worker(), xmlstorage::XMLWriter::write_post(), and xmlstorage::XMLWriter::write_pre().
const char [] xmlstorage::XS_EMPTY = "" |
Definition at line 57 of file xmlstorage.d.
const char [] xmlstorage::XS_FALSE = "false" |
Definition at line 52 of file xmlstorage.d.
Referenced by xmlstorage::XMLBoolRef::assign(), and xmlstorage::XMLBool::str().
const char [] xmlstorage::XS_FLOATFMT = "%d" |
Definition at line 55 of file xmlstorage.d.
Referenced by xmlstorage::XMLDoubleRef::assign(), and xmlstorage::XMLDouble::str().
const char [] xmlstorage::XS_INTFMT = "%d" |
Definition at line 54 of file xmlstorage.d.
Referenced by xmlstorage::XMLIntRef::assign(), and xmlstorage::XMLInt::str().
const char [] xmlstorage::XS_TRUE = "true" |
Definition at line 51 of file xmlstorage.d.
Referenced by xmlstorage::XMLBoolRef::assign(), xmlstorage::XMLBoolRef::opCast(), xmlstorage::XMLBoolRef::opNot(), xmlstorage::XMLBool::str(), and xmlstorage::XMLBool::this().