OBT::TiXmlDeclaration Class Reference

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

#include <OBTtinyxml.h>

Inheritance diagram for OBT::TiXmlDeclaration:

Inheritance graph
[legend]
Collaboration diagram for OBT::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.
 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)
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 1284 of file OBTtinyxml.h.


Constructor & Destructor Documentation

OBT::TiXmlDeclaration::TiXmlDeclaration (  )  [inline]

Construct an empty declaration.

Definition at line 1288 of file OBTtinyxml.h.

Referenced by Clone().

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

Constructor.

Definition at line 1396 of file OBTtinyxml.cpp.

References encoding, standalone, and version.

01399         : TiXmlNode( TiXmlNode::DECLARATION )
01400 {
01401         version = _version;
01402         encoding = _encoding;
01403         standalone = _standalone;
01404 }

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

Construct.

Definition at line 1384 of file OBTtinyxml.cpp.

References encoding, standalone, and version.

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

OBT::TiXmlDeclaration::TiXmlDeclaration ( const TiXmlDeclaration copy  ) 

Definition at line 1408 of file OBTtinyxml.cpp.

References CopyTo().

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

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

Definition at line 1305 of file OBTtinyxml.h.

01305 {}

OBT::TiXmlDeclaration::TiXmlDeclaration (  )  [inline]

Construct an empty declaration.

Definition at line 1287 of file tiny/OBTtinyxml.h.

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

Constructor.

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

Construct.

OBT::TiXmlDeclaration::TiXmlDeclaration ( const TiXmlDeclaration copy  ) 

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

Definition at line 1304 of file tiny/OBTtinyxml.h.

01304 {}


Member Function Documentation

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

Definition at line 1415 of file OBTtinyxml.cpp.

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

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

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

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

Definition at line 1308 of file OBTtinyxml.h.

01308 { return version.c_str (); }

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

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

Definition at line 1310 of file OBTtinyxml.h.

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

01310 { return encoding.c_str (); }

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

Is this a standalone document?

Definition at line 1312 of file OBTtinyxml.h.

01312 { return standalone.c_str (); }

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

Creates a copy of this Declaration and returns it.

Implements OBT::TiXmlNode.

Definition at line 1460 of file OBTtinyxml.cpp.

References CopyTo(), and TiXmlDeclaration().

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

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

Definition at line 1422 of file OBTtinyxml.cpp.

References encoding, standalone, and version.

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

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

virtual void OBT::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 OBT::TiXmlBase.

Definition at line 1318 of file OBTtinyxml.h.

01318                                                            {
01319                 Print( cfile, depth, 0 );
01320         }

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

Implements OBT::TiXmlBase.

Definition at line 1574 of file OBTtinyxmlparser.cpp.

References OBT::TiXmlParsingData::Cursor(), encoding, OBT::TiXmlNode::GetDocument(), OBT::TiXmlBase::IsWhiteSpace(), OBT::TiXmlBase::location, OBT::TiXmlAttribute::Parse(), OBT::TiXmlDocument::SetError(), OBT::TiXmlBase::SkipWhiteSpace(), OBT::TiXmlParsingData::Stamp(), standalone, OBT::TiXmlBase::StringEqual(), OBT::TiXmlBase::TIXML_ERROR_PARSING_DECLARATION, OBT::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* OBT::TiXmlDeclaration::ToDeclaration (  )  const [inline, virtual]

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

Reimplemented from OBT::TiXmlNode.

Definition at line 1324 of file OBTtinyxml.h.

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

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

Reimplemented from OBT::TiXmlNode.

Definition at line 1325 of file OBTtinyxml.h.

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

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

Implements OBT::TiXmlNode.

Definition at line 1454 of file OBTtinyxml.cpp.

References OBT::TiXmlVisitor::Visit().

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

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

Definition at line 1444 of file OBTtinyxml.cpp.

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

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

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

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

Implements OBT::TiXmlNode.

Definition at line 1551 of file OBTtinyxmlparser.cpp.

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

01552 {
01553         while ( in->good() )
01554         {
01555                 int c = in->get();
01556                 if ( c <= 0 )
01557                 {
01558                         TiXmlDocument* document = GetDocument();
01559                         if ( document )
01560                                 document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN );
01561                         return;
01562                 }
01563                 (*tag) += (char) c;
01564 
01565                 if ( c == '>' )
01566                 {
01567                         // All is well.
01568                         return;
01569                 }
01570         }
01571 }

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

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

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

Definition at line 1307 of file tiny/OBTtinyxml.h.

References version.

01307 { return version.c_str (); }

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

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

Definition at line 1309 of file tiny/OBTtinyxml.h.

References encoding.

01309 { return encoding.c_str (); }

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

Is this a standalone document?

Definition at line 1311 of file tiny/OBTtinyxml.h.

References standalone.

01311 { return standalone.c_str (); }

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

Creates a copy of this Declaration and returns it.

Implements OBT::TiXmlNode.

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

virtual void OBT::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 OBT::TiXmlBase.

Definition at line 1317 of file tiny/OBTtinyxml.h.

References Print().

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

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

Implements OBT::TiXmlBase.

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

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

Reimplemented from OBT::TiXmlNode.

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

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

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

Reimplemented from OBT::TiXmlNode.

Definition at line 1324 of file tiny/OBTtinyxml.h.

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

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

Implements OBT::TiXmlNode.

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

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

Implements OBT::TiXmlNode.


Member Data Documentation

TIXML_STRING OBT::TiXmlDeclaration::version [private]

Definition at line 1340 of file OBTtinyxml.h.

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

TIXML_STRING OBT::TiXmlDeclaration::encoding [private]

Definition at line 1341 of file OBTtinyxml.h.

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

TIXML_STRING OBT::TiXmlDeclaration::standalone [private]

Definition at line 1342 of file OBTtinyxml.h.

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


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