ReactOS 0.4.15-dev-8222-g9164419
XMLStorage::XMLWriter Struct Reference

on the fly XML writer More...

#include <xmlstorage.h>

Collaboration diagram for XMLStorage::XMLWriter:

Classes

struct  StackEntry
 container for XMLWriter state information More...
 

Public Types

enum  WRITESTATE { NOTHING , ATTRIBUTES , PRE_CLOSED , POST }
 

Public Member Functions

 XMLWriter (std::ostream &out, const XMLFormat &format=XMLFormat())
 
 XMLWriter (LPCTSTR path, const XMLFormat &format=XMLFormat())
 
 ~XMLWriter ()
 
void create (const XS_String &name)
 create node and move to it
 
bool back ()
 go back to previous position
 
void put (const XS_String &attr_name, const XS_String &value)
 attribute setting
 
XS_Stringoperator[] (const XS_String &attr_name)
 index operator write access to an attribute
 
void set_content (const XS_String &s, bool cdata=false)
 
void create_node_content (const XS_String &node_name, const XS_String &content)
 create node with string content
 

Protected Types

typedef XMLNode::AttributeMap AttrMap
 

Protected Member Functions

void close_pre (StackEntry &entry)
 
void write_pre (StackEntry &entry)
 
void write_attributes (StackEntry &entry)
 
void write_post (StackEntry &entry)
 

Protected Attributes

tofstream_pofstream
 
std::ostream & _out
 
XMLFormat _format
 
std::stack< StackEntry_stack
 

Static Protected Attributes

static XS_String s_empty_attr
 

Detailed Description

on the fly XML writer

Definition at line 2901 of file xmlstorage.h.

Member Typedef Documentation

◆ AttrMap

Definition at line 2971 of file xmlstorage.h.

Member Enumeration Documentation

◆ WRITESTATE

Enumerator
NOTHING 
ATTRIBUTES 
PRE_CLOSED 
POST 

Definition at line 2962 of file xmlstorage.h.

Constructor & Destructor Documentation

◆ XMLWriter() [1/2]

XMLStorage::XMLWriter::XMLWriter ( std::ostream &  out,
const XMLFormat format = XMLFormat() 
)
inline

Definition at line 2903 of file xmlstorage.h.

2904 : _pofstream(NULL),
2905 _out(out),
2907 {
2908 format.print_header(_out, false); // _format._endl is printed in write_pre()
2909 }
#define NULL
Definition: types.h:112
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
static FILE * out
Definition: regtests2xml.c:44
void print_header(std::ostream &out, bool lf=true) const
Definition: xmlstorage.cpp:740
std::ostream & _out
Definition: xmlstorage.h:2968
tofstream * _pofstream
Definition: xmlstorage.h:2967

◆ XMLWriter() [2/2]

XMLStorage::XMLWriter::XMLWriter ( LPCTSTR  path,
const XMLFormat format = XMLFormat() 
)
inline

Definition at line 2911 of file xmlstorage.h.

2912 : _pofstream(new tofstream(path)),
2913 _out(*_pofstream),
2915 {
2916 format.print_header(_out, false); // _format._endl is printed in write_pre()
2917 }

◆ ~XMLWriter()

XMLStorage::XMLWriter::~XMLWriter ( )
inline

Definition at line 2919 of file xmlstorage.h.

2920 {
2921 _out << _format._endl;
2922 delete _pofstream;
2923 }
const char * _endl
Definition: xmlstorage.h:789

Member Function Documentation

◆ back()

bool XMLStorage::XMLWriter::back ( )

go back to previous position

Definition at line 972 of file xmlstorage.cpp.

973{
974 if (!_stack.empty()) {
975 write_post(_stack.top());
976
977 _stack.pop();
978 return true;
979 } else
980 return false;
981}
void write_post(StackEntry &entry)
std::stack< StackEntry > _stack
Definition: xmlstorage.h:2984

Referenced by create_node_content().

◆ close_pre()

void XMLStorage::XMLWriter::close_pre ( StackEntry entry)
protected

Definition at line 983 of file xmlstorage.cpp.

984{
985 _out << '>';
986
987 entry._state = PRE_CLOSED;
988}
uint32_t entry
Definition: isohybrid.c:63

Referenced by create(), and write_post().

◆ create()

void XMLStorage::XMLWriter::create ( const XS_String name)

create node and move to it

Definition at line 952 of file xmlstorage.cpp.

953{
954 if (!_stack.empty()) {
955 StackEntry& last = _stack.top();
956
957 if (last._state < PRE_CLOSED) {
960 }
961
962 ++last._children;
963 }
964
965 StackEntry entry;
966 entry._node_name = name;
967 _stack.push(entry);
968
970}
static UINT UINT last
Definition: font.c:45
void write_pre(StackEntry &entry)
Definition: xmlstorage.cpp:990
void close_pre(StackEntry &entry)
Definition: xmlstorage.cpp:983
void write_attributes(StackEntry &entry)
Definition: name.c:39

◆ create_node_content()

void XMLStorage::XMLWriter::create_node_content ( const XS_String node_name,
const XS_String content 
)
inline

create node with string content

Definition at line 2954 of file xmlstorage.h.

2955 {
2956 create(node_name);
2958 back();
2959 }
content
Definition: atl_ax.c:994
static const struct access_res create[16]
Definition: package.c:7644
void set_content(const XS_String &s, bool cdata=false)
Definition: xmlstorage.h:2947
bool back()
go back to previous position
Definition: xmlstorage.cpp:972

◆ operator[]()

XS_String & XMLStorage::XMLWriter::operator[] ( const XS_String attr_name)
inline

index operator write access to an attribute

Definition at line 2939 of file xmlstorage.h.

2940 {
2941 if (_stack.empty())
2942 return s_empty_attr;
2943
2944 return _stack.top()._attributes[attr_name];
2945 }
static XS_String s_empty_attr
Definition: xmlstorage.h:2986

◆ put()

void XMLStorage::XMLWriter::put ( const XS_String attr_name,
const XS_String value 
)
inline

attribute setting

Definition at line 2932 of file xmlstorage.h.

2933 {
2934 if (!_stack.empty())
2935 _stack.top()._attributes[attr_name] = value;
2936 }
Definition: pdh_main.c:94

◆ set_content()

void XMLStorage::XMLWriter::set_content ( const XS_String s,
bool  cdata = false 
)
inline

Definition at line 2947 of file xmlstorage.h.

2948 {
2949 if (!_stack.empty())
2950 _stack.top()._content = EncodeXMLString(s.c_str(), cdata);
2951 }
GLdouble s
Definition: gl.h:2039
std::string EncodeXMLString(const XS_String &str, bool cdata)
encode XML string literals
Definition: xmlstorage.cpp:374

Referenced by create_node_content().

◆ write_attributes()

void XMLStorage::XMLWriter::write_attributes ( StackEntry entry)
protected

Definition at line 1004 of file xmlstorage.cpp.

1005{
1006 for(AttrMap::const_iterator it=entry._attributes.begin(); it!=entry._attributes.end(); ++it)
1007 _out << ' ' << EncodeXMLString(it->first) << "=\"" << EncodeXMLString(it->second) << "\"";
1008
1009 entry._state = ATTRIBUTES;
1010}

Referenced by create(), and write_post().

◆ write_post()

void XMLStorage::XMLWriter::write_post ( StackEntry entry)
protected

Definition at line 1012 of file xmlstorage.cpp.

1013{
1014 if (entry._state < ATTRIBUTES)
1016
1017 if (entry._children || !entry._content.empty()) {
1018 if (entry._state < PRE_CLOSED)
1020
1021 _out << entry._content;
1022 //entry._state = CONTENT;
1023
1024 if (_format._pretty>=PRETTY_LINEFEED && entry._content.empty())
1025 _out << _format._endl;
1026
1027 if (_format._pretty==PRETTY_INDENT && entry._content.empty()) {
1028 for(size_t i=_stack.size(); --i>0; )
1030 }
1031
1032 _out << "</" << EncodeXMLString(entry._node_name) << ">";
1033 } else {
1034 _out << "/>";
1035 }
1036
1037 entry._state = POST;
1038}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
@ PRETTY_LINEFEED
Definition: xmlstorage.h:719
PRETTY_FLAGS _pretty
Definition: xmlstorage.h:788
#define XML_INDENT_SPACE
Definition: xmlstorage.h:617

Referenced by back().

◆ write_pre()

void XMLStorage::XMLWriter::write_pre ( StackEntry entry)
protected

Definition at line 990 of file xmlstorage.cpp.

991{
993 _out << _format._endl;
994
996 for(size_t i=_stack.size(); --i>0; )
998 }
999
1000 _out << '<' << EncodeXMLString(entry._node_name);
1001 //entry._state = PRE;
1002}

Referenced by create().

Member Data Documentation

◆ _format

XMLFormat XMLStorage::XMLWriter::_format
protected

Definition at line 2969 of file xmlstorage.h.

Referenced by write_post(), write_pre(), and ~XMLWriter().

◆ _out

std::ostream& XMLStorage::XMLWriter::_out
protected

Definition at line 2968 of file xmlstorage.h.

Referenced by close_pre(), write_attributes(), write_post(), write_pre(), XMLWriter(), and ~XMLWriter().

◆ _pofstream

tofstream* XMLStorage::XMLWriter::_pofstream
protected

Definition at line 2967 of file xmlstorage.h.

Referenced by ~XMLWriter().

◆ _stack

std::stack<StackEntry> XMLStorage::XMLWriter::_stack
protected

Definition at line 2984 of file xmlstorage.h.

Referenced by back(), create(), operator[](), put(), set_content(), write_post(), and write_pre().

◆ s_empty_attr

XS_String XMLStorage::XMLWriter::s_empty_attr
staticprotected

Definition at line 2986 of file xmlstorage.h.

Referenced by operator[]().


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