#include <tinyxml.h>
Public Member Functions | |
TiXmlComment () | |
Constructs an empty comment. | |
TiXmlComment (const char *_value) | |
Construct a comment from text. | |
TiXmlComment (const TiXmlComment &) | |
void | operator= (const TiXmlComment &base) |
virtual | ~TiXmlComment () |
virtual TiXmlNode * | Clone () const |
Returns a copy of this Comment. | |
virtual void | Print (FILE *cfile, int depth) const |
virtual const char * | Parse (const char *p, TiXmlParsingData *data, TiXmlEncoding encoding) |
virtual const TiXmlComment * | ToComment () const |
Cast to a more defined type. Will return null not of the requested type. | |
virtual TiXmlComment * | ToComment () |
Cast to a more defined type. Will return null not of the requested type. | |
virtual bool | Accept (TiXmlVisitor *visitor) const |
Protected Member Functions | |
void | CopyTo (TiXmlComment *target) const |
virtual void | StreamIn (std::istream *in, TiXmlString *tag) |
An XML comment.
Definition at line 1160 of file tinyxml.h.
TiXmlComment::TiXmlComment | ( | ) | [inline] |
Constructs an empty comment.
Definition at line 1164 of file tinyxml.h.
Referenced by Clone().
: TiXmlNode( TiXmlNode::TINYXML_COMMENT ) {}
TiXmlComment::TiXmlComment | ( | const char * | _value ) | [inline] |
Construct a comment from text.
Definition at line 1166 of file tinyxml.h.
References TiXmlNode::SetValue().
: TiXmlNode( TiXmlNode::TINYXML_COMMENT ) { SetValue( _value ); }
TiXmlComment::TiXmlComment | ( | const TiXmlComment & | copy ) |
Definition at line 1238 of file tinyxml.cpp.
References CopyTo().
: TiXmlNode( TiXmlNode::TINYXML_COMMENT ) { copy.CopyTo( this ); }
virtual TiXmlComment::~TiXmlComment | ( | ) | [inline, virtual] |
bool TiXmlComment::Accept | ( | TiXmlVisitor * | visitor ) | const [virtual] |
Walk the XML tree visiting this node and all of its children.
Implements TiXmlNode.
Definition at line 1268 of file tinyxml.cpp.
References TiXmlVisitor::Visit().
{ return visitor->Visit( *this ); }
TiXmlNode * TiXmlComment::Clone | ( | ) | const [virtual] |
Returns a copy of this Comment.
Implements TiXmlNode.
Definition at line 1274 of file tinyxml.cpp.
References CopyTo(), and TiXmlComment().
{ TiXmlComment* clone = new TiXmlComment(); if ( !clone ) return 0; CopyTo( clone ); return clone; }
void TiXmlComment::CopyTo | ( | TiXmlComment * | target ) | const [protected] |
Definition at line 1262 of file tinyxml.cpp.
Referenced by Clone(), operator=(), and TiXmlComment().
{ TiXmlNode::CopyTo( target ); }
void TiXmlComment::operator= | ( | const TiXmlComment & | base ) |
Definition at line 1244 of file tinyxml.cpp.
References TiXmlNode::Clear(), and CopyTo().
const char * TiXmlComment::Parse | ( | const char * | p, |
TiXmlParsingData * | data, | ||
TiXmlEncoding | encoding | ||
) | [virtual] |
Implements TiXmlBase.
Definition at line 1336 of file tinyxmlparser.cpp.
References TiXmlParsingData::Cursor(), TiXmlNode::GetDocument(), TiXmlBase::location, TiXmlDocument::SetError(), TiXmlBase::SkipWhiteSpace(), TiXmlParsingData::Stamp(), TiXmlBase::StringEqual(), TiXmlBase::TIXML_ERROR_PARSING_COMMENT, and TiXmlNode::value.
{ TiXmlDocument* document = GetDocument(); value = ""; p = SkipWhiteSpace( p, encoding ); if ( data ) { data->Stamp( p, encoding ); location = data->Cursor(); } const char* startTag = "<!--"; const char* endTag = "-->"; if ( !StringEqual( p, startTag, false, encoding ) ) { document->SetError( TIXML_ERROR_PARSING_COMMENT, p, data, encoding ); return 0; } p += strlen( startTag ); // [ 1475201 ] TinyXML parses entities in comments // Oops - ReadText doesn't work, because we don't want to parse the entities. // p = ReadText( p, &value, false, endTag, false, encoding ); // // from the XML spec: /* [Definition: Comments may appear anywhere in a document outside other markup; in addition, they may appear within the document type declaration at places allowed by the grammar. They are not part of the document's character data; an XML processor MAY, but need not, make it possible for an application to retrieve the text of comments. For compatibility, the string "--" (double-hyphen) MUST NOT occur within comments.] Parameter entity references MUST NOT be recognized within comments. An example of a comment: <!-- declarations for <head> & <body> --> */ value = ""; // Keep all the white space. while ( p && *p && !StringEqual( p, endTag, false, encoding ) ) { value.append( p, 1 ); ++p; } if ( p && *p ) p += strlen( endTag ); return p; }
void TiXmlComment::Print | ( | FILE * | cfile, |
int | depth | ||
) | const [virtual] |
All TinyXml classes can print themselves to a filestream or the string class (TiXmlString in non-STL mode, std::string in STL mode.) Either or both cfile and str can be null.
This is a formatted print, and will insert tabs and newlines.
(For an unformatted stream, use the << operator.)
Implements TiXmlBase.
Definition at line 1251 of file tinyxml.cpp.
References TiXmlNode::value.
{ assert( cfile ); for ( int i=0; i<depth; i++ ) { fprintf( cfile, " " ); } fprintf( cfile, "<!--%s-->", value.c_str() ); }
void TiXmlComment::StreamIn | ( | std::istream * | in, |
TiXmlString * | tag | ||
) | [protected, virtual] |
Implements TiXmlNode.
Definition at line 1309 of file tinyxmlparser.cpp.
References TiXmlNode::GetDocument(), TiXmlDocument::SetError(), TIXML_ENCODING_UNKNOWN, and TiXmlBase::TIXML_ERROR_EMBEDDED_NULL.
{ while ( in->good() ) { int c = in->get(); if ( c <= 0 ) { TiXmlDocument* document = GetDocument(); if ( document ) document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); return; } (*tag) += (char) c; if ( c == '>' && tag->at( tag->length() - 2 ) == '-' && tag->at( tag->length() - 3 ) == '-' ) { // All is well. return; } } }
virtual const TiXmlComment* TiXmlComment::ToComment | ( | ) | const [inline, virtual] |
virtual TiXmlComment* TiXmlComment::ToComment | ( | ) | [inline, virtual] |