xmlTiny::TiXmlBase Class Reference

TiXmlBase is a base class for every class in TinyXml. More...

#include <OBTtinyxml.h>

Inheritance diagram for xmlTiny::TiXmlBase:

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

Collaboration graph
[legend]

List of all members.

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
 All TinyXml classes can print themselves to a filestream or the string class (TiXmlString in non-STL mode, std::string in STL mode.
int Row () const
 Return the position, in the original source file, of this node or attribute.
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)
 The world does not agree on whether white space should be kept or not.
static bool IsWhiteSpaceCondensed ()
 Return the current white space setting.
static void EncodeString (const TIXML_STRING &str, TIXML_STRING *out)
 Expands entities in a string.

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 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

Classes

struct  Entity


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 201 of file tiny/tmp/OBTtinyxml.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 271 of file tiny/tmp/OBTtinyxml.h.

anonymous enum [private]

Enumerator:
NUM_ENTITY 
MAX_ENTITY_LENGTH 

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

00414         {
00415                 NUM_ENTITY = 5,
00416                 MAX_ENTITY_LENGTH = 6
00417 
00418         };


Constructor & Destructor Documentation

xmlTiny::TiXmlBase::TiXmlBase (  )  [inline]

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

00208 :       userData(0)             {}

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

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

00209 {}

xmlTiny::TiXmlBase::TiXmlBase ( const TiXmlBase  )  [private]


Member Function Documentation

virtual void xmlTiny::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 xmlTiny::TiXmlAttribute, xmlTiny::TiXmlElement, xmlTiny::TiXmlComment, xmlTiny::TiXmlText, xmlTiny::TiXmlDeclaration, xmlTiny::TiXmlUnknown, and xmlTiny::TiXmlDocument.

Referenced by xmlTiny::TiXmlElement::Print().

static void xmlTiny::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 228 of file tiny/tmp/OBTtinyxml.h.

References condenseWhiteSpace.

00228 { condenseWhiteSpace = condense; }

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

Return the current white space setting.

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

References condenseWhiteSpace.

Referenced by xmlTiny::TiXmlElement::ReadValue().

00231 { return condenseWhiteSpace; }

int xmlTiny::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 251 of file tiny/tmp/OBTtinyxml.h.

References location, and xmlTiny::TiXmlCursor::row.

00251 { return location.row + 1; }

int xmlTiny::TiXmlBase::Column (  )  const [inline]

See Row().

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

References xmlTiny::TiXmlCursor::col, and location.

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

Set a pointer to arbitrary user data.

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

References userData.

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

Get a pointer to arbitrary user data.

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

References userData.

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

Get a pointer to arbitrary user data.

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

References userData.

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

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

Referenced by xmlTiny::TiXmlDocument::Parse(), and xmlTiny::TiXmlElement::ReadValue().

void xmlTiny::TiXmlBase::EncodeString ( const TIXML_STRING &  str,
TIXML_STRING *  out 
) [static]

Expands entities in a string.

Note this should not contian the tag's '<', '>', etc, or they will be transformed into entities!

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

References entity.

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

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

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

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

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

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

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

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

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

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

00298         { 
00299                 return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' ); 
00300         }

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

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

References IsWhiteSpace().

00302         {
00303                 if ( c < 256 )
00304                         return IsWhiteSpace( (char) c );
00305                 return false;   // Again, only truly correct for English/Latin...but usually works.
00306         }

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

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

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

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

References IsAlpha(), and IsAlphaNum().

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

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

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

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

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

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

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

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

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

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

Referenced by GetChar().

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

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

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

References GetEntity(), xmlTiny::TIXML_ENCODING_UTF8, and utf8ByteTable.

Referenced by ReadText().

00335         {
00336                 assert( p );
00337                 if ( encoding == TIXML_ENCODING_UTF8 )
00338                 {
00339                         *length = utf8ByteTable[ *((const unsigned char*)p) ];
00340                         assert( *length >= 0 && *length < 5 );
00341                 }
00342                 else
00343                 {
00344                         *length = 1;
00345                 }
00346 
00347                 if ( *length == 1 )
00348                 {
00349                         if ( *p == '&' )
00350                                 return GetEntity( p, _value, length, encoding );
00351                         *_value = *p;
00352                         return p+1;
00353                 }
00354                 else if ( *length )
00355                 {
00356                         //strncpy( _value, p, *length );        // lots of compilers don't like this function (unsafe),
00357                                                                                                 // and the null terminator isn't needed
00358                         for( int i=0; p[i] && i<*length; ++i ) {
00359                                 _value[i] = p[i];
00360                         }
00361                         return p + (*length);
00362                 }
00363                 else
00364                 {
00365                         // Not valid text.
00366                         return 0;
00367                 }
00368         }

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

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

References ToLower().

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

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

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

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

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

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

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

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

Referenced by ReadName().

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

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

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

References xmlTiny::TIXML_ENCODING_UTF8.

Referenced by StringEqual().

00390         {
00391                 if ( encoding == TIXML_ENCODING_UTF8 )
00392                 {
00393                         if ( v < 128 ) return tolower( v );
00394                         return v;
00395                 }
00396                 else
00397                 {
00398                         return tolower( v );
00399                 }
00400         }

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

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

Referenced by GetEntity().

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

void xmlTiny::TiXmlBase::operator= ( const TiXmlBase base  )  [private]


Friends And Related Function Documentation

friend class TiXmlNode [friend]

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

friend class TiXmlElement [friend]

Reimplemented in xmlTiny::TiXmlNode, and xmlTiny::TiXmlText.

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

friend class TiXmlDocument [friend]

Reimplemented in xmlTiny::TiXmlNode.

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


Member Data Documentation

const int xmlTiny::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 260 of file tiny/tmp/OBTtinyxml.h.

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

const char * xmlTiny::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 378 of file tiny/tmp/OBTtinyxml.h.

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

TiXmlCursor xmlTiny::TiXmlBase::location [protected]

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

Referenced by Column(), xmlTiny::TiXmlDocument::LoadFile(), xmlTiny::TiXmlDeclaration::Parse(), xmlTiny::TiXmlText::Parse(), xmlTiny::TiXmlAttribute::Parse(), xmlTiny::TiXmlComment::Parse(), xmlTiny::TiXmlUnknown::Parse(), xmlTiny::TiXmlElement::Parse(), xmlTiny::TiXmlDocument::Parse(), and Row().

void* xmlTiny::TiXmlBase::userData [protected]

Field containing a generic user pointer.

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

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

TiXmlBase::Entity xmlTiny::TiXmlBase::entity [static, private]

Initial value:

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

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

Referenced by EncodeString(), and GetEntity().

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

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

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


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