#include <xmlstorage.h>
Public Member Functions | |
XMLNode (const XS_String &name) | |
XMLNode (const XS_String &name, const std::string &leading) | |
XMLNode (const XMLNode &other) | |
virtual | ~XMLNode () |
void | clear () |
XMLNode & | operator= (const XMLNode &other) |
void | add_child (XMLNode *child) |
add a new child node | |
void | put (const XS_String &attr_name, const XS_String &value) |
write access to an attribute | |
XS_String & | operator[] (const XS_String &attr_name) |
C++ write access to an attribute. | |
template<typename T> | |
XS_String | get (const T &attr_name, LPCXSSTR def=XS_EMPTY_STR) const |
read only access to an attribute | |
XS_String | subvalue (const XS_String &name, const XS_String &attr_name, int n=0) const |
convenient value access in children node | |
XS_String & | subvalue (const XS_String &name, const XS_String &attr_name, int n=0) |
convenient storage of distinct values in children node | |
const Children & | get_children () const |
Children & | get_children () |
const AttributeMap & | get_attributes () const |
AttributeMap & | get_attributes () |
XS_String | get_content () const |
void | set_content (const XS_String &s) |
std::ostream & | write (std::ostream &out, const XMLFormat &format, WRITE_MODE mode=FORMAT_SMART, int indent=0) const |
write node with children tree to output stream | |
Protected Member Functions | |
XMLNode * | get_first_child () const |
XMLNode * | find (const XS_String &name, int n=0) const |
XMLNode * | find (const XS_String &name, const XS_String &attr_name, const XS_String &attr_value, int n=0) const |
const XMLNode * | find_relative (const char *path) const |
XPath find function (const). | |
XMLNode * | find_relative (const char *path) |
XPath find function. | |
XMLNode * | create_relative (const char *path) |
relative XPath create function | |
void | write_worker (std::ostream &out, int indent) const |
void | plain_write_worker (std::ostream &out) const |
void | pretty_write_worker (std::ostream &out, const XMLFormat &format, int indent) const |
void | smart_write_worker (std::ostream &out, const XMLFormat &format, int indent) const |
Protected Attributes | |
Children | _children |
AttributeMap | _attributes |
std::string | _leading |
std::string | _content |
std::string | _end_leading |
std::string | _trailing |
Friends | |
struct | XMLPos |
struct | const_XMLPos |
struct | XMLReaderBase |
Data Structures | |
struct | AttributeMap |
struct | Children |
internal children node list More... |
Definition at line 683 of file xmlstorage.h.
XMLStorage::XMLNode::XMLNode | ( | const XS_String & | name | ) | [inline] |
XMLStorage::XMLNode::XMLNode | ( | const XS_String & | name, | |
const std::string & | leading | |||
) | [inline] |
XMLStorage::XMLNode::XMLNode | ( | const XMLNode & | other | ) | [inline] |
Definition at line 774 of file xmlstorage.h.
References _children.
00775 : XS_String(other), 00776 _attributes(other._attributes), 00777 _leading(other._leading), 00778 _content(other._content), 00779 _end_leading(other._end_leading), 00780 _trailing(other._trailing) 00781 #ifdef XMLNODE_LOCATION 00782 , _location(other._location) 00783 #endif 00784 { 00785 for(Children::const_iterator it=other._children.begin(); it!=other._children.end(); ++it) 00786 _children.push_back(new XMLNode(**it)); 00787 }
virtual XMLStorage::XMLNode::~XMLNode | ( | ) | [inline, virtual] |
Definition at line 789 of file xmlstorage.h.
00790 { 00791 while(!_children.empty()) { 00792 delete _children.back(); 00793 _children.pop_back(); 00794 } 00795 }
void XMLStorage::XMLNode::clear | ( | ) | [inline] |
Definition at line 797 of file xmlstorage.h.
Referenced by XMLStorage::XMLNode::Children::clear().
00798 { 00799 _leading.erase(); 00800 _content.erase(); 00801 _end_leading.erase(); 00802 _trailing.erase(); 00803 00804 _attributes.clear(); 00805 _children.clear(); 00806 00807 XS_String::erase(); 00808 }
Definition at line 810 of file xmlstorage.h.
References _attributes, _children, _content, _end_leading, _leading, _trailing, and XMLStorage::XS_String::assign().
00811 { 00812 _children.assign(other._children); 00813 00814 _attributes = other._attributes; 00815 00816 _leading = other._leading; 00817 _content = other._content; 00818 _end_leading = other._end_leading; 00819 _trailing = other._trailing; 00820 00821 return *this; 00822 }
void XMLStorage::XMLNode::add_child | ( | XMLNode * | child | ) | [inline] |
add a new child node
Definition at line 825 of file xmlstorage.h.
00826 { 00827 _children.push_back(child); 00828 }
write access to an attribute
Definition at line 831 of file xmlstorage.h.
00832 { 00833 _attributes[attr_name] = value; 00834 }
C++ write access to an attribute.
Definition at line 837 of file xmlstorage.h.
00838 { 00839 return _attributes[attr_name]; 00840 }
XS_String XMLStorage::XMLNode::get | ( | const T & | attr_name, | |
LPCXSSTR | def = XS_EMPTY_STR | |||
) | const [inline] |
read only access to an attribute
Definition at line 843 of file xmlstorage.h.
Referenced by find(), subvalue(), XMLStorage::XMLBool::XMLBool(), XMLStorage::XMLDouble::XMLDouble(), XMLStorage::XMLInt::XMLInt(), and XMLStorage::XMLString::XMLString().
00844 { 00845 AttributeMap::const_iterator found = _attributes.find(attr_name); 00846 00847 if (found != _attributes.end()) 00848 return found->second; 00849 else 00850 return def; 00851 }
XS_String XMLStorage::XMLNode::subvalue | ( | const XS_String & | name, | |
const XS_String & | attr_name, | |||
int | n = 0 | |||
) | const [inline] |
convenient value access in children node
Definition at line 854 of file xmlstorage.h.
References get(), and XMLStorage::XS_String::XS_String().
00855 { 00856 const XMLNode* node = find(name, n); 00857 00858 if (node) 00859 return node->get(attr_name); 00860 else 00861 return XS_String(); 00862 }
const Children& XMLStorage::XMLNode::get_children | ( | ) | const [inline] |
Children& XMLStorage::XMLNode::get_children | ( | ) | [inline] |
const AttributeMap& XMLStorage::XMLNode::get_attributes | ( | ) | const [inline] |
AttributeMap& XMLStorage::XMLNode::get_attributes | ( | ) | [inline] |
XS_String XMLStorage::XMLNode::get_content | ( | ) | const [inline] |
Definition at line 923 of file xmlstorage.h.
References XMLStorage::assign_utf8(), and XMLStorage::DecodeXMLString().
00924 { 00925 #ifdef XS_STRING_UTF8 00926 const XS_String& ret = _content; 00927 #else 00928 XS_String ret; 00929 assign_utf8(ret, _content.c_str(), _content.length()); 00930 #endif 00931 00932 return DecodeXMLString(ret.c_str()); 00933 }
void XMLStorage::XMLNode::set_content | ( | const XS_String & | s | ) | [inline] |
Definition at line 935 of file xmlstorage.h.
References XMLStorage::XS_String::assign(), and XMLStorage::EncodeXMLString().
00936 { 00937 _content.assign(EncodeXMLString(s.c_str())); 00938 }
std::ostream& XMLStorage::XMLNode::write | ( | std::ostream & | out, | |
const XMLFormat & | format, | |||
WRITE_MODE | mode = FORMAT_SMART , |
|||
int | indent = 0 | |||
) | const [inline] |
write node with children tree to output stream
Definition at line 945 of file xmlstorage.h.
References XMLStorage::FORMAT_ORIGINAL, XMLStorage::FORMAT_PLAIN, and XMLStorage::FORMAT_PRETTY.
00946 { 00947 switch(mode) { 00948 case FORMAT_PLAIN: 00949 plain_write_worker(out); 00950 break; 00951 00952 case FORMAT_PRETTY: 00953 pretty_write_worker(out, format, indent); 00954 break; 00955 00956 case FORMAT_ORIGINAL: 00957 write_worker(out, indent); 00958 break; 00959 00960 default: // FORMAT_SMART 00961 smart_write_worker(out, format, indent); 00962 } 00963 00964 return out; 00965 }
XMLNode* XMLStorage::XMLNode::get_first_child | ( | ) | const [inline, protected] |
Definition at line 980 of file xmlstorage.h.
00981 { 00982 if (!_children.empty()) 00983 return _children.front(); 00984 else 00985 return NULL; 00986 }
Definition at line 988 of file xmlstorage.h.
00989 { 00990 for(Children::const_iterator it=_children.begin(); it!=_children.end(); ++it) 00991 if (**it == name) 00992 if (!n--) 00993 return *it; 00994 00995 return NULL; 00996 }
XMLNode* XMLStorage::XMLNode::find | ( | const XS_String & | name, | |
const XS_String & | attr_name, | |||
const XS_String & | attr_value, | |||
int | n = 0 | |||
) | const [inline, protected] |
Definition at line 998 of file xmlstorage.h.
References get().
00999 { 01000 for(Children::const_iterator it=_children.begin(); it!=_children.end(); ++it) { 01001 const XMLNode& node = **it; 01002 01003 if (node==name && node.get(attr_name)==attr_value) 01004 if (!n--) 01005 return *it; 01006 } 01007 01008 return NULL; 01009 }
const XMLNode* XMLStorage::XMLNode::find_relative | ( | const char * | path | ) | const [protected] |
XPath find function (const).
XMLNode* XMLStorage::XMLNode::find_relative | ( | const char * | path | ) | [inline, protected] |
XPath find function.
Definition at line 1041 of file xmlstorage.h.
01042 {return const_cast<XMLNode*>(const_cast<const XMLNode*>(this)->find_relative(path));}
XMLNode* XMLStorage::XMLNode::create_relative | ( | const char * | path | ) | [protected] |
relative XPath create function
void XMLStorage::XMLNode::write_worker | ( | std::ostream & | out, | |
int | indent | |||
) | const [protected] |
void XMLStorage::XMLNode::plain_write_worker | ( | std::ostream & | out | ) | const [protected] |
void XMLStorage::XMLNode::pretty_write_worker | ( | std::ostream & | out, | |
const XMLFormat & | format, | |||
int | indent | |||
) | const [protected] |
void XMLStorage::XMLNode::smart_write_worker | ( | std::ostream & | out, | |
const XMLFormat & | format, | |||
int | indent | |||
) | const [protected] |
friend struct XMLPos [friend] |
Definition at line 759 of file xmlstorage.h.
friend struct const_XMLPos [friend] |
Definition at line 760 of file xmlstorage.h.
friend struct XMLReaderBase [friend] |
Definition at line 761 of file xmlstorage.h.
Children XMLStorage::XMLNode::_children [protected] |
AttributeMap XMLStorage::XMLNode::_attributes [protected] |
std::string XMLStorage::XMLNode::_leading [protected] |
std::string XMLStorage::XMLNode::_content [protected] |
std::string XMLStorage::XMLNode::_end_leading [protected] |
std::string XMLStorage::XMLNode::_trailing [protected] |
IBrowser Source Code Documentation
generated on 18.09.2008 by |