ReactOS  r76032
XMLStorage::XMLDoc Struct Reference

XML document holder. More...

#include <xmlstorage.h>

Inheritance diagram for XMLStorage::XMLDoc:
Collaboration diagram for XMLStorage::XMLDoc:

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 More...
 
bool write_formating (std::ostream &out) const
 write XML stream with formating More...
 
bool write_file (LPCTSTR path, WRITE_MODE mode=FORMAT_SMART) const
 
bool write_formating (LPCTSTR path) const
 
- Public Member Functions inherited from XMLStorage::XMLNode
 XMLNode (const XS_String &name)
 
 XMLNode (const XS_String &name, const std::string &leading)
 
 XMLNode (const XMLNode &other)
 
 XMLNode (const XMLNode &other, COPY_FLAGS copy_no_children)
 
virtual ~XMLNode ()
 
void clear ()
 
XMLNodeoperator= (const XMLNode &other)
 
void add_child (XMLNode *child)
 add a new child node More...
 
void remove_children (const XS_String &name)
 remove all children named 'name' More...
 
void put (const XS_String &attr_name, const XS_String &value)
 write access to an attribute More...
 
XS_Stringoperator[] (const XS_String &attr_name)
 index operator write access to an attribute More...
 
template<typename T >
XS_String get (const T &attr_name, LPCXSSTR def=XS_EMPTY_STR) const
 read only access to an attribute More...
 
void erase (const XS_String &attr_name)
 remove the attribute 'attr_name' More...
 
XS_String subvalue (const XS_String &child_name, const XS_String &attr_name, int n=0) const
 convenient value access in children node More...
 
XS_Stringsubvalue (const XS_String &child_name, const XS_String &attr_name, int n=0)
 convenient storage of distinct values in children node More...
 
const Childrenget_children () const
 
Childrenget_children ()
 
const AttributeMapget_attributes () const
 
AttributeMapget_attributes ()
 
XS_String get_content () const
 read element node content More...
 
XS_String get_sub_content (const XPath &xpath) const
 read content of a subnode specified by an XPath expression More...
 
void set_content (const XS_String &s, bool cdata=false)
 set element node content More...
 
bool set_sub_content (const XPath &xpath, const XS_String &s, bool cdata=false)
 set content of a subnode specified by an XPath expression More...
 
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 More...
 
int count (const XPath &xpath) const
 count the nodes matching the given relative XPath expression More...
 
int count (XPath::const_iterator from, const XPath::const_iterator &to) const
 count the nodes matching the given relative XPath expression More...
 
bool filter (const XPath &xpath, XMLNode &target) const
 copy matching tree nodes using the given XPath filter expression More...
 
const XMLNodefind_relative (const XPath &xpath) const
 XPath find function (const) More...
 
XMLNodefind_relative (const XPath &xpath)
 XPath find function. More...
 
XMLNodeget_first_child () const
 
- Public Member Functions inherited from XMLStorage::XS_String
 XS_String ()
 
 XS_String (LPCXSSTR s)
 
 XS_String (LPCXSSTR s, size_t l)
 
 XS_String (const super &other)
 
 XS_String (const XS_String &other)
 
void assign (const XS_String &s)
 
XS_Stringoperator= (LPCXSSTR s)
 
XS_Stringoperator= (const super &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
 

Additional Inherited Members

- Public Types inherited from XMLStorage::XMLNode
enum  COPY_FLAGS { COPY_NOCHILDREN }
 
- Public Types inherited from XMLStorage::XS_String
typedef std::string super
 
- Protected Member Functions inherited from XMLStorage::XMLNode
XMLNodecreate_relative (const XPath &xpath)
 relative XPath create function More...
 
XMLNodefilter (XPath::const_iterator from, const XPath::const_iterator &to) const
 create a new node tree using the given XPath filter expression More...
 
void original_write_worker (std::ostream &out) const
 write node with children tree to output stream using original white space More...
 
void plain_write_worker (std::ostream &out) const
 print node without any white space More...
 
void pretty_write_worker (std::ostream &out, const XMLFormat &format, int indent) const
 pretty print node with children tree to output stream More...
 
void smart_write_worker (std::ostream &out, const XMLFormat &format, int indent) const
 write node with children tree to output stream using smart formating More...
 
- Protected Attributes inherited from XMLStorage::XMLNode
Children _children
 
AttributeMap _attributes
 
std::string _leading
 
std::string _content
 
std::string _end_leading
 
std::string _trailing
 
bool _cdata_content
 

Detailed Description

XML document holder.

Definition at line 2702 of file xmlstorage.h.

Constructor & Destructor Documentation

XMLStorage::XMLDoc::XMLDoc ( )
inline

Definition at line 2704 of file xmlstorage.h.

2705  : XMLNode("")
2706  {
2707  }
XMLNode(const XS_String &name)
Definition: xmlstorage.h:984
XMLStorage::XMLDoc::XMLDoc ( LPCTSTR  path)
inline

Definition at line 2709 of file xmlstorage.h.

2710  : XMLNode("")
2711  {
2712  read_file(path);
2713  }
XMLNode(const XS_String &name)
Definition: xmlstorage.h:984
bool read_file(LPCTSTR path)
Definition: xmlstorage.h:2741
Definition: services.c:311

Member Function Documentation

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

Definition at line 2776 of file xmlstorage.h.

Referenced by read_file(), and read_stream().

2777  {
2778 #ifdef XMLNODE_LOCATION
2779  // make a string copy to handle temporary string objects
2780  _display_path = display_path;
2781  reader._display_path = _display_path.c_str();
2782 #endif
2783 
2784  reader.clear_errors();
2785  reader.read();
2786 
2787  _format = reader.get_format();
2788  _format._endl = reader.get_endl();
2789 
2790  if (!reader.get_errors().empty()) {
2791  _errors = reader.get_errors();
2792  return false;
2793  }
2794 
2795  return true;
2796  }
const char * _endl
Definition: xmlstorage.h:789
Definition: reader.h:83
XMLErrorList _errors
Definition: xmlstorage.h:2835
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 XMLStorage::XMLMessageFromString::XMLMessageFromString(), and XMLStorage::XMLMessageReader::XMLMessageReader().

2757  {
2759  }
GLuint buffer
Definition: glext.h:5915
GLenum GLsizei len
Definition: glext.h:6722
char string[160]
Definition: util.h:11
bool read_buffer(const char *buffer, size_t len, const std::string &system_id=std::string())
Definition: xmlstorage.h:2756
__u8 system_id[8]
Definition: mkdosfs.c:359
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.

2762  {
2763  std::istringstream istr(buffer);
2764 
2765  return read_stream(istr, system_id);
2766  }
bool read_stream(std::istream &in, const std::string &system_id=std::string())
Definition: xmlstorage.h:2768
GLuint buffer
Definition: glext.h:5915
basic_istringstream< char, char_traits< char >, allocator< char > > istringstream
Definition: _iosfwd.h:126
__u8 system_id[8]
Definition: mkdosfs.c:359
bool XMLStorage::XMLDoc::read_file ( LPCTSTR  path)
inline

Definition at line 2741 of file xmlstorage.h.

Referenced by ExplorerGlobals::read_persistent(), and XMLDoc().

2742  {
2743  tifstream in(path);
2744  if (!in.good())
2745  return false;
2746 
2747  XMLReader reader(this, in);
2748 
2749 #if defined(_STRING_DEFINED) && !defined(XS_STRING_UTF8)
2750  return read(reader, std::string(ANS(path)));
2751 #else
2752  return read(reader, XS_String(path));
2753 #endif
2754  }
bool read(XMLReaderBase &reader, const std::string &display_path)
Definition: xmlstorage.h:2776
char string[160]
Definition: util.h:11
GLfloat CONST GLvector4f * in
Definition: m_xform.h:122
Definition: services.c:311
Definition: reader.h:83
bool XMLStorage::XMLDoc::read_stream ( std::istream in,
const std::string system_id = std::string() 
)
inline

Definition at line 2768 of file xmlstorage.h.

Referenced by read_buffer().

2769  {
2770  XMLReader reader(this, in);
2771 
2772  return read(reader, system_id);
2773  }
bool read(XMLReaderBase &reader, const std::string &display_path)
Definition: xmlstorage.h:2776
GLfloat CONST GLvector4f * in
Definition: m_xform.h:122
Definition: reader.h:83
__u8 system_id[8]
Definition: mkdosfs.c:359
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.

Referenced by XMLStorage::XMLMessage::toString(), write_file(), and write_formating().

2801  {
2803 
2804  if (_children.size() == 1)
2805  _children.front()->write(out, _format, mode);
2806  else if (!_children.empty()) {
2807  //throw Exception("more than one XML root!");
2808  return false;
2809  }
2810 
2811  return out.good();
2812  }
static FILE * out
Definition: regtests2xml.c:44
void print_header(std::ostream &out, bool lf=true) const
Definition: xmlstorage.cpp:740
bool XMLStorage::XMLDoc::write_file ( LPCTSTR  path,
WRITE_MODE  mode = FORMAT_SMART 
) const
inline

Definition at line 2820 of file xmlstorage.h.

Referenced by ExplorerGlobals::write_persistent().

2821  {
2822  tofstream out(path);
2823 
2824  return write(out, mode);
2825  }
static FILE * out
Definition: regtests2xml.c:44
Definition: services.c:311
bool write(std::ostream &out, WRITE_MODE mode=FORMAT_SMART) const
write XML stream
Definition: xmlstorage.h:2800
bool XMLStorage::XMLDoc::write_formating ( std::ostream out) const
inline

write XML stream with formating

Definition at line 2815 of file xmlstorage.h.

Referenced by write_formating().

2816  {
2817  return write(out, FORMAT_PRETTY);
2818  }
write XML stream preserving original white space and comments
Definition: xmlstorage.h:808
static FILE * out
Definition: regtests2xml.c:44
bool write(std::ostream &out, WRITE_MODE mode=FORMAT_SMART) const
write XML stream
Definition: xmlstorage.h:2800
bool XMLStorage::XMLDoc::write_formating ( LPCTSTR  path) const
inline

Definition at line 2827 of file xmlstorage.h.

2828  {
2829  tofstream out(path);
2830 
2831  return write_formating(out);
2832  }
static FILE * out
Definition: regtests2xml.c:44
bool write_formating(std::ostream &out) const
write XML stream with formating
Definition: xmlstorage.h:2815
Definition: services.c:311

Member Data Documentation

XMLErrorList XMLStorage::XMLDoc::_errors

Definition at line 2835 of file xmlstorage.h.

Referenced by read(), and ExplorerGlobals::read_persistent().

XMLFormat XMLStorage::XMLDoc::_format

Definition at line 2834 of file xmlstorage.h.

Referenced by read(), and write().


The documentation for this struct was generated from the following file: