FlightGear next
SimpleDOM.cxx
Go to the documentation of this file.
1#include "SimpleDOM.hxx"
2using std::string;
3
4namespace flightgear {
5namespace http {
6
8{
9 for( Children_t::const_iterator it = _children.begin(); it != _children.end(); ++it )
10 delete *it;
11}
12
13string DOMNode::render() const
14{
15 string reply;
16 reply.append( "<" ).append( _name );
17 for( Attributes_t::const_iterator it = _attributes.begin(); it != _attributes.end(); ++it ) {
18 reply.append( " " );
19 reply.append( it->first );
20 reply.append( "=\"" );
21 reply.append( it->second );
22 reply.append( "\"" );
23 }
24
25 if( _children.empty() ) {
26 reply.append( " />\r" );
27 return reply;
28 } else {
29 reply.append( ">" );
30 }
31
32 for( Children_t::const_iterator it = _children.begin(); it != _children.end(); ++it ) {
33 reply.append( (*it)->render() );
34 }
35
36 reply.append( "</" ).append( _name ).append( ">\r" );
37
38 return reply;
39}
40
42{
43 _children.push_back( child );
44 return dynamic_cast<DOMNode*>(child);
45}
46
47DOMNode * DOMNode::setAttribute( const string & name, const string & value )
48{
49 _attributes[name] = value;
50 return this;
51}
52
53}
54}
virtual std::string render() const
Definition SimpleDOM.cxx:13
virtual DOMNode * setAttribute(const std::string &name, const std::string &value)
Definition SimpleDOM.cxx:47
virtual DOMNode * addChild(DOMElement *child)
Definition SimpleDOM.cxx:41
DOMNode(const std::string &name)
Definition SimpleDOM.hxx:48
FlightPlan.hxx - defines a full flight-plan object, including departure, cruise, arrival information ...
Definition Addon.cxx:53
const char * name