FEDRA emulsion software from the OPERA Collaboration
TiXmlDeclaration Class Reference

#include <tinyxml.h>

Inheritance diagram for TiXmlDeclaration:
Collaboration diagram for TiXmlDeclaration:

Public Member Functions

virtual bool Accept (TiXmlVisitor *visitor) const
 
virtual TiXmlNodeClone () const
 Creates a copy of this Declaration and returns it. More...
 
const char * Encoding () const
 Encoding. Will return an empty string if none was found. More...
 
TiXmlDeclarationoperator= (const TiXmlDeclaration &copy)
 
virtual const char * Parse (const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
 
virtual void Print (FILE *cfile, int depth) const
 
virtual void Print (FILE *cfile, int depth, TIXML_STRING *str) const
 
const char * Standalone () const
 Is this a standalone document? More...
 
 TiXmlDeclaration ()
 Construct an empty declaration. More...
 
 TiXmlDeclaration (const char *_version, const char *_encoding, const char *_standalone)
 Construct. More...
 
 TiXmlDeclaration (const TiXmlDeclaration &copy)
 
virtual TiXmlDeclarationToDeclaration ()
 Cast to a more defined type. Will return null not of the requested type. More...
 
virtual const TiXmlDeclarationToDeclaration () const
 Cast to a more defined type. Will return null not of the requested type. More...
 
const char * Version () const
 Version. Will return an empty string if none was found. More...
 
virtual ~TiXmlDeclaration ()
 
- Public Member Functions inherited from TiXmlNode
virtual bool Accept (TiXmlVisitor *visitor) const =0
 
void Clear ()
 Delete all the children of this node. Does not affect 'this'. More...
 
virtual TiXmlNodeClone () const =0
 
TiXmlNodeFirstChild ()
 
const TiXmlNodeFirstChild () const
 The first child of this node. Will be null if there are no children. More...
 
TiXmlNodeFirstChild (const char *_value)
 The first child of this node with the matching 'value'. Will be null if none found. More...
 
const TiXmlNodeFirstChild (const char *value) const
 
TiXmlElementFirstChildElement ()
 
const TiXmlElementFirstChildElement () const
 Convenience function to get through elements. More...
 
TiXmlElementFirstChildElement (const char *_value)
 
const TiXmlElementFirstChildElement (const char *_value) const
 Convenience function to get through elements. More...
 
TiXmlDocumentGetDocument ()
 
const TiXmlDocumentGetDocument () const
 
TiXmlNodeInsertAfterChild (TiXmlNode *afterThis, const TiXmlNode &addThis)
 
TiXmlNodeInsertBeforeChild (TiXmlNode *beforeThis, const TiXmlNode &addThis)
 
TiXmlNodeInsertEndChild (const TiXmlNode &addThis)
 
TiXmlNodeIterateChildren (const char *_value, const TiXmlNode *previous)
 
const TiXmlNodeIterateChildren (const char *value, const TiXmlNode *previous) const
 This flavor of IterateChildren searches for children with a particular 'value'. More...
 
TiXmlNodeIterateChildren (const TiXmlNode *previous)
 
const TiXmlNodeIterateChildren (const TiXmlNode *previous) const
 
TiXmlNodeLastChild ()
 The last child of this node. Will be null if there are no children. More...
 
const TiXmlNodeLastChild () const
 
TiXmlNodeLastChild (const char *_value)
 The last child of this node matching 'value'. Will be null if there are no children. More...
 
const TiXmlNodeLastChild (const char *value) const
 
TiXmlNodeLinkEndChild (TiXmlNode *addThis)
 
TiXmlNodeNextSibling ()
 
const TiXmlNodeNextSibling () const
 Navigate to a sibling node. More...
 
const TiXmlNodeNextSibling (const char *) const
 Navigate to a sibling node with the given 'value'. More...
 
TiXmlNodeNextSibling (const char *_next)
 
TiXmlElementNextSiblingElement ()
 
const TiXmlElementNextSiblingElement () const
 
const TiXmlElementNextSiblingElement (const char *) const
 
TiXmlElementNextSiblingElement (const char *_next)
 
bool NoChildren () const
 Returns true if this node has no children. More...
 
TiXmlNodeParent ()
 One step up the DOM. More...
 
const TiXmlNodeParent () const
 
TiXmlNodePreviousSibling ()
 
const TiXmlNodePreviousSibling () const
 Navigate to a sibling node. More...
 
const TiXmlNodePreviousSibling (const char *) const
 Navigate to a sibling node. More...
 
TiXmlNodePreviousSibling (const char *_prev)
 
bool RemoveChild (TiXmlNode *removeThis)
 Delete a child of this node. More...
 
TiXmlNodeReplaceChild (TiXmlNode *replaceThis, const TiXmlNode &withThis)
 
void SetValue (const char *_value)
 
virtual TiXmlCommentToComment ()
 Cast to a more defined type. Will return null if not of the requested type. More...
 
virtual const TiXmlCommentToComment () const
 Cast to a more defined type. Will return null if not of the requested type. More...
 
virtual TiXmlDeclarationToDeclaration ()
 Cast to a more defined type. Will return null if not of the requested type. More...
 
virtual const TiXmlDeclarationToDeclaration () const
 Cast to a more defined type. Will return null if not of the requested type. More...
 
virtual TiXmlDocumentToDocument ()
 Cast to a more defined type. Will return null if not of the requested type. More...
 
virtual const TiXmlDocumentToDocument () const
 Cast to a more defined type. Will return null if not of the requested type. More...
 
virtual TiXmlElementToElement ()
 Cast to a more defined type. Will return null if not of the requested type. More...
 
virtual const TiXmlElementToElement () const
 Cast to a more defined type. Will return null if not of the requested type. More...
 
virtual TiXmlTextToText ()
 Cast to a more defined type. Will return null if not of the requested type. More...
 
virtual const TiXmlTextToText () const
 Cast to a more defined type. Will return null if not of the requested type. More...
 
virtual TiXmlUnknownToUnknown ()
 Cast to a more defined type. Will return null if not of the requested type. More...
 
virtual const TiXmlUnknownToUnknown () const
 Cast to a more defined type. Will return null if not of the requested type. More...
 
int Type () const
 
const char * Value () const
 
const TIXML_STRINGValueTStr () const
 
virtual ~TiXmlNode ()
 
- Public Member Functions inherited from TiXmlBase
int Column () const
 See Row() More...
 
voidGetUserData ()
 Get a pointer to arbitrary user data. More...
 
const voidGetUserData () const
 Get a pointer to arbitrary user data. More...
 
virtual const char * Parse (const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)=0
 
virtual void Print (FILE *cfile, int depth) const =0
 
int Row () const
 
void SetUserData (void *user)
 Set a pointer to arbitrary user data. More...
 
 TiXmlBase ()
 
virtual ~TiXmlBase ()
 

Protected Member Functions

void CopyTo (TiXmlDeclaration *target) const
 
- Protected Member Functions inherited from TiXmlNode
void CopyTo (TiXmlNode *target) const
 
TiXmlNodeIdentify (const char *start, TiXmlEncoding encoding)
 
 TiXmlNode (NodeType _type)
 

Private Attributes

TIXML_STRING encoding
 
TIXML_STRING standalone
 
TIXML_STRING version
 

Additional Inherited Members

- Public Types inherited from TiXmlNode
enum  NodeType {
  TINYXML_DOCUMENT , TINYXML_ELEMENT , TINYXML_COMMENT , TINYXML_UNKNOWN ,
  TINYXML_TEXT , TINYXML_DECLARATION , TINYXML_TYPECOUNT
}
 
- Public Types inherited from TiXmlBase
enum  {
  TIXML_NO_ERROR = 0 , TIXML_ERROR , TIXML_ERROR_OPENING_FILE , TIXML_ERROR_PARSING_ELEMENT ,
  TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME , TIXML_ERROR_READING_ELEMENT_VALUE , TIXML_ERROR_READING_ATTRIBUTES , TIXML_ERROR_PARSING_EMPTY ,
  TIXML_ERROR_READING_END_TAG , TIXML_ERROR_PARSING_UNKNOWN , TIXML_ERROR_PARSING_COMMENT , TIXML_ERROR_PARSING_DECLARATION ,
  TIXML_ERROR_DOCUMENT_EMPTY , TIXML_ERROR_EMBEDDED_NULL , TIXML_ERROR_PARSING_CDATA , TIXML_ERROR_DOCUMENT_TOP_ONLY ,
  TIXML_ERROR_STRING_COUNT
}
 
- Static Public Member Functions inherited from TiXmlBase
static void EncodeString (const TIXML_STRING &str, TIXML_STRING *out)
 
static bool IsWhiteSpaceCondensed ()
 Return the current white space setting. More...
 
static void SetCondenseWhiteSpace (bool condense)
 
- Static Public Attributes inherited from TiXmlBase
static const int utf8ByteTable [256]
 
- Static Protected Member Functions inherited from TiXmlBase
static void ConvertUTF32ToUTF8 (unsigned long input, char *output, int *length)
 
static const char * GetChar (const char *p, char *_value, int *length, TiXmlEncoding encoding)
 
static const char * GetEntity (const char *in, char *value, int *length, TiXmlEncoding encoding)
 
static int IsAlpha (unsigned char anyByte, TiXmlEncoding encoding)
 
static int IsAlphaNum (unsigned char anyByte, TiXmlEncoding encoding)
 
static bool IsWhiteSpace (char c)
 
static bool IsWhiteSpace (int c)
 
static const char * ReadName (const char *p, TIXML_STRING *name, TiXmlEncoding encoding)
 
static const char * ReadText (const char *in, TIXML_STRING *text, bool ignoreWhiteSpace, const char *endTag, bool ignoreCase, TiXmlEncoding encoding)
 
static const char * SkipWhiteSpace (const char *, TiXmlEncoding encoding)
 
static bool StringEqual (const char *p, const char *endTag, bool ignoreCase, TiXmlEncoding encoding)
 
static int ToLower (int v, TiXmlEncoding encoding)
 
- Protected Attributes inherited from TiXmlNode
TiXmlNodefirstChild
 
TiXmlNodelastChild
 
TiXmlNodenext
 
TiXmlNodeparent
 
TiXmlNodeprev
 
NodeType type
 
TIXML_STRING value
 
- Protected Attributes inherited from TiXmlBase
TiXmlCursor location
 
voiduserData
 Field containing a generic user pointer. More...
 
- Static Protected Attributes inherited from TiXmlBase
static const char * errorString [TIXML_ERROR_STRING_COUNT]
 

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.

Constructor & Destructor Documentation

◆ TiXmlDeclaration() [1/3]

TiXmlDeclaration::TiXmlDeclaration ( )
inline

Construct an empty declaration.

friend class TiXmlNode
Definition: tinyxml.h:196
@ TINYXML_DECLARATION
Definition: tinyxml.h:469

◆ TiXmlDeclaration() [2/3]

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

Construct.

1383{
1384 version = _version;
1385 encoding = _encoding;
1386 standalone = _standalone;
1387}
TIXML_STRING encoding
Definition: tinyxml.h:1342
TIXML_STRING standalone
Definition: tinyxml.h:1343
TIXML_STRING version
Definition: tinyxml.h:1341

◆ TiXmlDeclaration() [3/3]

TiXmlDeclaration::TiXmlDeclaration ( const TiXmlDeclaration copy)
1405{
1406 copy.CopyTo( this );
1407}
void CopyTo(TiXmlDeclaration *target) const
Definition: tinyxml.cpp:1440

◆ ~TiXmlDeclaration()

virtual TiXmlDeclaration::~TiXmlDeclaration ( )
inlinevirtual
1306{}

Member Function Documentation

◆ Accept()

bool TiXmlDeclaration::Accept ( TiXmlVisitor visitor) const
virtual

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

Implements TiXmlNode.

1451{
1452 return visitor->Visit( *this );
1453}
virtual bool Visit(const TiXmlDeclaration &)
Visit a declaration.
Definition: tinyxml.h:144

◆ Clone()

TiXmlNode * TiXmlDeclaration::Clone ( ) const
virtual

Creates a copy of this Declaration and returns it.

Implements TiXmlNode.

1457{
1458 TiXmlDeclaration* clone = new TiXmlDeclaration();
1459
1460 if ( !clone )
1461 return 0;
1462
1463 CopyTo( clone );
1464 return clone;
1465}
Definition: tinyxml.h:1286
TiXmlDeclaration()
Construct an empty declaration.
Definition: tinyxml.h:1289

◆ CopyTo()

void TiXmlDeclaration::CopyTo ( TiXmlDeclaration target) const
protected
1441{
1442 TiXmlNode::CopyTo( target );
1443
1444 target->version = version;
1445 target->encoding = encoding;
1446 target->standalone = standalone;
1447}
void CopyTo(TiXmlNode *target) const
Definition: tinyxml.cpp:161

◆ Encoding()

const char * TiXmlDeclaration::Encoding ( ) const
inline

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

1311{ return encoding.c_str (); }

◆ operator=()

TiXmlDeclaration & TiXmlDeclaration::operator= ( const TiXmlDeclaration copy)
1411{
1412 Clear();
1413 copy.CopyTo( this );
1414 return *this;
1415}
void Clear()
Delete all the children of this node. Does not affect 'this'.
Definition: tinyxml.cpp:169

◆ Parse()

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

Implements TiXmlBase.

1573{
1574 p = SkipWhiteSpace( p, _encoding );
1575 // Find the beginning, find the end, and look for
1576 // the stuff in-between.
1577 TiXmlDocument* document = GetDocument();
1578 if ( !p || !*p || !StringEqual( p, "<?xml", true, _encoding ) )
1579 {
1580 if ( document ) document->SetError( TIXML_ERROR_PARSING_DECLARATION, 0, 0, _encoding );
1581 return 0;
1582 }
1583 if ( data )
1584 {
1585 data->Stamp( p, _encoding );
1586 location = data->Cursor();
1587 }
1588 p += 5;
1589
1590 version = "";
1591 encoding = "";
1592 standalone = "";
1593
1594 while ( p && *p )
1595 {
1596 if ( *p == '>' )
1597 {
1598 ++p;
1599 return p;
1600 }
1601
1602 p = SkipWhiteSpace( p, _encoding );
1603 if ( StringEqual( p, "version", true, _encoding ) )
1604 {
1605 TiXmlAttribute attrib;
1606 p = attrib.Parse( p, data, _encoding );
1607 version = attrib.Value();
1608 }
1609 else if ( StringEqual( p, "encoding", true, _encoding ) )
1610 {
1611 TiXmlAttribute attrib;
1612 p = attrib.Parse( p, data, _encoding );
1613 encoding = attrib.Value();
1614 }
1615 else if ( StringEqual( p, "standalone", true, _encoding ) )
1616 {
1617 TiXmlAttribute attrib;
1618 p = attrib.Parse( p, data, _encoding );
1619 standalone = attrib.Value();
1620 }
1621 else
1622 {
1623 // Read over whatever it is.
1624 while( p && *p && *p != '>' && !IsWhiteSpace( *p ) )
1625 ++p;
1626 }
1627 }
1628 return 0;
1629}
Definition: tinyxml.h:780
const char * Value() const
Return the value of this attribute.
Definition: tinyxml.h:812
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
Definition: tinyxmlparser.cpp:1392
TiXmlCursor location
Definition: tinyxml.h:373
static bool StringEqual(const char *p, const char *endTag, bool ignoreCase, TiXmlEncoding encoding)
Definition: tinyxmlparser.cpp:534
@ TIXML_ERROR_PARSING_DECLARATION
Definition: tinyxml.h:277
static const char * SkipWhiteSpace(const char *, TiXmlEncoding encoding)
Definition: tinyxmlparser.cpp:314
static bool IsWhiteSpace(char c)
Definition: tinyxml.h:290
Definition: tinyxml.h:1394
void SetError(int err, const char *errorLocation, TiXmlParsingData *prevData, TiXmlEncoding encoding)
Definition: tinyxmlparser.cpp:798
const TiXmlDocument * GetDocument() const
Definition: tinyxml.cpp:512
void Stamp(const char *now, TiXmlEncoding encoding)
Definition: tinyxmlparser.cpp:196
const TiXmlCursor & Cursor() const
Definition: tinyxmlparser.cpp:177
p
Definition: testBGReduction_AllMethods.C:8

◆ Print() [1/2]

virtual void TiXmlDeclaration::Print ( FILE *  cfile,
int  depth 
) const
inlinevirtual

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.

1319 {
1320 Print( cfile, depth, 0 );
1321 }
virtual void Print(FILE *cfile, int depth, TIXML_STRING *str) const
Definition: tinyxml.cpp:1418

◆ Print() [2/2]

void TiXmlDeclaration::Print ( FILE *  cfile,
int  depth,
TIXML_STRING str 
) const
virtual
1419{
1420 if ( cfile ) fprintf( cfile, "<?xml " );
1421 if ( str ) (*str) += "<?xml ";
1422
1423 if ( !version.empty() ) {
1424 if ( cfile ) fprintf (cfile, "version=\"%s\" ", version.c_str ());
1425 if ( str ) { (*str) += "version=\""; (*str) += version; (*str) += "\" "; }
1426 }
1427 if ( !encoding.empty() ) {
1428 if ( cfile ) fprintf (cfile, "encoding=\"%s\" ", encoding.c_str ());
1429 if ( str ) { (*str) += "encoding=\""; (*str) += encoding; (*str) += "\" "; }
1430 }
1431 if ( !standalone.empty() ) {
1432 if ( cfile ) fprintf (cfile, "standalone=\"%s\" ", standalone.c_str ());
1433 if ( str ) { (*str) += "standalone=\""; (*str) += standalone; (*str) += "\" "; }
1434 }
1435 if ( cfile ) fprintf( cfile, "?>" );
1436 if ( str ) (*str) += "?>";
1437}

◆ Standalone()

const char * TiXmlDeclaration::Standalone ( ) const
inline

Is this a standalone document?

1313{ return standalone.c_str (); }

◆ ToDeclaration() [1/2]

virtual TiXmlDeclaration * TiXmlDeclaration::ToDeclaration ( )
inlinevirtual

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

Reimplemented from TiXmlNode.

◆ ToDeclaration() [2/2]

virtual const TiXmlDeclaration * TiXmlDeclaration::ToDeclaration ( ) const
inlinevirtual

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

Reimplemented from TiXmlNode.

◆ Version()

const char * TiXmlDeclaration::Version ( ) const
inline

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

1309{ return version.c_str (); }

Member Data Documentation

◆ encoding

TIXML_STRING TiXmlDeclaration::encoding
private

◆ standalone

TIXML_STRING TiXmlDeclaration::standalone
private

◆ version

TIXML_STRING TiXmlDeclaration::version
private

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