Classes | |
struct | TmpHeap |
struct | XS_String |
string class for TCHAR strings More... | |
struct | tifstream |
struct | tofstream |
struct | XMLLocation |
location of XML Node including XML file name More... | |
struct | XMLError |
XML Error with message and location. More... | |
struct | XMLErrorList |
list of XMLError entries More... | |
struct | StyleSheet |
XML Stylesheet entry. More... | |
struct | StyleSheetList |
list of StyleSheet entries More... | |
struct | DocType |
XML document type description. More... | |
struct | XMLFormat |
Management of XML file headers and formating. More... | |
struct | HeaderlessXMLFormat |
struct | XS_SMNode |
struct | XS_StringMap |
struct | XPathElement |
struct | XPath |
struct | XMLNode |
in memory representation of an XML node More... | |
struct | XMLChildrenFilter |
iterator access to children nodes with name filtering More... | |
struct | const_XMLChildrenFilter |
read only iterator access to children nodes with name filtering More... | |
struct | XMLPos |
iterator for XML trees More... | |
struct | const_XMLPos |
iterator for XML trees More... | |
struct | XMLReaderBase |
XML reader base class. More... | |
struct | XMLReader |
XML file reader. More... | |
struct | ReadBuffer |
struct | ParseContext |
struct | XMLDoc |
XML document holder. More... | |
struct | XMLStateReader |
struct | XMLStreamReader |
struct | XMLStreamChildrenIterator |
read only iterator access to XMLStreamReader nodes More... | |
struct | XMLStreamChildrenFilter |
read only iterator access to children nodes to XMLStreamReader nodes with name filtering More... | |
struct | XMLBool |
type converter for boolean data More... | |
struct | XMLBoolRef |
type converter for boolean data with write access More... | |
struct | XMLInt |
type converter for integer data More... | |
struct | XMLIntRef |
type converter for integer data with write access More... | |
struct | XMLInt64 |
type converter for integer data More... | |
struct | XMLInt64Ref |
type converter for integer data with write access More... | |
struct | XMLDouble |
type converter for numeric data More... | |
struct | XMLDoubleRef |
type converter for numeric data with write access More... | |
struct | XMLString |
type converter for string data More... | |
struct | XMLStringRef |
type converter for string data with write access More... | |
struct | XMLProperty |
a key/value pair for property data access More... | |
struct | XMLPropertyReader |
utility class to read property settings from a XML tree More... | |
struct | XMLMessage |
XML message wrapper. More... | |
struct | XMLMessageFromString |
helper structure to read XML messages from strings More... | |
struct | XMLMessageReader |
Reader for XML Messages. More... | |
struct | XMLWriter |
on the fly XML writer More... | |
Typedefs | |
typedef std::ostringstream | fast_ostringstream |
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 | |
XS_String | unescape (LPCXSSTR s) |
XS_String | unescape (LPCXSSTR s, size_t l) |
std::string | EncodeXMLString (const XS_String &str, bool cdata) |
encode XML string literals | |
XS_String | DecodeXMLString (const std::string &str_utf8) |
decode XML string literals | |
std::ostream & | operator<< (std::ostream &out, const XMLError &err) |
const char * | get_xmlsym_end_utf8 (const char *p) |
LPCXSSTR | safe_skip_space (LPCXSSTR s) |
template<typename T > | |
XS_String | from_utf8 (const T &s) |
XS_String | from_utf8 (const char *s, size_t l) |
template<typename T > | |
void | read_option (T &var, const_XMLPos &cfg, LPCXSSTR key) |
template<> | |
void | read_option (int &var, const_XMLPos &cfg, LPCXSSTR key) |
Variables | |
const XS_String | XS_KEY = XS_KEY_STR |
const XS_String | XS_VALUE = XS_VALUE_STR |
const XS_String | XS_PROPERTY = XS_PROPERTY_STR |
typedef std::ostringstream XMLStorage::fast_ostringstream |
Definition at line 2836 of file xmlstorage.h.
Definition at line 911 of file xmlstorage.h.
{ PRETTY_PLAIN = 0, PRETTY_LINEFEED = 1, PRETTY_INDENT = 2 };
Definition at line 1031 of file xmlstorage.h.
{ 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 };
XS_String XMLStorage::DecodeXMLString | ( | const std::string & | str_utf8 ) |
decode XML string literals
Definition at line 517 of file xmlstorage.cpp.
References CDATA_END, LPCXSSTR, LPXSSTR, TMP_ALLOC, XS_CHAR, XS_len, XS_nicmp, XS_strstr, and XS_TEXT.
Referenced by XMLStorage::ReadBuffer::get_attributes(), XMLStorage::XMLNode::get_content(), and BookmarkList::import_IE_favorites().
{ #ifdef XS_STRING_UTF8 const XS_String& str = str_utf8; #else XS_String str; assign_utf8(str, str_utf8.c_str(), str_utf8.length()); #endif LPCXSSTR s = str.c_str(); size_t l = XS_len(s); TMP_ALLOC(XS_CHAR, buffer, heap, l); LPXSSTR o = buffer; for(LPCXSSTR p=s; *p; ++p) if (*p == '&') { if (!XS_nicmp(p+1, XS_TEXT("lt;"), 3)) { *o++ = '<'; p += 3; } else if (!XS_nicmp(p+1, XS_TEXT("gt;"), 3)) { *o++ = '>'; p += 3; } else if (!XS_nicmp(p+1, XS_TEXT("amp;"), 4)) { *o++ = '&'; p += 4; } else if (!XS_nicmp(p+1, XS_TEXT("quot;"), 5)) { *o++ = '"'; p += 5; } else if (!XS_nicmp(p+1, XS_TEXT("apos;"), 5)) { *o++ = '\''; p += 5; } else //@@ maybe decode "&#xx;" special characters *o++ = *p; } else if (*p=='<' && !XS_nicmp(p+1,XS_TEXT("![CDATA["),8)) { LPCXSSTR e = XS_strstr(p+9, XS_TEXT(CDATA_END)); if (e) { p += 9; size_t l = e - p; memcpy(o, p, l); o += l; p = e + 2; } else *o++ = *p; } else *o++ = *p; return XS_String(buffer, o-buffer); }
std::string XMLStorage::EncodeXMLString | ( | const XS_String & | str, |
bool | cdata | ||
) |
encode XML string literals
Definition at line 392 of file xmlstorage.cpp.
References BUFFER_LEN, CDATA_END, CDATA_START, LPCXSSTR, LPXSSTR, XS_CHAR, and XS_len.
Referenced by XMLStorage::XMLNode::original_write_worker(), XMLStorage::XMLWriter::set_content(), and XMLStorage::XMLNode::set_content().
{ LPCXSSTR s = str.c_str(); size_t l = XS_len(s); if (cdata) { // encode the whole string in a CDATA section std::string ret = CDATA_START; #ifdef XS_STRING_UTF8 ret += str; #else ret += get_utf8(str); #endif #ifdef XS_STRICT_XML_1_0 for(char*p=&ret.at(9); *p; ++p) // strlen(CDATA_START) == 9 if ((unsigned)*p<0x20 && *p!='\t' && *p!='\r' && *p!='\n') *p = '?'; #endif ret += CDATA_END; return ret; } else if (l <= BUFFER_LEN) { LPXSSTR buffer = (LPXSSTR)alloca(6*sizeof(XS_CHAR)*XS_len(s)); // worst case """ / "'" LPXSSTR o = buffer; for(LPCXSSTR p=s; *p; ++p) switch(*p) { case '&': *o++ = '&'; *o++ = 'a'; *o++ = 'm'; *o++ = 'p'; *o++ = ';'; // "&" break; case '<': *o++ = '&'; *o++ = 'l'; *o++ = 't'; *o++ = ';'; // "<" break; case '>': *o++ = '&'; *o++ = 'g'; *o++ = 't'; *o++ = ';'; // ">" break; case '"': *o++ = '&'; *o++ = 'q'; *o++ = 'u'; *o++ = 'o'; *o++ = 't'; *o++ = ';'; // """ break; case '\'': *o++ = '&'; *o++ = 'a'; *o++ = 'p'; *o++ = 'o'; *o++ = 's'; *o++ = ';'; // "'" break; default: if ((unsigned)*p>=0x20 || *p=='\t' || *p=='\r' || *p=='\n') *o++ = *p; else { #ifdef XS_STRICT_XML_1_0 *o++ = '?'; #else char b[16]; sprintf(b, "&#%d;", (unsigned)*p); for(const char*q=b; *q; ) *o++ = *q++; #endif } } #ifdef XS_STRING_UTF8 return XS_String(buffer, o-buffer); #else return get_utf8(buffer, o-buffer); #endif } else { // l > BUFFER_LEN // alternative code for larger strings using ostringstream // and avoiding to use alloca() for preallocated memory fast_ostringstream out; #ifdef XS_STRING_UTF8 LPCXSSTR s = str.c_str(); #else std::string utf8_str = get_utf8(str); const char* s = utf8_str.c_str(); #endif for(const char* p=s; *p; ++p) switch(*p) { case '&': out << "&"; break; case '<': out << "<"; break; case '>': out << ">"; break; case '"': out << """; break; case '\'': out << "'"; break; default: if ((unsigned)*p>=0x20 || *p=='\t' || *p=='\r' || *p=='\n') out << (unsigned char)*p; else { #ifdef XS_STRICT_XML_1_0 out << '?'; #else out << "&#" << (unsigned)*p << ";"; #endif } } #ifdef XS_STRING_UTF8 return XS_String(out.str()); #else return out.str(); #endif } }
XS_String XMLStorage::from_utf8 | ( | const T & | s ) | [inline] |
Definition at line 542 of file xmlstorage.h.
Referenced by XMLStorage::ReadBuffer::get_tag().
{
return s;
}
XS_String XMLStorage::from_utf8 | ( | const char * | s, |
size_t | l | ||
) | [inline] |
Definition at line 547 of file xmlstorage.h.
{
return XS_String(s, l);
}
const char * XMLStorage::get_xmlsym_end_utf8 | ( | const char * | p ) |
Definition at line 749 of file xmlstorage.cpp.
Referenced by XMLStorage::ReadBuffer::get_attributes(), and XMLStorage::ReadBuffer::get_tag().
{ for(; *p; ++p) { char c = *p; // NameChar ::= Letter | Digit | '.' | '-' | '_' | ':' | CombiningChar | Extender if (c == '\xC3') // UTF-8 escape character ++p; //TODO only continue on umlaut characters else if (!isalnum(c) && c!='.' && c!='-' && c!='_' && c!=':') break; } return p; }
std::ostream& XMLStorage::operator<< | ( | std::ostream & | out, |
const XMLError & | err | ||
) |
void XMLStorage::read_option | ( | T & | var, |
const_XMLPos & | cfg, | ||
LPCXSSTR | key | ||
) | [inline] |
Definition at line 3846 of file xmlstorage.h.
References XMLStorage::const_XMLPos::get().
{ const XS_String& val = cfg.get(key); if (!val.empty()) var = val; }
void XMLStorage::read_option | ( | int & | var, |
const_XMLPos & | cfg, | ||
LPCXSSTR | key | ||
) | [inline] |
Definition at line 3856 of file xmlstorage.h.
References XMLStorage::const_XMLPos::get(), and XS_toi.
{ const XS_String& val = cfg.get(key); if (!val.empty()) var = XS_toi(val.c_str()); }
LPCXSSTR XMLStorage::safe_skip_space | ( | LPCXSSTR | s ) | [inline] |
Definition at line 527 of file xmlstorage.h.
References XS_EMPTY_STR.
Referenced by XMLStorage::XMLBool::XMLBool(), XMLStorage::XMLDouble::XMLDouble(), XMLStorage::XMLInt::XMLInt(), and XMLStorage::XMLInt64::XMLInt64().
{ if (s) { // strip leading white space while(_istspace(*s)) ++s; return s; } else return XS_EMPTY_STR; }
XS_String XMLStorage::unescape | ( | LPCXSSTR | s ) | [inline] |
Definition at line 81 of file xmlstorage.cpp.
{ if (*s == _T('\'')) return unescape(s, _T('\''), _T('\'')); else return unescape(s, _T('"'), _T('"')); }
XS_String XMLStorage::unescape | ( | LPCXSSTR | s, |
size_t | l | ||
) | [inline] |
Definition at line 101 of file xmlstorage.cpp.
{ if (*s == '\'') return unescape(s, l, _T('\''), _T('\'')); else if (*s == '"') return unescape(s, l, _T('"'), _T('"')); else return XS_String(s, l); }
const XS_String XMLStorage::XS_KEY = XS_KEY_STR |
Definition at line 62 of file xmlstorage.cpp.
Referenced by XMLStorage::XMLPos::set_property().
const XS_String XMLStorage::XS_PROPERTY = XS_PROPERTY_STR |
Definition at line 64 of file xmlstorage.cpp.
const XS_String XMLStorage::XS_VALUE = XS_VALUE_STR |
Definition at line 63 of file xmlstorage.cpp.
Referenced by XMLStorage::XMLPos::set_property().
ROS Explorer Source Code Documentation
generated on 02.01.2013 by ![]() |