Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Attributes

HTMLWriter Struct Reference

Inheritance diagram for HTMLWriter:
Inheritance graph
[legend]
Collaboration diagram for HTMLWriter:
Collaboration graph
[legend]

List of all members.

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

Detailed Description

Definition at line 385 of file httpsrv.cpp.


Member Typedef Documentation

typedef XMLNode::AttributeMap XMLStorage::XMLWriter::AttrMap [protected, inherited]

Definition at line 4259 of file xmlstorage.h.


Member Enumeration Documentation

Enumerator:
NOTHING 
ATTRIBUTES 
PRE_CLOSED 
POST 

Definition at line 4250 of file xmlstorage.h.

                    {
        NOTHING, /*PRE,*/ ATTRIBUTES, PRE_CLOSED, /*CONTENT,*/ POST
    };

Constructor & Destructor Documentation

HTMLWriter::HTMLWriter ( ostream &  out ) [inline]

Definition at line 387 of file httpsrv.cpp.

     :  XMLWriter(out, HTMLFormat())
    {
    }

Member Function Documentation

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;
    }
}

Here is the caller graph for this function:

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);
}

Here is the caller graph for this function:

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();
    }

Here is the call graph for this function:

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.

    {
        if (!_stack.empty())
            _stack.top()._attributes[attr_name] = value;
    }
void XMLStorage::XMLWriter::set_attributes ( const XMLNode::AttributeMap attrs ) [inline, inherited]

Definition at line 4218 of file xmlstorage.h.

References XMLStorage::XMLWriter::_stack.

    {
        if (!_stack.empty())
            _stack.top()._attributes = attrs;
    }
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);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

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.

    {
        if (!_stack.empty())
            _stack.top()._content = s;
    }
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;
}

Member Data Documentation

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]
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]
XS_String XMLStorage::XMLWriter::s_empty_attr [static, protected, inherited]

Definition at line 4274 of file xmlstorage.h.

Referenced by XMLStorage::XMLWriter::operator[]().


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