CMS 3D CMS Logo

Public Member Functions | Protected Member Functions

TiXmlComment Class Reference

#include <tinyxml.h>

Inheritance diagram for TiXmlComment:
TiXmlNode TiXmlBase

List of all members.

Public Member Functions

virtual bool Accept (TiXmlVisitor *visitor) const
virtual TiXmlNodeClone () const
 Returns a copy of this Comment.
TiXmlCommentoperator= (const TiXmlComment &base)
virtual const char * Parse (const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
virtual void Print (FILE *cfile, int depth) const
 TiXmlComment ()
 Constructs an empty comment.
 TiXmlComment (const char *_value)
 Construct a comment from text.
 TiXmlComment (const TiXmlComment &)
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 ~TiXmlComment ()

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 1157 of file tinyxml.h.


Constructor & Destructor Documentation

TiXmlComment::TiXmlComment ( ) [inline]

Constructs an empty comment.

Definition at line 1161 of file tinyxml.h.

Referenced by Clone().

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

Construct a comment from text.

Definition at line 1163 of file tinyxml.h.

References TiXmlNode::SetValue().

                                           : TiXmlNode( TiXmlNode::COMMENT ) {
                SetValue( _value );
        }
TiXmlComment::TiXmlComment ( const TiXmlComment copy)

Definition at line 1303 of file tinyxml.cc.

References CopyTo().

                                                     : TiXmlNode( TiXmlNode::COMMENT )
{
        copy.CopyTo( this );
}
virtual TiXmlComment::~TiXmlComment ( ) [inline, virtual]

Definition at line 1169 of file tinyxml.h.

{}

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 1334 of file tinyxml.cc.

References TiXmlVisitor::Visit().

{
        return visitor->Visit( *this );
}
TiXmlNode * TiXmlComment::Clone ( ) const [virtual]

Returns a copy of this Comment.

Implements TiXmlNode.

Definition at line 1340 of file tinyxml.cc.

References clone(), 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 1328 of file tinyxml.cc.

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

{
        TiXmlNode::CopyTo( target );
}
TiXmlComment & TiXmlComment::operator= ( const TiXmlComment base)

Definition at line 1309 of file tinyxml.cc.

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

{
        Clear();
        base.CopyTo( this );
        return *this;
}
const char * TiXmlComment::Parse ( const char *  p,
TiXmlParsingData data,
TiXmlEncoding  encoding 
) [virtual]

Implements TiXmlBase.

Definition at line 1345 of file tinyxmlparser.cc.

References TiXmlParsingData::Cursor(), TiXmlNode::GetDocument(), TiXmlBase::location, AlCaHLTBitMon_ParallelJobs::p, 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 += 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 1317 of file tinyxml.cc.

References TiXmlNode::value.

{
        assert( cfile );
        for ( int i=0; i<depth; i++ )
        {
                fprintf( cfile,  "    " );
        }
        fprintf( cfile, "<!--%s-->", value.c_str() );
}
virtual void TiXmlComment::StreamIn ( std::istream *  in,
TIXML_STRING *  tag 
) [protected, virtual]

Implements TiXmlNode.

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 1181 of file tinyxml.h.

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 1182 of file tinyxml.h.