TiXmlBase Class Reference

#include <tinyxml.h>

Inheritance diagram for TiXmlBase:
TiXmlAttribute TiXmlNode TiXmlComment TiXmlDeclaration TiXmlDocument TiXmlElement TiXmlText TiXmlUnknown

List of all members.

Classes

struct  Entity

Public Types

enum  {
  TIXML_NO_ERROR = 0, TIXML_ERROR, TIXML_ERROR_OPENING_FILE, TIXML_ERROR_OUT_OF_MEMORY,
  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
}

Public Member Functions

 TiXmlBase ()
virtual ~TiXmlBase ()
virtual void Print (FILE *cfile, int depth) const =0
int Row () const
int Column () const
 See Row().
void SetUserData (void *user)
 Set a pointer to arbitrary user data.
void * GetUserData ()
 Get a pointer to arbitrary user data.
const void * GetUserData () const
 Get a pointer to arbitrary user data.
virtual const char * Parse (const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)=0

Static Public Member Functions

static void SetCondenseWhiteSpace (bool condense)
static bool IsWhiteSpaceCondensed ()
 Return the current white space setting.

Static Public Attributes

static const int utf8ByteTable [256]

Static Protected Member Functions

static const char * SkipWhiteSpace (const char *, TiXmlEncoding encoding)
static bool IsWhiteSpace (char c)
static bool IsWhiteSpace (int c)
static bool StreamWhiteSpace (std::istream *in, TIXML_STRING *tag)
static bool StreamTo (std::istream *in, int character, TIXML_STRING *tag)
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 * GetEntity (const char *in, char *value, int *length, TiXmlEncoding encoding)
static const char * GetChar (const char *p, char *_value, int *length, TiXmlEncoding encoding)
static void PutString (const TIXML_STRING &str, TIXML_STRING *out)
static bool StringEqual (const char *p, const char *endTag, bool ignoreCase, TiXmlEncoding encoding)
static int IsAlpha (unsigned char anyByte, TiXmlEncoding encoding)
static int IsAlphaNum (unsigned char anyByte, TiXmlEncoding encoding)
static int ToLower (int v, TiXmlEncoding encoding)
static void ConvertUTF32ToUTF8 (unsigned long input, char *output, int *length)

Protected Attributes

TiXmlCursor location
void * userData
 Field containing a generic user pointer.

Static Protected Attributes

static const char * errorString [TIXML_ERROR_STRING_COUNT]

Private Types

enum  { NUM_ENTITY = 5, MAX_ENTITY_LENGTH = 6 }

Private Member Functions

 TiXmlBase (const TiXmlBase &)
void operator= (const TiXmlBase &base)

Static Private Attributes

static Entity entity [NUM_ENTITY]
static bool condenseWhiteSpace = true

Friends

class TiXmlNode
class TiXmlElement
class TiXmlDocument

Detailed Description

TiXmlBase is a base class for every class in TinyXml. It does little except to establish that TinyXml classes can be printed and provide some utility functions.

In XML, the document and elements can contain other elements and other types of nodes.

	A Document can contain:	Element	(container or leaf)
							Comment (leaf)
							Unknown (leaf)
							Declaration( leaf )

	An Element can contain:	Element (container or leaf)
							Text	(leaf)
							Attributes (not on tree)
							Comment (leaf)
							Unknown (leaf)

	A Decleration contains: Attributes (not on tree)
	

Definition at line 195 of file tinyxml.h.


Member Enumeration Documentation

anonymous enum
Enumerator:
TIXML_NO_ERROR 
TIXML_ERROR 
TIXML_ERROR_OPENING_FILE 
TIXML_ERROR_OUT_OF_MEMORY 
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 

Definition at line 260 of file tinyxml.h.

anonymous enum [private]
Enumerator:
NUM_ENTITY 
MAX_ENTITY_LENGTH 

Definition at line 406 of file tinyxml.h.

00407         {
00408                 NUM_ENTITY = 5,
00409                 MAX_ENTITY_LENGTH = 6
00410 
00411         };


Constructor & Destructor Documentation

TiXmlBase::TiXmlBase (  )  [inline]

Definition at line 202 of file tinyxml.h.

00202 :       userData(0)             {}

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

Definition at line 203 of file tinyxml.h.

00203 {}

TiXmlBase::TiXmlBase ( const TiXmlBase  )  [private]

Member Function Documentation

int TiXmlBase::Column (  )  const [inline]

See Row().

Definition at line 246 of file tinyxml.h.

References TiXmlCursor::col, and location.

void TiXmlBase::ConvertUTF32ToUTF8 ( unsigned long  input,
char *  output,
int *  length 
) [static, protected]

Definition at line 88 of file tinyxmlparser.cpp.

Referenced by GetEntity().

00089 {
00090         const unsigned long BYTE_MASK = 0xBF;
00091         const unsigned long BYTE_MARK = 0x80;
00092         const unsigned long FIRST_BYTE_MARK[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
00093 
00094         if (input < 0x80) 
00095                 *length = 1;
00096         else if ( input < 0x800 )
00097                 *length = 2;
00098         else if ( input < 0x10000 )
00099                 *length = 3;
00100         else if ( input < 0x200000 )
00101                 *length = 4;
00102         else
00103                 { *length = 0; return; }        // This code won't covert this correctly anyway.
00104 
00105         output += *length;
00106 
00107         // Scary scary fall throughs.
00108         switch (*length) 
00109         {
00110                 case 4:
00111                         --output; 
00112                         *output = (char)((input | BYTE_MARK) & BYTE_MASK); 
00113                         input >>= 6;
00114                 case 3:
00115                         --output; 
00116                         *output = (char)((input | BYTE_MARK) & BYTE_MASK); 
00117                         input >>= 6;
00118                 case 2:
00119                         --output; 
00120                         *output = (char)((input | BYTE_MARK) & BYTE_MASK); 
00121                         input >>= 6;
00122                 case 1:
00123                         --output; 
00124                         *output = (char)(input | FIRST_BYTE_MARK[*length]);
00125         }
00126 }

static const char* TiXmlBase::GetChar ( const char *  p,
char *  _value,
int *  length,
TiXmlEncoding  encoding 
) [inline, static, protected]

Definition at line 323 of file tinyxml.h.

References GetEntity(), TIXML_ENCODING_UTF8, and utf8ByteTable.

Referenced by ReadText().

00324         {
00325                 assert( p );
00326                 if ( encoding == TIXML_ENCODING_UTF8 )
00327                 {
00328                         *length = utf8ByteTable[ *((const unsigned char*)p) ];
00329                         assert( *length >= 0 && *length < 5 );
00330                 }
00331                 else
00332                 {
00333                         *length = 1;
00334                 }
00335 
00336                 if ( *length == 1 )
00337                 {
00338                         if ( *p == '&' )
00339                                 return GetEntity( p, _value, length, encoding );
00340                         *_value = *p;
00341                         return p+1;
00342                 }
00343                 else if ( *length )
00344                 {
00345                         //strncpy( _value, p, *length );        // lots of compilers don't like this function (unsafe),
00346                                                                                                 // and the null terminator isn't needed
00347                         for( int i=0; p[i] && i<*length; ++i ) {
00348                                 _value[i] = p[i];
00349                         }
00350                         return p + (*length);
00351                 }
00352                 else
00353                 {
00354                         // Not valid text.
00355                         return 0;
00356                 }
00357         }

const char * TiXmlBase::GetEntity ( const char *  in,
char *  value,
int *  length,
TiXmlEncoding  encoding 
) [static, protected]

Definition at line 438 of file tinyxmlparser.cpp.

References TiXmlBase::Entity::chr, ConvertUTF32ToUTF8(), entity, NUM_ENTITY, TIXML_ENCODING_UTF8, and TIXML_STRING.

Referenced by GetChar().

00439 {
00440         // Presume an entity, and pull it out.
00441     TIXML_STRING ent;
00442         int i;
00443         *length = 0;
00444 
00445         if ( *(p+1) && *(p+1) == '#' && *(p+2) )
00446         {
00447                 unsigned long ucs = 0;
00448                 ptrdiff_t delta = 0;
00449                 unsigned mult = 1;
00450 
00451                 if ( *(p+2) == 'x' )
00452                 {
00453                         // Hexadecimal.
00454                         if ( !*(p+3) ) return 0;
00455 
00456                         const char* q = p+3;
00457                         q = strchr( q, ';' );
00458 
00459                         if ( !q || !*q ) return 0;
00460 
00461                         delta = q-p;
00462                         --q;
00463 
00464                         while ( *q != 'x' )
00465                         {
00466                                 if ( *q >= '0' && *q <= '9' )
00467                                         ucs += mult * (*q - '0');
00468                                 else if ( *q >= 'a' && *q <= 'f' )
00469                                         ucs += mult * (*q - 'a' + 10);
00470                                 else if ( *q >= 'A' && *q <= 'F' )
00471                                         ucs += mult * (*q - 'A' + 10 );
00472                                 else 
00473                                         return 0;
00474                                 mult *= 16;
00475                                 --q;
00476                         }
00477                 }
00478                 else
00479                 {
00480                         // Decimal.
00481                         if ( !*(p+2) ) return 0;
00482 
00483                         const char* q = p+2;
00484                         q = strchr( q, ';' );
00485 
00486                         if ( !q || !*q ) return 0;
00487 
00488                         delta = q-p;
00489                         --q;
00490 
00491                         while ( *q != '#' )
00492                         {
00493                                 if ( *q >= '0' && *q <= '9' )
00494                                         ucs += mult * (*q - '0');
00495                                 else 
00496                                         return 0;
00497                                 mult *= 10;
00498                                 --q;
00499                         }
00500                 }
00501                 if ( encoding == TIXML_ENCODING_UTF8 )
00502                 {
00503                         // convert the UCS to UTF-8
00504                         ConvertUTF32ToUTF8( ucs, value, length );
00505                 }
00506                 else
00507                 {
00508                         *value = (char)ucs;
00509                         *length = 1;
00510                 }
00511                 return p + delta + 1;
00512         }
00513 
00514         // Now try to match it.
00515         for( i=0; i<NUM_ENTITY; ++i )
00516         {
00517                 if ( strncmp( entity[i].str, p, entity[i].strLength ) == 0 )
00518                 {
00519                         assert( strlen( entity[i].str ) == entity[i].strLength );
00520                         *value = entity[i].chr;
00521                         *length = 1;
00522                         return ( p + entity[i].strLength );
00523                 }
00524         }
00525 
00526         // So it wasn't an entity, its unrecognized, or something like that.
00527         *value = *p;    // Don't put back the last one, since we return it!
00528         //*length = 1;  // Leave unrecognized entities - this doesn't really work.
00529                                         // Just writes strange XML.
00530         return p+1;
00531 }

const void* TiXmlBase::GetUserData (  )  const [inline]

Get a pointer to arbitrary user data.

Definition at line 250 of file tinyxml.h.

References userData.

void* TiXmlBase::GetUserData (  )  [inline]

Get a pointer to arbitrary user data.

Definition at line 249 of file tinyxml.h.

References userData.

int TiXmlBase::IsAlpha ( unsigned char  anyByte,
TiXmlEncoding  encoding 
) [static, protected]

Definition at line 129 of file tinyxmlparser.cpp.

Referenced by TiXmlNode::Identify(), and ReadName().

00130 {
00131         // This will only work for low-ascii, everything else is assumed to be a valid
00132         // letter. I'm not sure this is the best approach, but it is quite tricky trying
00133         // to figure out alhabetical vs. not across encoding. So take a very 
00134         // conservative approach.
00135 
00136 //      if ( encoding == TIXML_ENCODING_UTF8 )
00137 //      {
00138                 if ( anyByte < 127 )
00139                         return isalpha( anyByte );
00140                 else
00141                         return 1;       // What else to do? The unicode set is huge...get the english ones right.
00142 //      }
00143 //      else
00144 //      {
00145 //              return isalpha( anyByte );
00146 //      }
00147 }

int TiXmlBase::IsAlphaNum ( unsigned char  anyByte,
TiXmlEncoding  encoding 
) [static, protected]

Definition at line 150 of file tinyxmlparser.cpp.

Referenced by ReadName().

00151 {
00152         // This will only work for low-ascii, everything else is assumed to be a valid
00153         // letter. I'm not sure this is the best approach, but it is quite tricky trying
00154         // to figure out alhabetical vs. not across encoding. So take a very 
00155         // conservative approach.
00156 
00157 //      if ( encoding == TIXML_ENCODING_UTF8 )
00158 //      {
00159                 if ( anyByte < 127 )
00160                         return isalnum( anyByte );
00161                 else
00162                         return 1;       // What else to do? The unicode set is huge...get the english ones right.
00163 //      }
00164 //      else
00165 //      {
00166 //              return isalnum( anyByte );
00167 //      }
00168 }

static bool TiXmlBase::IsWhiteSpace ( int  c  )  [inline, static, protected]

Definition at line 290 of file tinyxml.h.

References IsWhiteSpace().

00291         {
00292                 if ( c < 256 )
00293                         return IsWhiteSpace( (char) c );
00294                 return false;   // Again, only truly correct for English/Latin...but usually works.
00295         }

static bool TiXmlBase::IsWhiteSpace ( char  c  )  [inline, static, protected]

Definition at line 286 of file tinyxml.h.

Referenced by TiXmlText::Blank(), IsWhiteSpace(), TiXmlAttribute::Parse(), TiXmlDeclaration::Parse(), ReadText(), SkipWhiteSpace(), TiXmlElement::StreamIn(), and StreamWhiteSpace().

00287         { 
00288                 return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' ); 
00289         }

static bool TiXmlBase::IsWhiteSpaceCondensed (  )  [inline, static]

Return the current white space setting.

Definition at line 225 of file tinyxml.h.

References condenseWhiteSpace.

Referenced by TiXmlElement::ReadValue().

00225 { return condenseWhiteSpace; }

void TiXmlBase::operator= ( const TiXmlBase base  )  [private]
virtual const char* TiXmlBase::Parse ( const char *  p,
TiXmlParsingData data,
TiXmlEncoding  encoding 
) [pure virtual]
virtual void TiXmlBase::Print ( FILE *  cfile,
int  depth 
) const [pure 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.)

Implemented in TiXmlAttribute, TiXmlElement, TiXmlComment, TiXmlText, TiXmlDeclaration, TiXmlUnknown, and TiXmlDocument.

Referenced by TiXmlElement::Print().

void TiXmlBase::PutString ( const TIXML_STRING &  str,
TIXML_STRING *  out 
) [static, protected]

Definition at line 37 of file tinyxml.cpp.

References entity.

Referenced by TiXmlText::Print(), and TiXmlAttribute::Print().

00038 {
00039         int i=0;
00040 
00041         while( i<(int)str.length() )
00042         {
00043                 unsigned char c = (unsigned char) str[i];
00044 
00045                 if (    c == '&' 
00046                      && i < ( (int)str.length() - 2 )
00047                          && str[i+1] == '#'
00048                          && str[i+2] == 'x' )
00049                 {
00050                         // Hexadecimal character reference.
00051                         // Pass through unchanged.
00052                         // &#xA9;       -- copyright symbol, for example.
00053                         //
00054                         // The -1 is a bug fix from Rob Laveaux. It keeps
00055                         // an overflow from happening if there is no ';'.
00056                         // There are actually 2 ways to exit this loop -
00057                         // while fails (error case) and break (semicolon found).
00058                         // However, there is no mechanism (currently) for
00059                         // this function to return an error.
00060                         while ( i<(int)str.length()-1 )
00061                         {
00062                                 outString->append( str.c_str() + i, 1 );
00063                                 ++i;
00064                                 if ( str[i] == ';' )
00065                                         break;
00066                         }
00067                 }
00068                 else if ( c == '&' )
00069                 {
00070                         outString->append( entity[0].str, entity[0].strLength );
00071                         ++i;
00072                 }
00073                 else if ( c == '<' )
00074                 {
00075                         outString->append( entity[1].str, entity[1].strLength );
00076                         ++i;
00077                 }
00078                 else if ( c == '>' )
00079                 {
00080                         outString->append( entity[2].str, entity[2].strLength );
00081                         ++i;
00082                 }
00083                 else if ( c == '\"' )
00084                 {
00085                         outString->append( entity[3].str, entity[3].strLength );
00086                         ++i;
00087                 }
00088                 else if ( c == '\'' )
00089                 {
00090                         outString->append( entity[4].str, entity[4].strLength );
00091                         ++i;
00092                 }
00093                 else if ( c < 32 )
00094                 {
00095                         // Easy pass at non-alpha/numeric/symbol
00096                         // Below 32 is symbolic.
00097                         char buf[ 32 ];
00098                         
00099                         #if defined(TIXML_SNPRINTF)             
00100                                 TIXML_SNPRINTF( buf, sizeof(buf), "&#x%02X;", (unsigned) ( c & 0xff ) );
00101                         #else
00102                                 sprintf( buf, "&#x%02X;", (unsigned) ( c & 0xff ) );
00103                         #endif          
00104 
00105                         //*ME:  warning C4267: convert 'size_t' to 'int'
00106                         //*ME:  Int-Cast to make compiler happy ...
00107                         outString->append( buf, (int)strlen( buf ) );
00108                         ++i;
00109                 }
00110                 else
00111                 {
00112                         //char realc = (char) c;
00113                         //outString->append( &realc, 1 );
00114                         *outString += (char) c; // somewhat more efficient function call.
00115                         ++i;
00116                 }
00117         }
00118 }

const char * TiXmlBase::ReadName ( const char *  p,
TIXML_STRING *  name,
TiXmlEncoding  encoding 
) [static, protected]

Definition at line 401 of file tinyxmlparser.cpp.

References IsAlpha(), and IsAlphaNum().

Referenced by TiXmlAttribute::Parse(), and TiXmlElement::Parse().

00402 {
00403         // Oddly, not supported on some comilers,
00404         //name->clear();
00405         // So use this:
00406         *name = "";
00407         assert( p );
00408 
00409         // Names start with letters or underscores.
00410         // Of course, in unicode, tinyxml has no idea what a letter *is*. The
00411         // algorithm is generous.
00412         //
00413         // After that, they can be letters, underscores, numbers,
00414         // hyphens, or colons. (Colons are valid ony for namespaces,
00415         // but tinyxml can't tell namespaces from names.)
00416         if (    p && *p 
00417                  && ( IsAlpha( (unsigned char) *p, encoding ) || *p == '_' ) )
00418         {
00419                 const char* start = p;
00420                 while(          p && *p
00421                                 &&      (               IsAlphaNum( (unsigned char ) *p, encoding ) 
00422                                                  || *p == '_'
00423                                                  || *p == '-'
00424                                                  || *p == '.'
00425                                                  || *p == ':' ) )
00426                 {
00427                         //(*name) += *p; // expensive
00428                         ++p;
00429                 }
00430                 if ( p-start > 0 ) {
00431                         name->assign( start, p-start );
00432                 }
00433                 return p;
00434         }
00435         return 0;
00436 }

const char * TiXmlBase::ReadText ( const char *  in,
TIXML_STRING *  text,
bool  ignoreWhiteSpace,
const char *  endTag,
bool  ignoreCase,
TiXmlEncoding  encoding 
) [static, protected]

Definition at line 574 of file tinyxmlparser.cpp.

References condenseWhiteSpace, GetChar(), IsWhiteSpace(), len, SkipWhiteSpace(), and StringEqual().

Referenced by TiXmlAttribute::Parse(), TiXmlComment::Parse(), and TiXmlText::Parse().

00580 {
00581     *text = "";
00582         if (    !trimWhiteSpace                 // certain tags always keep whitespace
00583                  || !condenseWhiteSpace )       // if true, whitespace is always kept
00584         {
00585                 // Keep all the white space.
00586                 while (    p && *p
00587                                 && !StringEqual( p, endTag, caseInsensitive, encoding )
00588                           )
00589                 {
00590                         int len;
00591                         char cArr[4] = { 0, 0, 0, 0 };
00592                         p = GetChar( p, cArr, &len, encoding );
00593                         text->append( cArr, len );
00594                 }
00595         }
00596         else
00597         {
00598                 bool whitespace = false;
00599 
00600                 // Remove leading white space:
00601                 p = SkipWhiteSpace( p, encoding );
00602                 while (    p && *p
00603                                 && !StringEqual( p, endTag, caseInsensitive, encoding ) )
00604                 {
00605                         if ( *p == '\r' || *p == '\n' )
00606                         {
00607                                 whitespace = true;
00608                                 ++p;
00609                         }
00610                         else if ( IsWhiteSpace( *p ) )
00611                         {
00612                                 whitespace = true;
00613                                 ++p;
00614                         }
00615                         else
00616                         {
00617                                 // If we've found whitespace, add it before the
00618                                 // new character. Any whitespace just becomes a space.
00619                                 if ( whitespace )
00620                                 {
00621                                         (*text) += ' ';
00622                                         whitespace = false;
00623                                 }
00624                                 int len;
00625                                 char cArr[4] = { 0, 0, 0, 0 };
00626                                 p = GetChar( p, cArr, &len, encoding );
00627                                 if ( len == 1 )
00628                                         (*text) += cArr[0];     // more efficient
00629                                 else
00630                                         text->append( cArr, len );
00631                         }
00632                 }
00633         }
00634         if ( p ) 
00635                 p += strlen( endTag );
00636         return p;
00637 }

int TiXmlBase::Row (  )  const [inline]

Return the position, in the original source file, of this node or attribute. The row and column are 1-based. (That is the first row and first column is 1,1). If the returns values are 0 or less, then the parser does not have a row and column value.

Generally, the row and column value will be set when the TiXmlDocument::Load(), TiXmlDocument::LoadFile(), or any TiXmlNode::Parse() is called. It will NOT be set when the DOM was created from operator>>.

The values reflect the initial load. Once the DOM is modified programmatically (by adding or changing nodes and attributes) the new values will NOT update to reflect changes in the document.

There is a minor performance cost to computing the row and column. Computation can be disabled if TiXmlDocument::SetTabSize() is called with 0 as the value.

See also:
TiXmlDocument::SetTabSize()

Definition at line 245 of file tinyxml.h.

References location, and TiXmlCursor::row.

00245 { return location.row + 1; }

static void TiXmlBase::SetCondenseWhiteSpace ( bool  condense  )  [inline, static]

The world does not agree on whether white space should be kept or not. In order to make everyone happy, these global, static functions are provided to set whether or not TinyXml will condense all white space into a single space or not. The default is to condense. Note changing this value is not thread safe.

Definition at line 222 of file tinyxml.h.

References condenseWhiteSpace.

00222 { condenseWhiteSpace = condense; }

void TiXmlBase::SetUserData ( void *  user  )  [inline]

Set a pointer to arbitrary user data.

Definition at line 248 of file tinyxml.h.

References userData.

const char * TiXmlBase::SkipWhiteSpace ( const char *  p,
TiXmlEncoding  encoding 
) [static, protected]

Definition at line 314 of file tinyxmlparser.cpp.

References IsWhiteSpace(), TIXML_ENCODING_UTF8, TIXML_UTF_LEAD_0, TIXML_UTF_LEAD_1, and TIXML_UTF_LEAD_2.

Referenced by TiXmlNode::Identify(), TiXmlAttribute::Parse(), TiXmlComment::Parse(), TiXmlElement::Parse(), TiXmlDocument::Parse(), TiXmlDeclaration::Parse(), TiXmlUnknown::Parse(), ReadText(), and TiXmlElement::ReadValue().

00315 {
00316         if ( !p || !*p )
00317         {
00318                 return 0;
00319         }
00320         if ( encoding == TIXML_ENCODING_UTF8 )
00321         {
00322                 while ( *p )
00323                 {
00324                         const unsigned char* pU = (const unsigned char*)p;
00325                         
00326                         // Skip the stupid Microsoft UTF-8 Byte order marks
00327                         if (    *(pU+0)==TIXML_UTF_LEAD_0
00328                                  && *(pU+1)==TIXML_UTF_LEAD_1 
00329                                  && *(pU+2)==TIXML_UTF_LEAD_2 )
00330                         {
00331                                 p += 3;
00332                                 continue;
00333                         }
00334                         else if(*(pU+0)==TIXML_UTF_LEAD_0
00335                                  && *(pU+1)==0xbfU
00336                                  && *(pU+2)==0xbeU )
00337                         {
00338                                 p += 3;
00339                                 continue;
00340                         }
00341                         else if(*(pU+0)==TIXML_UTF_LEAD_0
00342                                  && *(pU+1)==0xbfU
00343                                  && *(pU+2)==0xbfU )
00344                         {
00345                                 p += 3;
00346                                 continue;
00347                         }
00348 
00349                         if ( IsWhiteSpace( *p ) || *p == '\n' || *p =='\r' )            // Still using old rules for white space.
00350                                 ++p;
00351                         else
00352                                 break;
00353                 }
00354         }
00355         else
00356         {
00357                 while ( *p && IsWhiteSpace( *p ) || *p == '\n' || *p =='\r' )
00358                         ++p;
00359         }
00360 
00361         return p;
00362 }

bool TiXmlBase::StreamTo ( std::istream *  in,
int  character,
TIXML_STRING *  tag 
) [static, protected]

Definition at line 380 of file tinyxmlparser.cpp.

Referenced by TiXmlDocument::StreamIn().

00381 {
00382         //assert( character > 0 && character < 128 );   // else it won't work in utf-8
00383         while ( in->good() )
00384         {
00385                 int c = in->peek();
00386                 if ( c == character )
00387                         return true;
00388                 if ( c <= 0 )           // Silent failure: can't get document at this scope
00389                         return false;
00390 
00391                 in->get();
00392                 *tag += (char) c;
00393         }
00394         return false;
00395 }

bool TiXmlBase::StreamWhiteSpace ( std::istream *  in,
TIXML_STRING *  tag 
) [static, protected]

Definition at line 365 of file tinyxmlparser.cpp.

References IsWhiteSpace().

Referenced by TiXmlElement::StreamIn().

00366 {
00367         for( ;; )
00368         {
00369                 if ( !in->good() ) return false;
00370 
00371                 int c = in->peek();
00372                 // At this scope, we can't get to a document. So fail silently.
00373                 if ( !IsWhiteSpace( c ) || c <= 0 )
00374                         return true;
00375 
00376                 *tag += (char) in->get();
00377         }
00378 }

bool TiXmlBase::StringEqual ( const char *  p,
const char *  endTag,
bool  ignoreCase,
TiXmlEncoding  encoding 
) [static, protected]

Definition at line 534 of file tinyxmlparser.cpp.

References ToLower().

Referenced by TiXmlNode::Identify(), TiXmlComment::Parse(), TiXmlElement::Parse(), TiXmlDocument::Parse(), TiXmlDeclaration::Parse(), TiXmlText::Parse(), ReadText(), and TiXmlElement::ReadValue().

00538 {
00539         assert( p );
00540         assert( tag );
00541         if ( !p || !*p )
00542         {
00543                 assert( 0 );
00544                 return false;
00545         }
00546 
00547         const char* q = p;
00548 
00549         if ( ignoreCase )
00550         {
00551                 while ( *q && *tag && ToLower( *q, encoding ) == ToLower( *tag, encoding ) )
00552                 {
00553                         ++q;
00554                         ++tag;
00555                 }
00556 
00557                 if ( *tag == 0 )
00558                         return true;
00559         }
00560         else
00561         {
00562                 while ( *q && *tag && *q == *tag )
00563                 {
00564                         ++q;
00565                         ++tag;
00566                 }
00567 
00568                 if ( *tag == 0 )                // Have we found the end of the tag, and everything equal?
00569                         return true;
00570         }
00571         return false;
00572 }

static int TiXmlBase::ToLower ( int  v,
TiXmlEncoding  encoding 
) [inline, static, protected]

Definition at line 382 of file tinyxml.h.

References TIXML_ENCODING_UTF8.

Referenced by StringEqual().

00383         {
00384                 if ( encoding == TIXML_ENCODING_UTF8 )
00385                 {
00386                         if ( v < 128 ) return tolower( v );
00387                         return v;
00388                 }
00389                 else
00390                 {
00391                         return tolower( v );
00392                 }
00393         }


Friends And Related Function Documentation

friend class TiXmlDocument [friend]

Reimplemented in TiXmlNode.

Definition at line 199 of file tinyxml.h.

friend class TiXmlElement [friend]

Reimplemented in TiXmlNode, and TiXmlText.

Definition at line 198 of file tinyxml.h.

friend class TiXmlNode [friend]

Definition at line 197 of file tinyxml.h.


Member Data Documentation

bool TiXmlBase::condenseWhiteSpace = true [static, private]

Definition at line 413 of file tinyxml.h.

Referenced by IsWhiteSpaceCondensed(), ReadText(), and SetCondenseWhiteSpace().

Initial value:
 
{
        { "&amp;",  5, '&' },
        { "&lt;",   4, '<' },
        { "&gt;",   4, '>' },
        { "&quot;", 6, '\"' },
        { "&apos;", 6, '\'' }
}

Definition at line 412 of file tinyxml.h.

Referenced by GetEntity(), and PutString().

const char * TiXmlBase::errorString [static, protected]
Initial value:
{
        "No error",
        "Error",
        "Failed to open file",
        "Memory allocation failed.",
        "Error parsing Element.",
        "Failed to read Element name",
        "Error reading Element value.",
        "Error reading Attributes.",
        "Error: empty tag.",
        "Error reading end tag.",
        "Error parsing Unknown.",
        "Error parsing Comment.",
        "Error parsing Declaration.",
        "Error document empty.",
        "Error null (0) or unexpected EOF found in input stream.",
        "Error parsing CDATA.",
        "Error when TiXmlDocument added to document, because TiXmlDocument can only be at the root.",
}

Definition at line 371 of file tinyxml.h.

Referenced by TiXmlDocument::SetError().

void* TiXmlBase::userData [protected]

Field containing a generic user pointer.

Definition at line 376 of file tinyxml.h.

Referenced by TiXmlNode::CopyTo(), GetUserData(), and SetUserData().

const int TiXmlBase::utf8ByteTable [static]
Initial value:
 
{
        
                1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      
                1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      
                1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      
                1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      
                1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      
                1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      
                1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      
                1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      
                1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      
                1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      
                1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      
                1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      
                1,      1,      2,      2,      2,      2,      2,      2,      2,      2,      2,      2,      2,      2,      2,      2,      
                2,      2,      2,      2,      2,      2,      2,      2,      2,      2,      2,      2,      2,      2,      2,      2,      
                3,      3,      3,      3,      3,      3,      3,      3,      3,      3,      3,      3,      3,      3,      3,      3,      
                4,      4,      4,      4,      4,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1,      1       
}

Definition at line 254 of file tinyxml.h.

Referenced by GetChar(), and TiXmlParsingData::Stamp().


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

Generated on 3 Dec 2018 for loon by  doxygen 1.6.1