Public Types | |
enum | WRITESTATE { NOTHING, ATTRIBUTES, PRE_CLOSED, POST } |
Public Member Functions | |
HTMLWriter (ostream &out) | |
bool | good () const |
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_String & | operator[] (const XS_String &attr_name) |
index operator write access to an attribute | |
void | set_attributes (const XMLNode::AttributeMap &attrs) |
void | set_content (const XS_String &s, bool cdata=false) |
set element node content | |
void | set_encoded_content (const std::string &s) |
set element node content from encoded string | |
void | create_node_content (const XS_String &node_name, const XS_String &content) |
create node with string content | |
void | write (const std::string &s) |
direct string output | |
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 |
Private Attributes | |
ostringstream | _buffer |
Definition at line 385 of file httpsrv.cpp.
typedef XMLNode::AttributeMap XMLStorage::XMLWriter::AttrMap [protected, inherited] |
Definition at line 4259 of file xmlstorage.h.
enum XMLStorage::XMLWriter::WRITESTATE [inherited] |
Definition at line 4250 of file xmlstorage.h.
{ NOTHING, /*PRE,*/ ATTRIBUTES, PRE_CLOSED, /*CONTENT,*/ POST };
HTMLWriter::HTMLWriter | ( | ostream & | out ) | [inline] |
Definition at line 387 of file httpsrv.cpp.
: XMLWriter(out, HTMLFormat()) { }
bool XMLStorage::XMLWriter::back | ( | ) | [inherited] |
go back to previous position
Definition at line 1051 of file xmlstorage.cpp.
Referenced by XMLStorage::XMLWriter::create_node_content(), XMLRPC::XMLRPCWriter::flush(), XMLRPC::XMLRPCCall::init(), test_write(), test_writer(), XMLRPC::XMLRPCWriter::write_param(), XMLRPC::XMLRPCWriter::write_string_param(), and XMLRPC::XMLRPCWriter::write_struct().
{ if (!_stack.empty()) { write_post(_stack.top()); _stack.pop(); return true; } else { assert(!_stack.empty()); return false; } }
void XMLStorage::XMLWriter::close_pre | ( | StackEntry & | entry ) | [protected, inherited] |
Definition at line 1064 of file xmlstorage.cpp.
{ _out << '>'; entry._state = PRE_CLOSED; }
void XMLStorage::XMLWriter::create | ( | const XS_String & | name ) | [inherited] |
create node and move to it
Definition at line 1031 of file xmlstorage.cpp.
References XMLStorage::XMLWriter::StackEntry::_children, XMLStorage::XMLWriter::StackEntry::_node_name, and XMLStorage::XMLWriter::StackEntry::_state.
Referenced by XMLStorage::XMLWriter::create_node_content(), XMLRPC::XMLRPCCall::init(), test_write(), test_writer(), XMLRPC::XMLRPCWriter::write_param(), XMLRPC::XMLRPCWriter::write_string_param(), and XMLRPC::XMLRPCWriter::write_struct().
{ if (!_stack.empty()) { StackEntry& last = _stack.top(); if (last._state < PRE_CLOSED) { write_attributes(last); close_pre(last); } ++last._children; } StackEntry entry; entry._node_name = name; _stack.push(entry); write_pre(entry); }
void XMLStorage::XMLWriter::create_node_content | ( | const XS_String & | node_name, |
const XS_String & | content | ||
) | [inline, inherited] |
create node with string content
Definition at line 4239 of file xmlstorage.h.
References XMLStorage::XMLWriter::back(), XMLStorage::XMLWriter::create(), and XMLStorage::XMLWriter::set_content().
{ create(node_name); set_content(content); back(); }
bool XMLStorage::XMLWriter::good | ( | ) | const [inline, inherited] |
Definition at line 4191 of file xmlstorage.h.
References XMLStorage::XMLWriter::_out.
{ return _out.good(); }
XS_String& XMLStorage::XMLWriter::operator[] | ( | const XS_String & | attr_name ) | [inline, inherited] |
index operator write access to an attribute
Definition at line 4210 of file xmlstorage.h.
References XMLStorage::XMLWriter::_stack, and XMLStorage::XMLWriter::s_empty_attr.
{ if (_stack.empty()) return s_empty_attr; return _stack.top()._attributes[attr_name]; }
void XMLStorage::XMLWriter::put | ( | const XS_String & | attr_name, |
const XS_String & | value | ||
) | [inline, inherited] |
attribute setting
Definition at line 4203 of file xmlstorage.h.
References XMLStorage::XMLWriter::_stack.
void XMLStorage::XMLWriter::set_attributes | ( | const XMLNode::AttributeMap & | attrs ) | [inline, inherited] |
Definition at line 4218 of file xmlstorage.h.
References XMLStorage::XMLWriter::_stack.
void XMLStorage::XMLWriter::set_content | ( | const XS_String & | s, |
bool | cdata = false |
||
) | [inline, inherited] |
set element node content
Definition at line 4225 of file xmlstorage.h.
References XMLStorage::XMLWriter::_stack, and XMLStorage::EncodeXMLString().
Referenced by XMLStorage::XMLWriter::create_node_content(), XMLRPC::XMLRPCCall::init(), test_write(), test_writer(), XMLRPC::XMLRPCWriter::write_param(), XMLRPC::XMLRPCWriter::write_string_param(), and XMLRPC::XMLRPCWriter::write_struct().
{ if (!_stack.empty()) _stack.top()._content = EncodeXMLString(s.c_str(), cdata); }
void XMLStorage::XMLWriter::set_encoded_content | ( | const std::string & | s ) | [inline, inherited] |
set element node content from encoded string
Definition at line 4232 of file xmlstorage.h.
References XMLStorage::XMLWriter::_stack.
void XMLStorage::XMLWriter::write | ( | const std::string & | s ) | [inherited] |
direct string output
Definition at line 1121 of file xmlstorage.cpp.
{ if (!_stack.empty()) { StackEntry& last = _stack.top(); if (last._state < PRE_CLOSED) { write_attributes(last); close_pre(last); } } _out.write(s.c_str(), s.length()); }
void XMLStorage::XMLWriter::write_attributes | ( | StackEntry & | entry ) | [protected, inherited] |
Definition at line 1085 of file xmlstorage.cpp.
{ for(AttrMap::const_iterator it=entry._attributes.begin(); it!=entry._attributes.end(); ++it) _out << ' ' << EncodeXMLString(it->first) << "=\"" << EncodeXMLString(it->second) << "\""; entry._state = ATTRIBUTES; }
void XMLStorage::XMLWriter::write_post | ( | StackEntry & | entry ) | [protected, inherited] |
Definition at line 1093 of file xmlstorage.cpp.
{ if (entry._state < ATTRIBUTES) write_attributes(entry); if (entry._children || !entry._content.empty()) { if (entry._state < PRE_CLOSED) close_pre(entry); _out << entry._content; //entry._state = CONTENT; if (_format._pretty>=PRETTY_LINEFEED && entry._content.empty()) _out << _format._endl; if (_format._pretty==PRETTY_INDENT && entry._content.empty()) { for(size_t i=_stack.size(); --i>0; ) _out << XML_INDENT_SPACE; } _out << "</" << EncodeXMLString(entry._node_name) << ">"; } else { _out << "/>"; } entry._state = POST; }
void XMLStorage::XMLWriter::write_pre | ( | StackEntry & | entry ) | [protected, inherited] |
Definition at line 1071 of file xmlstorage.cpp.
{ if (_format._pretty >= PRETTY_LINEFEED) _out << _format._endl; if (_format._pretty == PRETTY_INDENT) { for(size_t i=_stack.size(); --i>0; ) _out << XML_INDENT_SPACE; } _out << '<' << EncodeXMLString(entry._node_name); //entry._state = PRE; }
ostringstream HTMLWriter::_buffer [private] |
Definition at line 393 of file httpsrv.cpp.
XMLFormat XMLStorage::XMLWriter::_format [protected, inherited] |
Definition at line 4257 of file xmlstorage.h.
Referenced by XMLStorage::XMLWriter::~XMLWriter().
std::ostream& XMLStorage::XMLWriter::_out [protected, inherited] |
Definition at line 4256 of file xmlstorage.h.
Referenced by XMLStorage::XMLWriter::good(), XMLStorage::XMLWriter::XMLWriter(), and XMLStorage::XMLWriter::~XMLWriter().
tofstream* XMLStorage::XMLWriter::_pofstream [protected, inherited] |
Definition at line 4255 of file xmlstorage.h.
Referenced by XMLStorage::XMLWriter::~XMLWriter().
std::stack<StackEntry> XMLStorage::XMLWriter::_stack [protected, inherited] |
Definition at line 4272 of file xmlstorage.h.
Referenced by XMLStorage::XMLWriter::operator[](), XMLStorage::XMLWriter::put(), XMLStorage::XMLWriter::set_attributes(), XMLStorage::XMLWriter::set_content(), and XMLStorage::XMLWriter::set_encoded_content().
XS_String XMLStorage::XMLWriter::s_empty_attr [static, protected, inherited] |
Definition at line 4274 of file xmlstorage.h.
Referenced by XMLStorage::XMLWriter::operator[]().