xmlTiny::TiXmlDeclaration Class Reference

In correct XML the declaration is the first entry in the file. More...

#include <OBTtinyxml.h>

Inheritance diagram for xmlTiny::TiXmlDeclaration:

Inheritance graph
[legend]
Collaboration diagram for xmlTiny::TiXmlDeclaration:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 TiXmlDeclaration ()
 Construct an empty declaration.
 TiXmlDeclaration (const std::string &_version, const std::string &_encoding, const std::string &_standalone)
 Constructor.
 TiXmlDeclaration (const char *_version, const char *_encoding, const char *_standalone)
 Construct.
 TiXmlDeclaration (const TiXmlDeclaration &copy)
void operator= (const TiXmlDeclaration &copy)
virtual ~TiXmlDeclaration ()
const char * Version () const
 Version. Will return an empty string if none was found.
const char * Encoding () const
 Encoding. Will return an empty string if none was found.
const char * Standalone () const
 Is this a standalone document?
virtual TiXmlNodeClone () const
 Creates a copy of this Declaration and returns it.
virtual void Print (FILE *cfile, int depth, TIXML_STRING *str) const
virtual void Print (FILE *cfile, int depth) const
 All TinyXml classes can print themselves to a filestream or the string class (TiXmlString in non-STL mode, std::string in STL mode.
virtual const char * Parse (const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
virtual const
TiXmlDeclaration
ToDeclaration () const
 Cast to a more defined type. Will return null not of the requested type.
virtual
TiXmlDeclaration
ToDeclaration ()
 Cast to a more defined type. Will return null not of the requested type.
virtual bool Accept (TiXmlVisitor *visitor) const
 Walk the XML tree visiting this node and all of its children.

Protected Member Functions

void CopyTo (TiXmlDeclaration *target) const
virtual void StreamIn (std::istream *in, TIXML_STRING *tag)

Private Attributes

TIXML_STRING version
TIXML_STRING encoding
TIXML_STRING standalone


Detailed Description

In correct XML the declaration is the first entry in the file.

		<?xml version="1.0" standalone="yes"?>
	

TinyXml will happily read or write files without a declaration, however. There are 3 possible attributes to the declaration: version, encoding, and standalone.

Note: In this version of the code, the attributes are handled as special cases, not generic attributes, simply because there can only be at most 3 and they are always the same.

Definition at line 1282 of file tiny/tmp/OBTtinyxml.h.


Constructor & Destructor Documentation

xmlTiny::TiXmlDeclaration::TiXmlDeclaration (  )  [inline]

Construct an empty declaration.

Definition at line 1286 of file tiny/tmp/OBTtinyxml.h.

Referenced by Clone().

xmlTiny::TiXmlDeclaration::TiXmlDeclaration ( const std::string &  _version,
const std::string &  _encoding,
const std::string &  _standalone 
)

Constructor.

xmlTiny::TiXmlDeclaration::TiXmlDeclaration ( const char *  _version,
const char *  _encoding,
const char *  _standalone 
)

Construct.

Definition at line 1385 of file tiny/tmp/OBTtinyxml.cpp.

References encoding, standalone, and version.

01388         : TiXmlNode( TiXmlNode::DECLARATION )
01389 {
01390         version = _version;
01391         encoding = _encoding;
01392         standalone = _standalone;
01393 }

xmlTiny::TiXmlDeclaration::TiXmlDeclaration ( const TiXmlDeclaration copy  ) 

Definition at line 1409 of file tiny/tmp/OBTtinyxml.cpp.

References CopyTo().

01410         : TiXmlNode( TiXmlNode::DECLARATION )
01411 {
01412         copy.CopyTo( this );    
01413 }

virtual xmlTiny::TiXmlDeclaration::~TiXmlDeclaration (  )  [inline, virtual]

Definition at line 1303 of file tiny/tmp/OBTtinyxml.h.

01303 {}


Member Function Documentation

void xmlTiny::TiXmlDeclaration::operator= ( const TiXmlDeclaration copy  ) 

Definition at line 1416 of file tiny/tmp/OBTtinyxml.cpp.

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

01417 {
01418         Clear();
01419         copy.CopyTo( this );
01420 }

const char* xmlTiny::TiXmlDeclaration::Version (  )  const [inline]

Version. Will return an empty string if none was found.

Definition at line 1306 of file tiny/tmp/OBTtinyxml.h.

References version.

01306 { return version.c_str (); }

const char* xmlTiny::TiXmlDeclaration::Encoding (  )  const [inline]

Encoding. Will return an empty string if none was found.

Definition at line 1308 of file tiny/tmp/OBTtinyxml.h.

References encoding.

Referenced by xmlTiny::TiXmlDocument::Parse().

01308 { return encoding.c_str (); }

const char* xmlTiny::TiXmlDeclaration::Standalone (  )  const [inline]

Is this a standalone document?

Definition at line 1310 of file tiny/tmp/OBTtinyxml.h.

References standalone.

01310 { return standalone.c_str (); }

TiXmlNode * xmlTiny::TiXmlDeclaration::Clone (  )  const [virtual]

Creates a copy of this Declaration and returns it.

Implements xmlTiny::TiXmlNode.

Definition at line 1461 of file tiny/tmp/OBTtinyxml.cpp.

References CopyTo(), and TiXmlDeclaration().

01462 {       
01463         TiXmlDeclaration* clone = new TiXmlDeclaration();
01464 
01465         if ( !clone )
01466                 return 0;
01467 
01468         CopyTo( clone );
01469         return clone;
01470 }

void xmlTiny::TiXmlDeclaration::Print ( FILE *  cfile,
int  depth,
TIXML_STRING *  str 
) const [virtual]

Definition at line 1423 of file tiny/tmp/OBTtinyxml.cpp.

References encoding, standalone, and version.

Referenced by Print(), and xmlTiny::TiXmlPrinter::Visit().

01424 {
01425         if ( cfile ) fprintf( cfile, "<?xml " );
01426         if ( str )       (*str) += "<?xml ";
01427 
01428         if ( !version.empty() ) {
01429                 if ( cfile ) fprintf (cfile, "version=\"%s\" ", version.c_str ());
01430                 if ( str ) { (*str) += "version=\""; (*str) += version; (*str) += "\" "; }
01431         }
01432         if ( !encoding.empty() ) {
01433                 if ( cfile ) fprintf (cfile, "encoding=\"%s\" ", encoding.c_str ());
01434                 if ( str ) { (*str) += "encoding=\""; (*str) += encoding; (*str) += "\" "; }
01435         }
01436         if ( !standalone.empty() ) {
01437                 if ( cfile ) fprintf (cfile, "standalone=\"%s\" ", standalone.c_str ());
01438                 if ( str ) { (*str) += "standalone=\""; (*str) += standalone; (*str) += "\" "; }
01439         }
01440         if ( cfile ) fprintf( cfile, "?>" );
01441         if ( str )       (*str) += "?>";
01442 }

virtual void xmlTiny::TiXmlDeclaration::Print ( FILE *  cfile,
int  depth 
) const [inline, 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 xmlTiny::TiXmlBase.

Definition at line 1316 of file tiny/tmp/OBTtinyxml.h.

References Print().

01316                                                            {
01317                 Print( cfile, depth, 0 );
01318         }

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

Implements xmlTiny::TiXmlBase.

Definition at line 1574 of file tiny/tmp/OBTtinyxmlparser.cpp.

References xmlTiny::TiXmlParsingData::Cursor(), encoding, xmlTiny::TiXmlNode::GetDocument(), xmlTiny::TiXmlBase::IsWhiteSpace(), xmlTiny::TiXmlBase::location, xmlTiny::TiXmlAttribute::Parse(), xmlTiny::TiXmlDocument::SetError(), xmlTiny::TiXmlBase::SkipWhiteSpace(), xmlTiny::TiXmlParsingData::Stamp(), standalone, xmlTiny::TiXmlBase::StringEqual(), xmlTiny::TiXmlBase::TIXML_ERROR_PARSING_DECLARATION, xmlTiny::TiXmlAttribute::Value(), and version.

01575 {
01576         p = SkipWhiteSpace( p, _encoding );
01577         // Find the beginning, find the end, and look for
01578         // the stuff in-between.
01579         TiXmlDocument* document = GetDocument();
01580         if ( !p || !*p || !StringEqual( p, "<?xml", true, _encoding ) )
01581         {
01582                 if ( document ) document->SetError( TIXML_ERROR_PARSING_DECLARATION, 0, 0, _encoding );
01583                 return 0;
01584         }
01585         if ( data )
01586         {
01587                 data->Stamp( p, _encoding );
01588                 location = data->Cursor();
01589         }
01590         p += 5;
01591 
01592         version = "";
01593         encoding = "";
01594         standalone = "";
01595 
01596         while ( p && *p )
01597         {
01598                 if ( *p == '>' )
01599                 {
01600                         ++p;
01601                         return p;
01602                 }
01603 
01604                 p = SkipWhiteSpace( p, _encoding );
01605                 if ( StringEqual( p, "version", true, _encoding ) )
01606                 {
01607                         TiXmlAttribute attrib;
01608                         p = attrib.Parse( p, data, _encoding );         
01609                         version = attrib.Value();
01610                 }
01611                 else if ( StringEqual( p, "encoding", true, _encoding ) )
01612                 {
01613                         TiXmlAttribute attrib;
01614                         p = attrib.Parse( p, data, _encoding );         
01615                         encoding = attrib.Value();
01616                 }
01617                 else if ( StringEqual( p, "standalone", true, _encoding ) )
01618                 {
01619                         TiXmlAttribute attrib;
01620                         p = attrib.Parse( p, data, _encoding );         
01621                         standalone = attrib.Value();
01622                 }
01623                 else
01624                 {
01625                         // Read over whatever it is.
01626                         while( p && *p && *p != '>' && !IsWhiteSpace( *p ) )
01627                                 ++p;
01628                 }
01629         }
01630         return 0;
01631 }

virtual const TiXmlDeclaration* xmlTiny::TiXmlDeclaration::ToDeclaration (  )  const [inline, virtual]

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

Reimplemented from xmlTiny::TiXmlNode.

Definition at line 1322 of file tiny/tmp/OBTtinyxml.h.

virtual TiXmlDeclaration* xmlTiny::TiXmlDeclaration::ToDeclaration (  )  [inline, virtual]

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

Reimplemented from xmlTiny::TiXmlNode.

Definition at line 1323 of file tiny/tmp/OBTtinyxml.h.

bool xmlTiny::TiXmlDeclaration::Accept ( TiXmlVisitor visitor  )  const [virtual]

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

Implements xmlTiny::TiXmlNode.

Definition at line 1455 of file tiny/tmp/OBTtinyxml.cpp.

References xmlTiny::TiXmlVisitor::Visit().

01456 {
01457         return visitor->Visit( *this );
01458 }

void xmlTiny::TiXmlDeclaration::CopyTo ( TiXmlDeclaration target  )  const [protected]

Definition at line 1445 of file tiny/tmp/OBTtinyxml.cpp.

References xmlTiny::TiXmlNode::CopyTo(), encoding, standalone, and version.

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

01446 {
01447         TiXmlNode::CopyTo( target );
01448 
01449         target->version = version;
01450         target->encoding = encoding;
01451         target->standalone = standalone;
01452 }

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

Implements xmlTiny::TiXmlNode.


Member Data Documentation

TIXML_STRING xmlTiny::TiXmlDeclaration::version [private]

Definition at line 1338 of file tiny/tmp/OBTtinyxml.h.

Referenced by CopyTo(), Parse(), Print(), TiXmlDeclaration(), and Version().

TIXML_STRING xmlTiny::TiXmlDeclaration::encoding [private]

Definition at line 1339 of file tiny/tmp/OBTtinyxml.h.

Referenced by CopyTo(), Encoding(), Parse(), Print(), and TiXmlDeclaration().

TIXML_STRING xmlTiny::TiXmlDeclaration::standalone [private]

Definition at line 1340 of file tiny/tmp/OBTtinyxml.h.

Referenced by CopyTo(), Parse(), Print(), Standalone(), and TiXmlDeclaration().


Generated on Wed Oct 1 11:34:25 2008 for OBT by  doxygen 1.5.3