Classes | |
| struct | XS_String |
| string class for TCHAR strings More... | |
| struct | tifstream |
| struct | tofstream |
| 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 | 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 | 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 | 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 | XMLReaderBase |
| XML reader base class. More... | |
| struct | XMLReader |
| XML file reader. More... | |
| struct | XMLDoc |
| XML document holder. 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... | |
| struct | Buffer |
| line buffer for XS-native parser 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 | |
| static std::string | unescape (const char *s, char b, char e) |
| remove escape characters from zero terminated string | |
| std::string | unescape (const char *s) |
| static std::string | unescape (const char *s, size_t l, char b, char e) |
| remove escape characters from string with specified length | |
| std::string | unescape (const char *s, size_t l) |
| std::string | EncodeXMLString (const XS_String &str, bool cdata) |
| encode XML string literals | |
| XS_String | DecodeXMLString (const std::string &str) |
| decode XML string literals | |
| std::ostream & | operator<< (std::ostream &out, const XMLError &err) |
| const char * | get_xmlsym_end_utf8 (const char *p) |
| 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 2696 of file xmlstorage.h.
Definition at line 717 of file xmlstorage.h.
00718 { 00719 PRETTY_PLAIN = 0, 00720 PRETTY_LINEFEED = 1, 00721 PRETTY_INDENT = 2
Definition at line 804 of file xmlstorage.h.
00805 { 00806 FORMAT_PLAIN, /// write XML without any white space 00807 FORMAT_SMART, /// preserve original white space and comments if present; pretty print otherwise 00808 FORMAT_ORIGINAL, /// write XML stream preserving original white space and comments 00809 FORMAT_PRETTY /// pretty print node to stream without preserving original white space
| XS_String XMLStorage::DecodeXMLString | ( | const std::string & | str | ) |
decode XML string literals
Definition at line 473 of file xmlstorage.cpp.
Referenced by XMLStorage::Buffer::get_attributes(), and XMLStorage::XMLNode::get_content().
00477 { 00478 #ifdef XS_STRING_UTF8 00479 const XS_String& str_utf8 = str; 00480 #else 00481 XS_String str_utf8; 00482 assign_utf8(str_utf8, str.c_str(), str.length()); 00483 #endif 00484 00485 LPCXSSTR s = str_utf8.c_str(); 00486 LPXSSTR buffer = (LPXSSTR)alloca(sizeof(XS_CHAR)*XS_len(s)); 00487 LPXSSTR o = buffer; 00488 00489 for(LPCXSSTR p=s; *p; ++p) 00490 if (*p == '&') { 00491 if (!XS_nicmp(p+1, XS_TEXT("lt;"), 3)) { 00492 *o++ = '<'; 00493 p += 3; 00494 } else if (!XS_nicmp(p+1, XS_TEXT("gt;"), 3)) { 00495 *o++ = '>'; 00496 p += 3; 00497 } else if (!XS_nicmp(p+1, XS_TEXT("amp;"), 4)) { 00498 *o++ = '&'; 00499 p += 4; 00500 } else if (!XS_nicmp(p+1, XS_TEXT("quot;"), 5)) { 00501 *o++ = '"'; 00502 p += 5; 00503 } else if (!XS_nicmp(p+1, XS_TEXT("apos;"), 5)) { 00504 *o++ = '\''; 00505 p += 5; 00506 } else //@@ maybe decode "&#xx;" special characters 00507 *o++ = *p; 00508 } else if (*p=='<' && !XS_nicmp(p+1,XS_TEXT("
| std::string XMLStorage::EncodeXMLString | ( | const XS_String & | str, | |
| bool | cdata | |||
| ) |
encode XML string literals
Definition at line 372 of file xmlstorage.cpp.
References BUFFER_LEN, CDATA_END, CDATA_START, LPCXSSTR, LPXSSTR, XS_CHAR, XS_len, and XMLStorage::XS_String::XS_String().
Referenced by XMLStorage::XMLWriter::set_content(), and XMLStorage::XMLNode::set_content().
00373 { 00374 LPCXSSTR s = str.c_str(); 00375 size_t l = XS_len(s); 00376 00377 if (cdata) { 00378 // encode the whole string in a CDATA section 00379 std::string ret = CDATA_START; 00380 00381 #ifdef XS_STRING_UTF8 00382 ret += str; 00383 #else 00384 ret += get_utf8(str); 00385 #endif 00386 00387 ret += CDATA_END; 00388 00389 return ret; 00390 } else if (l <= BUFFER_LEN) { 00391 LPXSSTR buffer = (LPXSSTR)alloca(6*sizeof(XS_CHAR)*XS_len(s)); // worst case """ / "'" 00392 LPXSSTR o = buffer; 00393 00394 for(LPCXSSTR p=s; *p; ++p) 00395 switch(*p) { 00396 case '&': 00397 *o++ = '&'; *o++ = 'a'; *o++ = 'm'; *o++ = 'p'; *o++ = ';'; // "&" 00398 break; 00399 00400 case '<': 00401 *o++ = '&'; *o++ = 'l'; *o++ = 't'; *o++ = ';'; // "<" 00402 break; 00403 00404 case '>': 00405 *o++ = '&'; *o++ = 'g'; *o++ = 't'; *o++ = ';'; // ">" 00406 break; 00407 00408 case '"': 00409 *o++ = '&'; *o++ = 'q'; *o++ = 'u'; *o++ = 'o'; *o++ = 't'; *o++ = ';'; // """ 00410 break; 00411 00412 case '\'': 00413 *o++ = '&'; *o++ = 'a'; *o++ = 'p'; *o++ = 'o'; *o++ = 's'; *o++ = ';'; // "'" 00414 break; 00415 00416 default: 00417 if ((unsigned)*p<0x20 && *p!='\t' && *p!='\r' && *p!='\n') { 00418 char b[16]; 00419 sprintf(b, "&#%d;", (unsigned)*p); 00420 for(const char*q=b; *q; ) 00421 *o++ = *q++; 00422 } else 00423 *o++ = *p; 00424 } 00425 00426 #ifdef XS_STRING_UTF8 00427 return XS_String(buffer, o-buffer); 00428 #else 00429 return get_utf8(buffer, o-buffer); 00430 #endif 00431 } else { // l > BUFFER_LEN 00432 // alternative code for larger strings using ostringstream 00433 // and avoiding to use alloca() for preallocated memory 00434 fast_ostringstream out; 00435 00436 LPCXSSTR s = str.c_str(); 00437 00438 for(LPCXSSTR p=s; *p; ++p) 00439 switch(*p) { 00440 case '&': 00441 out << "&"; 00442 break; 00443 00444 case '<': 00445 out << "<"; 00446 break; 00447 00448 case '>': 00449 out << ">"; 00450 break; 00451 00452 case '"': 00453 out << """; 00454 break; 00455 00456 case '\'': 00457 out << "'"; 00458 break; 00459 00460 default: 00461 if ((unsigned)*p<0x20 && *p!='\t' && *p!='\r' && *p!='\n') 00462 out << "&#" << (unsigned)*p << ";"; 00463 else 00464 out << *p; 00465 } 00466 00467 #ifdef XS_STRING_UTF8 00468 return XS_String(out.str()); 00469 #else 00470 return get_utf8(out.str());


| const char * XMLStorage::get_xmlsym_end_utf8 | ( | const char * | p | ) |
Definition at line 676 of file xmlstorage.cpp.
Referenced by XMLStorage::Buffer::get_attributes(), and XMLStorage::Buffer::get_tag().
00681 { 00682 for(; *p; ++p) { 00683 char c = *p; 00684 00685 // NameChar ::= Letter | Digit | '.' | '-' | '_' | ':' | CombiningChar | Extender 00686 if (c == '\xC3') // UTF-8 escape character 00687 ++p; //TODO only continue on umlaut characters 00688 else if (!isalnum(c) && c!='.' && c!='-' && c!='_' && c!=':') 00689 break;

| std::ostream& XMLStorage::operator<< | ( | std::ostream & | out, | |
| const XMLError & | err | |||
| ) |
Definition at line 667 of file xmlstorage.cpp.
Referenced by XMLStorage::XMLError::XMLError().

| void XMLStorage::read_option | ( | int & | var, | |
| const_XMLPos & | cfg, | |||
| LPCXSSTR | key | |||
| ) | [inline] |
Definition at line 2265 of file xmlstorage.h.
References XMLStorage::const_XMLPos::get(), and XS_toi.
02267 { 02268 const XS_String& val = cfg.get(key); 02269 02270 if (!val.empty()) 02271 var = XS_toi(val.c_str());

| void XMLStorage::read_option | ( | T & | var, | |
| const_XMLPos & | cfg, | |||
| LPCXSSTR | key | |||
| ) | [inline] |
Definition at line 2255 of file xmlstorage.h.
References XMLStorage::const_XMLPos::get().

| std::string XMLStorage::unescape | ( | const char * | s, | |
| size_t | l | |||
| ) | [inline] |
Definition at line 105 of file xmlstorage.cpp.
References unescape().
00106 { 00107 return unescape(s, l, '"', '"'); 00108 }

| static std::string XMLStorage::unescape | ( | const char * | s, | |
| size_t | l, | |||
| char | b, | |||
| char | e | |||
| ) | [static] |
remove escape characters from string with specified length
Definition at line 88 of file xmlstorage.cpp.
00089 { 00090 const char* end = s + l; 00091 00092 // if (*s == b) 00093 // ++s; 00094 // 00095 // if (end>s && end[-1]==e) 00096 // --end; 00097 00098 if (*s == b) 00099 if (end>s && end[-1]==e) 00100 ++s, --end; 00101 00102 return std::string(s, end-s); 00103 }
| std::string XMLStorage::unescape | ( | const char * | s | ) | [inline] |
Definition at line 82 of file xmlstorage.cpp.
References unescape().
00083 { 00084 return unescape(s, '"', '"'); 00085 }

| static std::string XMLStorage::unescape | ( | const char * | s, | |
| char | b, | |||
| char | e | |||
| ) | [static] |
remove escape characters from zero terminated string
Definition at line 65 of file xmlstorage.cpp.
Referenced by XMLStorage::XPathElement::parse(), and unescape().
00066 { 00067 const char* end = s + strlen(s); 00068 00069 // if (*s == b) 00070 // ++s; 00071 // 00072 // if (end>s && end[-1]==e) 00073 // --end; 00074 00075 if (*s == b) 00076 if (end>s && end[-1]==e) 00077 ++s, --end; 00078 00079 return std::string(s, end-s); 00080 }

| const XS_String XMLStorage::XS_KEY = XS_KEY_STR |
Definition at line 59 of file xmlstorage.cpp.
Referenced by XMLStorage::XMLPos::set_property(), and XMLStorage::XMLProperty::XMLProperty().
| const XS_String XMLStorage::XS_PROPERTY = XS_PROPERTY_STR |
Definition at line 61 of file xmlstorage.cpp.
Referenced by XMLStorage::XMLPropertyReader::XMLPropertyReader().
| const XS_String XMLStorage::XS_VALUE = XS_VALUE_STR |
Definition at line 60 of file xmlstorage.cpp.
Referenced by XMLStorage::XMLPos::set_property(), and XMLStorage::XMLProperty::XMLProperty().
1.5.4