XMLStorage::XMLDoc Struct Reference

XML document holder. More...

#include <xmlstorage.h>

Inheritance diagram for XMLStorage::XMLDoc:

Inheritance graph
[legend]
Collaboration diagram for XMLStorage::XMLDoc:

Collaboration graph
[legend]

List of all members.

Public Types

enum  COPY_FLAGS { COPY_NOCHILDREN }
typedef std::string super

Public Member Functions

 XMLDoc ()
 XMLDoc (LPCTSTR path)
bool read_file (LPCTSTR path)
bool read_buffer (const char *buffer, size_t len, const std::string &system_id=std::string())
bool read_buffer (const std::string &buffer, const std::string &system_id=std::string())
bool read_stream (std::istream &in, const std::string &system_id=std::string())
bool read (XMLReaderBase &reader, const std::string &display_path)
bool write (std::ostream &out, WRITE_MODE mode=FORMAT_SMART) const
 write XML stream
bool write_formating (std::ostream &out) const
 write XML stream with formating
bool write_file (LPCTSTR path, WRITE_MODE mode=FORMAT_SMART) const
bool write_formating (LPCTSTR path) const
void clear ()
void add_child (XMLNode *child)
 add a new child node
void remove_children (const XS_String &name)
 remove all children named 'name'
void put (const XS_String &attr_name, const XS_String &value)
 write access to an attribute
XS_Stringoperator[] (const XS_String &attr_name)
 index operator 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
void erase (const XS_String &attr_name)
 remove the attribute 'attr_name'
XS_String subvalue (const XS_String &child_name, const XS_String &attr_name, int n=0) const
 convenient value access in children node
XS_Stringsubvalue (const XS_String &child_name, const XS_String &attr_name, int n=0)
 convenient storage of distinct values in children node
const Childrenget_children () const
Childrenget_children ()
const AttributeMapget_attributes () const
AttributeMapget_attributes ()
XS_String get_content () const
 read element node content
XS_String get_sub_content (const XPath &xpath) const
 read content of a subnode specified by an XPath expression
void set_content (const XS_String &s, bool cdata=false)
 set element node content
bool set_sub_content (const XPath &xpath, const XS_String &s, bool cdata=false)
 set content of a subnode specified by an XPath expression
bool write (std::ostream &out, const XMLFormat &format, WRITE_MODE mode=FORMAT_SMART, int indent=0) const
 write node with children tree to output stream
int count (const XPath &xpath) const
 count the nodes matching the given relative XPath expression
int count (XPath::const_iterator from, const XPath::const_iterator &to) const
 count the nodes matching the given relative XPath expression
bool filter (const XPath &xpath, XMLNode &target) const
 copy matching tree nodes using the given XPath filter expression
const XMLNodefind_relative (const XPath &xpath) const
 XPath find function (const).
XMLNodefind_relative (const XPath &xpath)
 XPath find function.
XMLNodeget_first_child () const
void assign (const XS_String &s)
void assign (LPCXSSTR s)
void assign (LPCXSSTR s, size_t l)
 operator LPCXSSTR () const
XS_Stringprintf (LPCXSSTR fmt,...)
XS_Stringvprintf (LPCXSSTR fmt, va_list l)
XS_Stringappendf (LPCXSSTR fmt,...)
XS_Stringvappendf (LPCXSSTR fmt, va_list l)

Public Attributes

XMLFormat _format
XMLErrorList _errors

Protected Member Functions

XMLNodefilter (XPath::const_iterator from, const XPath::const_iterator &to) const
 create a new node tree using the given XPath filter expression
XMLNodecreate_relative (const XPath &xpath)
 relative XPath create function
void original_write_worker (std::ostream &out) const
 write node with children tree to output stream using original white space
void plain_write_worker (std::ostream &out) const
 print node without any white space
void pretty_write_worker (std::ostream &out, const XMLFormat &format, int indent) const
 pretty print node with children tree to output stream
void smart_write_worker (std::ostream &out, const XMLFormat &format, int indent) const
 write node with children tree to output stream using smart formating

Protected Attributes

Children _children
AttributeMap _attributes
std::string _leading
std::string _content
std::string _end_leading
std::string _trailing
bool _cdata_content

Friends

struct XMLPos
struct const_XMLPos
struct XMLReaderBase
struct XPathElement


Detailed Description

XML document holder.

Definition at line 2702 of file xmlstorage.h.


Member Typedef Documentation

typedef std::string XMLStorage::XS_String::super [inherited]

Definition at line 296 of file xmlstorage.h.


Member Enumeration Documentation

enum XMLStorage::XMLNode::COPY_FLAGS [inherited]

Enumerator:
COPY_NOCHILDREN 

Definition at line 1013 of file xmlstorage.h.

01014 {COPY_NOCHILDREN};


Constructor & Destructor Documentation

XMLStorage::XMLDoc::XMLDoc (  )  [inline]

Definition at line 2704 of file xmlstorage.h.

02704 {
02705     XMLDoc()
02706      :  XMLNode("")
02707     {

XMLStorage::XMLDoc::XMLDoc ( LPCTSTR  path  )  [inline]

Definition at line 2709 of file xmlstorage.h.

02711      :  XMLNode("")
02712     {
02713         read_file(path);


Member Function Documentation

bool XMLStorage::XMLDoc::read_file ( LPCTSTR  path  )  [inline]

Definition at line 2741 of file xmlstorage.h.

Referenced by test_delete(), test_read(), test_read1(), test_read2(), and xml_test().

02743     {
02744         tifstream in(path);
02745         if (!in.good())
02746             return false;
02747 
02748         XMLReader reader(this, in);
02749 
02750 #if defined(_STRING_DEFINED) && !defined(XS_STRING_UTF8)
02751         return read(reader, std::string(ANS(path)));
02752 #else
02753         return read(reader, XS_String(path));
02754 #endif

Here is the caller graph for this function:

bool XMLStorage::XMLDoc::read_buffer ( const char *  buffer,
size_t  len,
const std::string &  system_id = std::string() 
) [inline]

Definition at line 2756 of file xmlstorage.h.

Referenced by XMLRPCParser::XMLRPCParser().

02758     {
02759         return read_buffer(std::string(buffer, len), system_id);

Here is the caller graph for this function:

bool XMLStorage::XMLDoc::read_buffer ( const std::string &  buffer,
const std::string &  system_id = std::string() 
) [inline]

Definition at line 2761 of file xmlstorage.h.

02763     {
02764         std::istringstream istr(buffer);
02765 
02766         return read_stream(istr, system_id);

bool XMLStorage::XMLDoc::read_stream ( std::istream &  in,
const std::string &  system_id = std::string() 
) [inline]

Definition at line 2768 of file xmlstorage.h.

02770     {
02771         XMLReader reader(this, in);
02772 
02773         return read(reader, system_id);

bool XMLStorage::XMLDoc::read ( XMLReaderBase reader,
const std::string &  display_path 
) [inline]

Definition at line 2776 of file xmlstorage.h.

References XMLStorage::XMLFormat::_endl, XMLStorage::XMLReaderBase::clear_errors(), XMLStorage::XMLReaderBase::get_endl(), XMLStorage::XMLReaderBase::get_errors(), XMLStorage::XMLReaderBase::get_format(), and XMLStorage::XMLReaderBase::read().

02778     {
02779 #ifdef XMLNODE_LOCATION
02780          // make a string copy to handle temporary string objects
02781         _display_path = display_path;
02782         reader._display_path = _display_path.c_str();
02783 #endif
02784 
02785         reader.clear_errors();
02786         reader.read();
02787 
02788         _format = reader.get_format();
02789         _format._endl = reader.get_endl();
02790 
02791         if (!reader.get_errors().empty()) {
02792             _errors = reader.get_errors();
02793             return false;
02794         }
02795 
02796         return true;

Here is the call graph for this function:

bool XMLStorage::XMLDoc::write ( std::ostream &  out,
WRITE_MODE  mode = FORMAT_SMART 
) const [inline]

write XML stream

Definition at line 2800 of file xmlstorage.h.

References XMLStorage::FORMAT_PLAIN.

Referenced by get_html_page(), and test_read().

02800                     : preserving previous white space and comments
02801     bool write(std::ostream& out, WRITE_MODE mode=FORMAT_SMART) const
02802     {
02803         _format.print_header(out, mode!=FORMAT_PLAIN);
02804 
02805         if (_children.size() == 1)
02806             _children.front()->write(out, _format, mode);
02807         else if (!_children.empty()) {
02808             //throw Exception("more than one XML root!");
02809             return false;
02810         }
02811 
02812         return out.good();

Here is the caller graph for this function:

bool XMLStorage::XMLDoc::write_formating ( std::ostream &  out  )  const [inline]

write XML stream with formating

Definition at line 2815 of file xmlstorage.h.

References XMLStorage::FORMAT_PRETTY.

02817     {
02818         return write(out, FORMAT_PRETTY);

bool XMLStorage::XMLDoc::write_file ( LPCTSTR  path,
WRITE_MODE  mode = FORMAT_SMART 
) const [inline]

Definition at line 2820 of file xmlstorage.h.

Referenced by test_delete(), test_read1(), test_read2(), test_write(), and xml_test().

02822     {
02823         tofstream out(path);
02824 
02825         return write(out, mode);

Here is the caller graph for this function:

bool XMLStorage::XMLDoc::write_formating ( LPCTSTR  path  )  const [inline]

Definition at line 2827 of file xmlstorage.h.

02829     {
02830         tofstream out(path);
02831 
02832         return write_formating(out);

void XMLStorage::XMLNode::clear (  )  [inline, inherited]

Definition at line 1038 of file xmlstorage.h.

Referenced by XMLStorage::XMLNode::Children::clear().

01040     {
01041         _leading.erase();
01042         _content.erase();
01043         _end_leading.erase();
01044         _trailing.erase();
01045 
01046         _attributes.clear();
01047         _children.clear();
01048 
01049         XS_String::erase();

Here is the caller graph for this function:

void XMLStorage::XMLNode::add_child ( XMLNode child  )  [inline, inherited]

add a new child node

Definition at line 1067 of file xmlstorage.h.

Referenced by XMLStorage::XMLNode::create_relative(), and XMLStorage::XMLNode::filter().

01069     {
01070         _children.push_back(child);

Here is the caller graph for this function:

void XMLStorage::XMLNode::remove_children ( const XS_String name  )  [inline, inherited]

remove all children named 'name'

Definition at line 1073 of file xmlstorage.h.

01075     {
01076         Children::iterator it, next=_children.begin();
01077 
01078         while((it=next++) != _children.end())
01079             if (**it == name)
01080                 _children.erase(it);

void XMLStorage::XMLNode::put ( const XS_String attr_name,
const XS_String value 
) [inline, inherited]

write access to an attribute

Definition at line 1083 of file xmlstorage.h.

01085     {
01086         _attributes[attr_name] = value;

XS_String& XMLStorage::XMLNode::operator[] ( const XS_String attr_name  )  [inline, inherited]

index operator write access to an attribute

Definition at line 1089 of file xmlstorage.h.

01091     {
01092         return _attributes[attr_name];

template<typename T>
XS_String XMLStorage::XMLNode::get ( const T &  attr_name,
LPCXSSTR  def = XS_EMPTY_STR 
) const [inline, inherited]

read only access to an attribute

Definition at line 1095 of file xmlstorage.h.

Referenced by XMLStorage::XPathElement::matches(), XMLStorage::XMLNode::subvalue(), XMLStorage::XMLBool::XMLBool(), XMLStorage::XMLDouble::XMLDouble(), XMLStorage::XMLInt::XMLInt(), XMLStorage::XMLProperty::XMLProperty(), and XMLStorage::XMLString::XMLString().

01097     {
01098         AttributeMap::const_iterator found = _attributes.find(attr_name);
01099 
01100         if (found != _attributes.end())
01101             return found->second;
01102         else
01103             return def;

Here is the caller graph for this function:

void XMLStorage::XMLNode::erase ( const XS_String attr_name  )  [inline, inherited]

remove the attribute 'attr_name'

Definition at line 1106 of file xmlstorage.h.

01108     {
01109         _attributes.erase(attr_name);

XS_String XMLStorage::XMLNode::subvalue ( const XS_String child_name,
const XS_String attr_name,
int  n = 0 
) const [inline, inherited]

convenient value access in children node

Definition at line 1112 of file xmlstorage.h.

References XMLStorage::XMLNode::get(), and XMLStorage::XS_String::XS_String().

01114     {
01115         const XMLNode* node = XPathElement(child_name, n).const_find(this);
01116 
01117         if (node)
01118             return node->get(attr_name);
01119         else
01120             return XS_String();

Here is the call graph for this function:

XS_String& XMLStorage::XMLNode::subvalue ( const XS_String child_name,
const XS_String attr_name,
int  n = 0 
) [inline, inherited]

convenient storage of distinct values in children node

Definition at line 1123 of file xmlstorage.h.

01125     {
01126         XMLNode* node = XPathElement(child_name, n).find(this);
01127 
01128         if (!node) {
01129             node = new XMLNode(child_name);
01130             add_child(node);
01131         }
01132 
01133         return (*node)[attr_name];

const Children& XMLStorage::XMLNode::get_children (  )  const [inline, inherited]

Definition at line 1161 of file xmlstorage.h.

Referenced by XMLRPCStruct::XMLRPCStruct().

01163     {
01164         return _children;

Here is the caller graph for this function:

Children& XMLStorage::XMLNode::get_children (  )  [inline, inherited]

Definition at line 1166 of file xmlstorage.h.

01168     {
01169         return _children;

const AttributeMap& XMLStorage::XMLNode::get_attributes (  )  const [inline, inherited]

Definition at line 1171 of file xmlstorage.h.

01173     {
01174         return _attributes;

AttributeMap& XMLStorage::XMLNode::get_attributes (  )  [inline, inherited]

Definition at line 1176 of file xmlstorage.h.

01178     {
01179         return _attributes;

XS_String XMLStorage::XMLNode::get_content (  )  const [inline, inherited]

read element node content

Definition at line 1182 of file xmlstorage.h.

References XMLStorage::DecodeXMLString().

Referenced by XMLStorage::XMLNode::get_sub_content(), and test_read().

01184     {
01185         return DecodeXMLString(_content);

Here is the call graph for this function:

Here is the caller graph for this function:

XS_String XMLStorage::XMLNode::get_sub_content ( const XPath xpath  )  const [inline, inherited]

read content of a subnode specified by an XPath expression

Definition at line 1188 of file xmlstorage.h.

References XMLStorage::XMLNode::get_content(), and XS_EMPTY_STR.

Referenced by XMLRPCStruct::XMLRPCStruct().

01190     {
01191         const XMLNode* node = find_relative(xpath);
01192 
01193         if (node)
01194             return node->get_content();
01195         else
01196             return XS_EMPTY_STR;

Here is the call graph for this function:

Here is the caller graph for this function:

void XMLStorage::XMLNode::set_content ( const XS_String s,
bool  cdata = false 
) [inline, inherited]

set element node content

Definition at line 1199 of file xmlstorage.h.

References XMLStorage::EncodeXMLString().

Referenced by XMLStorage::XMLPos::create_node_content(), and XMLStorage::XMLNode::set_sub_content().

01201     {
01202         _content.assign(EncodeXMLString(s.c_str(), cdata));

Here is the call graph for this function:

Here is the caller graph for this function:

bool XMLStorage::XMLNode::set_sub_content ( const XPath xpath,
const XS_String s,
bool  cdata = false 
) [inline, inherited]

set content of a subnode specified by an XPath expression

Definition at line 1205 of file xmlstorage.h.

References XMLStorage::XMLNode::set_content().

01207     {
01208         XMLNode* node = create_relative(xpath);
01209 
01210         if (node) {
01211             node->set_content(s, cdata);
01212             return true;
01213         } else
01214             return false;

Here is the call graph for this function:

bool XMLStorage::XMLNode::write ( std::ostream &  out,
const XMLFormat format,
WRITE_MODE  mode = FORMAT_SMART,
int  indent = 0 
) const [inline, inherited]

write node with children tree to output stream

Definition at line 1221 of file xmlstorage.h.

References XMLStorage::FORMAT_ORIGINAL, XMLStorage::FORMAT_PLAIN, and XMLStorage::FORMAT_PRETTY.

01223     {
01224         switch(mode) {
01225           case FORMAT_PLAIN:
01226             plain_write_worker(out);
01227             break;
01228 
01229           case FORMAT_PRETTY:
01230             pretty_write_worker(out, format, indent);
01231             break;
01232 
01233           case FORMAT_ORIGINAL:
01234             original_write_worker(out);
01235             break;
01236 
01237           default:  // FORMAT_SMART
01238             smart_write_worker(out, format, indent);
01239         }
01240 
01241         return out.good();

int XMLStorage::XMLNode::count ( const XPath xpath  )  const [inline, inherited]

count the nodes matching the given relative XPath expression

Definition at line 1244 of file xmlstorage.h.

01246     {
01247         return count(xpath.begin(), xpath.end());

int XMLStorage::XMLNode::count ( XPath::const_iterator  from,
const XPath::const_iterator &  to 
) const [inherited]

count the nodes matching the given relative XPath expression

Definition at line 299 of file xmlstorage.cpp.

References XMLStorage::XMLNode::_children, and XMLStorage::XPathElement::matches().

00300 {
00301     const XPathElement& elem = *from++;
00302     int cnt = 0;
00303     int n = 0;
00304 
00305     for(XMLNode::Children::const_iterator it=_children.begin(); it!=_children.end(); ++it)
00306         if (elem.matches(**it, n)) {
00307             if (from != to)
00308                  // iterate deeper
00309                 cnt += (*it)->count(from, to);
00310             else
00311                  // increment match counter
00312                 ++cnt;
00313         }
00314 
00315     return cnt;
00316 }

Here is the call graph for this function:

bool XMLStorage::XMLNode::filter ( const XPath xpath,
XMLNode target 
) const [inherited]

copy matching tree nodes using the given XPath filter expression

Definition at line 319 of file xmlstorage.cpp.

References XMLStorage::XMLNode::_attributes, XMLStorage::XMLNode::_children, and XMLStorage::XMLNode::Children::move().

00320 {
00321     XMLNode* ret = filter(xpath.begin(), xpath.end());
00322 
00323     if (ret) {
00324          // move returned nodes to target node
00325         target._children.move(ret->_children);
00326         target._attributes = ret->_attributes;
00327 
00328         delete ret;
00329 
00330         return true;
00331     } else
00332         return false;
00333 }

Here is the call graph for this function:

XMLNode * XMLStorage::XMLNode::filter ( XPath::const_iterator  from,
const XPath::const_iterator &  to 
) const [protected, inherited]

create a new node tree using the given XPath filter expression

Definition at line 336 of file xmlstorage.cpp.

References XMLStorage::XMLNode::_children, XMLStorage::XMLNode::add_child(), XMLStorage::XMLNode::COPY_NOCHILDREN, XMLStorage::XPathElement::matches(), and XMLStorage::XMLNode::XMLNode().

00337 {
00338     XMLNode* copy = NULL;
00339 
00340     const XPathElement& elem = *from++;
00341     int cnt = 0;
00342     int n = 0;
00343 
00344     for(XMLNode::Children::const_iterator it=_children.begin(); it!=_children.end(); ++it)
00345         if (elem.matches(**it, n)) {
00346             if (!copy)
00347                 copy = new XMLNode(*this, XMLNode::COPY_NOCHILDREN);
00348 
00349             if (from != to) {
00350                 XMLNode* ret = (*it)->filter(from, to);
00351 
00352                 if (ret) {
00353                     copy->add_child(ret);
00354                     ++cnt;
00355                 }
00356             } else {
00357                 copy->add_child(new XMLNode(**it, XMLNode::COPY_NOCHILDREN));
00358                 ++cnt;
00359             }
00360         }
00361 
00362     if (cnt > 0) {
00363         return copy;
00364     } else {
00365         delete copy;
00366         return NULL;
00367     }
00368 }

Here is the call graph for this function:

const XMLNode * XMLStorage::XMLNode::find_relative ( const XPath xpath  )  const [inherited]

XPath find function (const).

Definition at line 249 of file xmlstorage.cpp.

Referenced by XMLRPCParser::get_param_type(), XMLStorage::const_XMLPos::go(), and XMLStorage::XMLPos::go().

00250 {
00251     const XMLNode* node = this;
00252 
00253     for(XPath::const_iterator it=xpath.begin(); it!=xpath.end(); ++it) {
00254         node = it->const_find(node);
00255 
00256         if (!node)
00257             return NULL;
00258     }
00259 
00260     return node;
00261 }

Here is the caller graph for this function:

XMLNode * XMLStorage::XMLNode::find_relative ( const XPath xpath  )  [inherited]

XPath find function.

Definition at line 263 of file xmlstorage.cpp.

00264 {
00265     XMLNode* node = this;
00266 
00267     for(XPath::const_iterator it=xpath.begin(); it!=xpath.end(); ++it) {
00268         node = it->find(node);
00269 
00270         if (!node)
00271             return NULL;
00272     }
00273 
00274     return node;
00275 }

XMLNode* XMLStorage::XMLNode::get_first_child (  )  const [inline, inherited]

Definition at line 1261 of file xmlstorage.h.

Referenced by XMLRPCParser::get_param_type().

01263     {
01264         if (!_children.empty())
01265             return _children.front();
01266         else
01267             return NULL;

Here is the caller graph for this function:

XMLNode * XMLStorage::XMLNode::create_relative ( const XPath xpath  )  [protected, inherited]

relative XPath create function

Definition at line 277 of file xmlstorage.cpp.

References XMLStorage::XMLNode::add_child(), and XMLStorage::XMLNode::XMLNode().

00278 {
00279     XMLNode* node = this;
00280 
00281     for(XPath::const_iterator it=xpath.begin(); it!=xpath.end(); ++it) {
00282         XMLNode* child = it->find(node);
00283 
00284         if (!child) {
00285             child = new XMLNode(it->_child_name);
00286             node->add_child(child);
00287 
00288             if (!it->_attr_name.empty())
00289                 (*this)[it->_attr_name] = it->_attr_value;
00290         }
00291 
00292         node = child;
00293     }
00294 
00295     return node;
00296 }

Here is the call graph for this function:

void XMLStorage::XMLNode::original_write_worker ( std::ostream &  out  )  const [protected, inherited]

write node with children tree to output stream using original white space

Definition at line 522 of file xmlstorage.cpp.

00527 {
00528     out << _leading << '<' << EncodeXMLString(*this);
00529 
00530     for(AttributeMap::const_iterator it=_attributes.begin(); it!=_attributes.end(); ++it)
00531         out << ' ' << EncodeXMLString(it->first) << "=\"" << EncodeXMLString(it->second) << "\"";
00532 
00533     if (!_children.empty() || !_content.empty()) {
00534         out << '>';
00535 
00536         if (_cdata_content)
00537             out << CDATA_START << _content << CDATA_END;
00538         else
00539             out << _content;
00540 
00541         for(Children::const_iterator it=_children.begin(); it!=_children.end(); ++it)
00542             (*it)->original_write_worker(out);
00543 
00544         out << _end_leading << "</" << EncodeXMLString(*this) << '>';
00545     } else

void XMLStorage::XMLNode::plain_write_worker ( std::ostream &  out  )  const [protected, inherited]

print node without any white space

Definition at line 549 of file xmlstorage.cpp.

00554 {
00555     out << '<' << EncodeXMLString(*this);
00556 
00557     for(AttributeMap::const_iterator it=_attributes.begin(); it!=_attributes.end(); ++it)
00558         out << ' ' << EncodeXMLString(it->first) << "=\"" << EncodeXMLString(it->second) << "\"";
00559 
00560      // strip leading white space from content
00561     const char* content = _content.c_str();
00562     while(isspace((unsigned char)*content)) ++content;
00563 
00564     if (!_children.empty() || *content) {
00565         out << ">" << content;
00566 
00567         for(Children::const_iterator it=_children.begin(); it!=_children.end(); ++it)
00568             (*it)->plain_write_worker(out);
00569 

void XMLStorage::XMLNode::pretty_write_worker ( std::ostream &  out,
const XMLFormat format,
int  indent 
) const [protected, inherited]

pretty print node with children tree to output stream

Definition at line 573 of file xmlstorage.cpp.

00578 {
00579     for(int i=indent; i--; )
00580         out << XML_INDENT_SPACE;
00581 
00582     out << '<' << EncodeXMLString(*this);
00583 
00584     for(AttributeMap::const_iterator it=_attributes.begin(); it!=_attributes.end(); ++it)
00585         out << ' ' << EncodeXMLString(it->first) << "=\"" << EncodeXMLString(it->second) << "\"";
00586 
00587      // strip leading white space from content
00588     const char* content = _content.c_str();
00589     while(isspace((unsigned char)*content)) ++content;
00590 
00591     if (!_children.empty() || *content) {
00592         out << '>' << content;
00593 
00594         if (!_children.empty())
00595             out << format._endl;
00596 
00597         for(Children::const_iterator it=_children.begin(); it!=_children.end(); ++it)
00598             (*it)->pretty_write_worker(out, format, indent+1);
00599 
00600         for(int i=indent; i--; )
00601             out << XML_INDENT_SPACE;
00602 

void XMLStorage::XMLNode::smart_write_worker ( std::ostream &  out,
const XMLFormat format,
int  indent 
) const [protected, inherited]

write node with children tree to output stream using smart formating

Definition at line 606 of file xmlstorage.cpp.

00611 {
00612      // strip the first line feed from _leading
00613     const char* leading = _leading.c_str();
00614     if (*leading == '\n') ++leading;
00615 
00616     if (!*leading)
00617         for(int i=indent; i--; )
00618             out << XML_INDENT_SPACE;
00619     else
00620         out << leading;
00621 
00622     out << '<' << EncodeXMLString(*this);
00623 
00624     for(AttributeMap::const_iterator it=_attributes.begin(); it!=_attributes.end(); ++it)
00625         out << ' ' << EncodeXMLString(it->first) << "=\"" << EncodeXMLString(it->second) << "\"";
00626 
00627      // strip leading white space from content
00628     const char* content = _content.c_str();
00629     while(isspace((unsigned char)*content)) ++content;
00630 
00631     if (_children.empty() && !*content)
00632         out << "/>";
00633     else {
00634         out << '>';
00635 
00636         if (_cdata_content)
00637             out << CDATA_START << _content << CDATA_END;
00638         else if (!*content)
00639             out << format._endl;
00640         else
00641             out << content;
00642 
00643         Children::const_iterator it = _children.begin();
00644 
00645         if (it != _children.end()) {
00646             for(; it!=_children.end(); ++it)
00647                 (*it)->smart_write_worker(out, format, indent+1);
00648 
00649              // strip the first line feed from _end_leading
00650             const char* end_leading = _end_leading.c_str();
00651             if (*end_leading == '\n') ++end_leading;
00652 
00653             if (!*end_leading)
00654                 for(int i=indent; i--; )
00655                     out << XML_INDENT_SPACE;
00656             else
00657                 out << end_leading;
00658         } else
00659             out << _end_leading;
00660 
00661         out << "</" << EncodeXMLString(*this) << '>';
00662     }
00663 
00664     if (_trailing.empty())

void XMLStorage::XS_String::assign ( const XS_String s  )  [inline, inherited]

Definition at line 337 of file xmlstorage.h.

Referenced by XMLStorage::XMLStringRef::operator=(), XMLStorage::XMLDoubleRef::operator=(), XMLStorage::XMLIntRef::operator=(), XMLStorage::XMLBoolRef::operator=(), XMLStorage::XMLNode::Children::operator=(), XMLStorage::XPathElement::parse(), XMLStorage::XMLBoolRef::toggle(), XMLStorage::XMLBoolRef::XMLBoolRef(), XMLStorage::XMLDoubleRef::XMLDoubleRef(), XMLStorage::XMLIntRef::XMLIntRef(), and XMLStorage::XMLStringRef::XMLStringRef().

00338 {assign(s.c_str());}

Here is the caller graph for this function:

void XMLStorage::XS_String::assign ( LPCXSSTR  s  )  [inline, inherited]

Definition at line 342 of file xmlstorage.h.

00342 {super::assign(s); return *this;}

void XMLStorage::XS_String::assign ( LPCXSSTR  s,
size_t  l 
) [inline, inherited]

Definition at line 343 of file xmlstorage.h.

00343 {super::assign(s);}

XMLStorage::XS_String::operator LPCXSSTR (  )  const [inline, inherited]

Definition at line 345 of file xmlstorage.h.

00346 {return c_str();}

XS_String& XMLStorage::XS_String::printf ( LPCXSSTR  fmt,
  ... 
) [inline, inherited]

Definition at line 357 of file xmlstorage.h.

References BUFFER_LEN, COUNTOF, XS_CHAR, and XS_vsnprintf.

00359     {
00360         va_list l;
00361         XS_CHAR b[BUFFER_LEN];
00362 
00363         va_start(l, fmt);
00364         super::assign(b, XS_vsnprintf(b, COUNTOF(b), fmt, l));
00365         va_end(l);
00366 
00367         return *this;

XS_String& XMLStorage::XS_String::vprintf ( LPCXSSTR  fmt,
va_list  l 
) [inline, inherited]

Definition at line 369 of file xmlstorage.h.

References BUFFER_LEN, COUNTOF, XS_CHAR, and XS_vsnprintf.

00371     {
00372         XS_CHAR b[BUFFER_LEN];
00373 
00374         super::assign(b, XS_vsnprintf(b, COUNTOF(b), fmt, l));
00375 
00376         return *this;

XS_String& XMLStorage::XS_String::appendf ( LPCXSSTR  fmt,
  ... 
) [inline, inherited]

Definition at line 378 of file xmlstorage.h.

References BUFFER_LEN, COUNTOF, XS_CHAR, and XS_vsnprintf.

00380     {
00381         va_list l;
00382         XS_CHAR b[BUFFER_LEN];
00383 
00384         va_start(l, fmt);
00385         super::append(b, XS_vsnprintf(b, COUNTOF(b), fmt, l));
00386         va_end(l);
00387 
00388         return *this;

XS_String& XMLStorage::XS_String::vappendf ( LPCXSSTR  fmt,
va_list  l 
) [inline, inherited]

Definition at line 390 of file xmlstorage.h.

References BUFFER_LEN, COUNTOF, XS_CHAR, and XS_vsnprintf.

00392     {
00393         XS_CHAR b[BUFFER_LEN];
00394 
00395         super::append(b, XS_vsnprintf(b, COUNTOF(b), fmt, l));
00396 
00397         return *this;


Friends And Related Function Documentation

friend struct XMLPos [friend, inherited]

Definition at line 979 of file xmlstorage.h.

friend struct const_XMLPos [friend, inherited]

Definition at line 980 of file xmlstorage.h.

friend struct XMLReaderBase [friend, inherited]

Definition at line 981 of file xmlstorage.h.

friend struct XPathElement [friend, inherited]

Definition at line 982 of file xmlstorage.h.


Member Data Documentation

XMLFormat XMLStorage::XMLDoc::_format

Definition at line 2834 of file xmlstorage.h.

Referenced by get_html_page().

XMLErrorList XMLStorage::XMLDoc::_errors

Definition at line 2835 of file xmlstorage.h.

Referenced by xml_test().

Children XMLStorage::XMLNode::_children [protected, inherited]

Definition at line 1270 of file xmlstorage.h.

Referenced by XMLStorage::XPathElement::const_find(), XMLStorage::XMLNode::count(), XMLStorage::XMLPos::delete_this(), XMLStorage::XMLNode::filter(), XMLStorage::XPathElement::find(), XMLStorage::XMLNode::operator=(), and XMLStorage::XMLNode::XMLNode().

AttributeMap XMLStorage::XMLNode::_attributes [protected, inherited]

Definition at line 1271 of file xmlstorage.h.

Referenced by XMLStorage::XMLNode::filter(), and XMLStorage::XMLNode::operator=().

std::string XMLStorage::XMLNode::_leading [protected, inherited]

Definition at line 1273 of file xmlstorage.h.

Referenced by XMLStorage::XMLNode::operator=().

std::string XMLStorage::XMLNode::_content [protected, inherited]

Definition at line 1274 of file xmlstorage.h.

Referenced by XMLStorage::XMLNode::operator=().

std::string XMLStorage::XMLNode::_end_leading [protected, inherited]

Definition at line 1275 of file xmlstorage.h.

Referenced by XMLStorage::XMLNode::operator=().

std::string XMLStorage::XMLNode::_trailing [protected, inherited]

Definition at line 1276 of file xmlstorage.h.

Referenced by XMLStorage::XMLNode::operator=().

bool XMLStorage::XMLNode::_cdata_content [protected, inherited]

Definition at line 1282 of file xmlstorage.h.


The documentation for this struct was generated from the following file:
Generated on Sat Jan 9 00:06:01 2010 for XMLStorage/C++ by  doxygen 1.5.4