ReactOS  0.4.12-dev-721-g03c3dd5
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 More...
 
bool back ()
 go back to previous position More...
 
void put (const XS_String &attr_name, const XS_String &value)
 attribute setting More...
 
XS_Stringoperator[] (const XS_String &attr_name)
 index operator write access to an attribute More...
 
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 More...
 

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),
2906  _format(format)
2907  {
2908  format.print_header(_out, false); // _format._endl is printed in write_pre()
2909  }
std::ostream & _out
Definition: xmlstorage.h:2968
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
smooth NULL
Definition: ftsmooth.c:416
static FILE * out
Definition: regtests2xml.c:44
tofstream * _pofstream
Definition: xmlstorage.h:2967
void print_header(std::ostream &out, bool lf=true) const
Definition: xmlstorage.cpp:740

◆ 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),
2914  _format(format)
2915  {
2916  format.print_header(_out, false); // _format._endl is printed in write_pre()
2917  }
std::ostream & _out
Definition: xmlstorage.h:2968
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
Definition: services.c:325
tofstream * _pofstream
Definition: xmlstorage.h:2967
void print_header(std::ostream &out, bool lf=true) const
Definition: xmlstorage.cpp:740

◆ ~XMLWriter()

XMLStorage::XMLWriter::~XMLWriter ( )
inline

Definition at line 2919 of file xmlstorage.h.

2920  {
2921  _out << _format._endl;
2922  delete _pofstream;
2923  }
std::ostream & _out
Definition: xmlstorage.h:2968
const char * _endl
Definition: xmlstorage.h:789
tofstream * _pofstream
Definition: xmlstorage.h:2967

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 }

◆ 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) {
959  close_pre(last);
960  }
961 
962  ++last._children;
963  }
964 
965  StackEntry entry;
966  entry._node_name = name;
967  _stack.push(entry);
968 
969  write_pre(entry);
970 }
void write_pre(StackEntry &entry)
Definition: xmlstorage.cpp:990
POINT last
Definition: font.c:46
uint8_t entry
Definition: isohybrid.c:63
std::stack< StackEntry > _stack
Definition: xmlstorage.h:2984
void write_attributes(StackEntry &entry)
void close_pre(StackEntry &entry)
Definition: xmlstorage.cpp:983
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by create_node_content().

◆ 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  }
void create(const XS_String &name)
create node and move to it
Definition: xmlstorage.cpp:952
bool back()
go back to previous position
Definition: xmlstorage.cpp:972
void set_content(const XS_String &s, bool cdata=false)
Definition: xmlstorage.h:2947
content
Definition: atl_ax.c:994

◆ operator[]()

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  }
std::stack< StackEntry > _stack
Definition: xmlstorage.h:2984
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  }
GLsizei const GLfloat * value
Definition: glext.h:6069
std::stack< StackEntry > _stack
Definition: xmlstorage.h:2984

◆ 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::stack< StackEntry > _stack
Definition: xmlstorage.h:2984
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 }
uint8_t entry
Definition: isohybrid.c:63
std::ostream & _out
Definition: xmlstorage.h:2968
std::string EncodeXMLString(const XS_String &str, bool cdata)
encode XML string literals
Definition: xmlstorage.cpp:374

◆ 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)
1019  close_pre(entry);
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 }
uint8_t entry
Definition: isohybrid.c:63
std::ostream & _out
Definition: xmlstorage.h:2968
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
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define XML_INDENT_SPACE
Definition: xmlstorage.h:617
PRETTY_FLAGS _pretty
Definition: xmlstorage.h:788
const char * _endl
Definition: xmlstorage.h:789
std::stack< StackEntry > _stack
Definition: xmlstorage.h:2984
std::string EncodeXMLString(const XS_String &str, bool cdata)
encode XML string literals
Definition: xmlstorage.cpp:374
void write_attributes(StackEntry &entry)
void close_pre(StackEntry &entry)
Definition: xmlstorage.cpp:983

◆ write_pre()

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

Definition at line 990 of file xmlstorage.cpp.

991 {
993  _out << _format._endl;
994 
995  if (_format._pretty == PRETTY_INDENT) {
996  for(size_t i=_stack.size(); --i>0; )
998  }
999 
1000  _out << '<' << EncodeXMLString(entry._node_name);
1001  //entry._state = PRE;
1002 }
uint8_t entry
Definition: isohybrid.c:63
std::ostream & _out
Definition: xmlstorage.h:2968
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
#define XML_INDENT_SPACE
Definition: xmlstorage.h:617
PRETTY_FLAGS _pretty
Definition: xmlstorage.h:788
const char * _endl
Definition: xmlstorage.h:789
std::stack< StackEntry > _stack
Definition: xmlstorage.h:2984
std::string EncodeXMLString(const XS_String &str, bool cdata)
encode XML string literals
Definition: xmlstorage.cpp:374

Member Data Documentation

◆ _format

XMLFormat XMLStorage::XMLWriter::_format
protected

Definition at line 2969 of file xmlstorage.h.

Referenced by ~XMLWriter().

◆ _out

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

Definition at line 2968 of file xmlstorage.h.

Referenced by 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 operator[](), put(), and set_content().

◆ 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: