TiXmlComment Class Reference

#include <tinyxml.h>

Inheritance diagram for TiXmlComment:
TiXmlNode TiXmlBase

List of all members.

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 TiXmlNodeClone () 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 TiXmlCommentToComment () const
 Cast to a more defined type. Will return null not of the requested type.
virtual TiXmlCommentToComment ()
 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, TIXML_STRING *tag)

Detailed Description

An XML comment.

Definition at line 1133 of file tinyxml.h.


Constructor & Destructor Documentation

TiXmlComment::TiXmlComment (  )  [inline]

Constructs an empty comment.

Definition at line 1137 of file tinyxml.h.

Referenced by Clone().

TiXmlComment::TiXmlComment ( const char *  _value  )  [inline]

Construct a comment from text.

Definition at line 1139 of file tinyxml.h.

References TiXmlNode::SetValue().

01139                                            : TiXmlNode( TiXmlNode::COMMENT ) {
01140                 SetValue( _value );
01141         }

TiXmlComment::TiXmlComment ( const TiXmlComment copy  ) 

Definition at line 1269 of file tinyxml.cpp.

References CopyTo().

01269                                                      : TiXmlNode( TiXmlNode::COMMENT )
01270 {
01271         copy.CopyTo( this );
01272 }

virtual TiXmlComment::~TiXmlComment (  )  [inline, virtual]

Definition at line 1145 of file tinyxml.h.

01145 {}


Member Function Documentation

bool TiXmlComment::Accept ( TiXmlVisitor visitor  )  const [virtual]

Walk the XML tree visiting this node and all of its children.

Implements TiXmlNode.

Definition at line 1299 of file tinyxml.cpp.

References TiXmlVisitor::Visit().

01300 {
01301         return visitor->Visit( *this );
01302 }

TiXmlNode * TiXmlComment::Clone (  )  const [virtual]

Returns a copy of this Comment.

Implements TiXmlNode.

Definition at line 1305 of file tinyxml.cpp.

References CopyTo(), and TiXmlComment().

01306 {
01307         TiXmlComment* clone = new TiXmlComment();
01308 
01309         if ( !clone )
01310                 return 0;
01311 
01312         CopyTo( clone );
01313         return clone;
01314 }

void TiXmlComment::CopyTo ( TiXmlComment target  )  const [protected]

Reimplemented from TiXmlNode.

Definition at line 1293 of file tinyxml.cpp.

Referenced by Clone(), operator=(), and TiXmlComment().

01294 {
01295         TiXmlNode::CopyTo( target );
01296 }

void TiXmlComment::operator= ( const TiXmlComment base  ) 

Reimplemented from TiXmlNode.

Definition at line 1275 of file tinyxml.cpp.

References TiXmlNode::Clear(), and CopyTo().

01276 {
01277         Clear();
01278         base.CopyTo( this );
01279 }

const char * TiXmlComment::Parse ( const char *  p,
TiXmlParsingData data,
TiXmlEncoding  encoding 
) [virtual]

Implements TiXmlBase.

Definition at line 1331 of file tinyxmlparser.cpp.

References TiXmlParsingData::Cursor(), TiXmlNode::GetDocument(), TiXmlBase::location, TiXmlBase::ReadText(), TiXmlDocument::SetError(), TiXmlBase::SkipWhiteSpace(), TiXmlParsingData::Stamp(), TiXmlBase::StringEqual(), TiXmlBase::TIXML_ERROR_PARSING_COMMENT, and TiXmlNode::value.

01332 {
01333         TiXmlDocument* document = GetDocument();
01334         value = "";
01335 
01336         p = SkipWhiteSpace( p, encoding );
01337 
01338         if ( data )
01339         {
01340                 data->Stamp( p, encoding );
01341                 location = data->Cursor();
01342         }
01343         const char* startTag = "<!--";
01344         const char* endTag   = "-->";
01345 
01346         if ( !StringEqual( p, startTag, false, encoding ) )
01347         {
01348                 document->SetError( TIXML_ERROR_PARSING_COMMENT, p, data, encoding );
01349                 return 0;
01350         }
01351         p += strlen( startTag );
01352         p = ReadText( p, &value, false, endTag, false, encoding );
01353         return p;
01354 }

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 1282 of file tinyxml.cpp.

References TiXmlNode::value.

01283 {
01284         assert( cfile );
01285         for ( int i=0; i<depth; i++ )
01286         {
01287                 fprintf( cfile,  "    " );
01288         }
01289         fprintf( cfile, "<!--%s-->", value.c_str() );
01290 }

void TiXmlComment::StreamIn ( std::istream *  in,
TIXML_STRING *  tag 
) [protected, virtual]

Implements TiXmlNode.

Definition at line 1304 of file tinyxmlparser.cpp.

References TiXmlNode::GetDocument(), TiXmlDocument::SetError(), TIXML_ENCODING_UNKNOWN, and TiXmlBase::TIXML_ERROR_EMBEDDED_NULL.

01305 {
01306         while ( in->good() )
01307         {
01308                 int c = in->get();      
01309                 if ( c <= 0 )
01310                 {
01311                         TiXmlDocument* document = GetDocument();
01312                         if ( document )
01313                                 document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN );
01314                         return;
01315                 }
01316 
01317                 (*tag) += (char) c;
01318 
01319                 if ( c == '>' 
01320                          && tag->at( tag->length() - 2 ) == '-'
01321                          && tag->at( tag->length() - 3 ) == '-' )
01322                 {
01323                         // All is well.
01324                         return;         
01325                 }
01326         }
01327 }

virtual TiXmlComment* TiXmlComment::ToComment (  )  [inline, virtual]

Cast to a more defined type. Will return null not of the requested type.

Reimplemented from TiXmlNode.

Definition at line 1158 of file tinyxml.h.

virtual const TiXmlComment* TiXmlComment::ToComment (  )  const [inline, virtual]

Cast to a more defined type. Will return null not of the requested type.

Reimplemented from TiXmlNode.

Definition at line 1157 of file tinyxml.h.


The documentation for this class was generated from the following files:

Generated on 3 Oct 2018 for loon by  doxygen 1.6.1