ReactOS 0.4.16-dev-197-g92996da
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
 
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
 
- 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
 
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
 
- 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
 
XMLNodefilter (XPath::const_iterator from, const XPath::const_iterator &to) const
 create a new node tree using the given XPath filter expression
 
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 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

◆ XMLDoc() [1/2]

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

◆ XMLDoc() [2/2]

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

Definition at line 2709 of file xmlstorage.h.

2710 : XMLNode("")
2711 {
2712 read_file(path);
2713 }
bool read_file(LPCTSTR path)
Definition: xmlstorage.h:2741

Member Function Documentation

◆ read()

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

Definition at line 2776 of file xmlstorage.h.

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 }
XMLErrorList _errors
Definition: xmlstorage.h:2835
const char * _endl
Definition: xmlstorage.h:789
Definition: reader.h:84

◆ read_buffer() [1/2]

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.

2757 {
2758 return read_buffer(std::string(buffer, len), system_id);
2759 }
GLuint buffer
Definition: glext.h:5915
GLenum GLsizei len
Definition: glext.h:6722
__u8 system_id[8]
Definition: mkdosfs.c:1
bool read_buffer(const char *buffer, size_t len, const std::string &system_id=std::string())
Definition: xmlstorage.h:2756

Referenced by read_buffer(), XMLStorage::XMLMessageFromString::XMLMessageFromString(), and XMLStorage::XMLMessageReader::XMLMessageReader().

◆ read_buffer() [2/2]

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

◆ read_file()

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

Definition at line 2741 of file xmlstorage.h.

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 }
#define read
Definition: acwin.h:96
GLuint in
Definition: glext.h:9616

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

◆ read_stream()

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

Definition at line 2768 of file xmlstorage.h.

2769 {
2770 XMLReader reader(this, in);
2771
2772 return read(reader, system_id);
2773 }

Referenced by read_buffer().

◆ write()

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.

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 }
GLenum mode
Definition: glext.h:6217
static FILE * out
Definition: regtests2xml.c:44
void print_header(std::ostream &out, bool lf=true) const
Definition: xmlstorage.cpp:740

◆ write_file()

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

Definition at line 2820 of file xmlstorage.h.

2821 {
2822 tofstream out(path);
2823
2824 return write(out, mode);
2825 }
#define write
Definition: acwin.h:97

Referenced by ExplorerGlobals::write_persistent().

◆ write_formating() [1/2]

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 }
bool write_formating(std::ostream &out) const
write XML stream with formating
Definition: xmlstorage.h:2815

◆ write_formating() [2/2]

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

write XML stream with formating

Definition at line 2815 of file xmlstorage.h.

2816 {
2817 return write(out, FORMAT_PRETTY);
2818 }
@ FORMAT_PRETTY
write XML stream preserving original white space and comments
Definition: xmlstorage.h:808

Referenced by write_formating().

Member Data Documentation

◆ _errors

XMLErrorList XMLStorage::XMLDoc::_errors

Definition at line 2835 of file xmlstorage.h.

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

◆ _format

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: