|
Milo
0.1
Milo:EquationManipulationProgram
|
#include <xml.h>

Public Member Functions | |
| Stream (std::ostream &os, const std::string &root, int step=2, std::string sep="\n") | |
| ~Stream () | |
| void | out (State state) |
| void | out (const std::string &tag) |
Private Types | |
| enum | Pending { NONE, HEADER_TAG, NAME, VALUE, ELEMENT_TAG } |
Private Attributes | |
| std::string | m_sep |
| Character to output before indention. | |
| std::ostream & | m_os |
| Ouput character stream to write XML. | |
| const int | m_indent_step |
| Number of spaces in indention before HEADER and standalone FOOTER. | |
| Pending | m_pending = NONE |
| Current pending state. | |
| std::string | m_nv |
| temp space for name tag value. | |
| int | m_indent = 0 |
| current indention of XML line. | |
| FSM | fsm |
| current FSM state. | |
Output stream for XML. Overloaded << operator is used to output XML states and tags. The constructor and destructor adds the root tag supplied ("document" in this example) level to the output. Destructor will also closes all open header tags. Example code:
{
Stream xml(std::cout, "document");
xml << HEADER << "foo";
xml << HEADER << "bar" << NAME_VALUE << "flag" << "true" << ATOM_END;
xml << HEADER << "text" << HEADER_END << ELEMENT << "Example text & element" << FOOTER;
}
This will give output:
<document>
<foo>
<bar flag="true">
<text>Example text & element</text>
</foo>
</document>
|
private |
Possible pending states. The HEADER tag leaves the stream in a HEADER_TAG pending state. The ELEMENT tag leaves thestream in an ELEMENT_TAG pending state. The NAME_VALUE tag leaves the stream in a NAME pending state. After the call to out(const std::string&), the stream is in a value pending state.
| XML::Stream::Stream | ( | std::ostream & | os, |
| const std::string & | root, | ||
| int | step = 2, |
||
| std::string | sep = "\n" |
||
| ) |
| XML::Stream::~Stream | ( | ) |
Destructor for class stream. Close all open headers with a footer.
| void XML::Stream::out | ( | State | state | ) |
Advances the XML output stream to the given state. Some states like footers are complete onto themselves and others like headers create a pending state to complete the transition.
| state | New state for the output stream. |
| void XML::Stream::out | ( | const std::string & | tag | ) |
Called when XML stream has a pending state that needs another string. With the pending state satisfied, it it completes the transistion to the next state.
| tag | String value for pending state. |
1.8.11