68 #if defined( DEBUG_PARSER )    69 #   if defined( DEBUG ) && defined( _MSC_VER )    71 #       define TIXML_LOG OutputDebugString    73 #       define TIXML_LOG printf    77 namespace RTT { 
namespace marsh {
    82 TiXmlBase::Entity TiXmlBase::entity[ NUM_ENTITY ] =
    87     { 
""", 6, 
'\"' },
   108         1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  
   109         1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  
   110         1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  
   111         1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  
   112         1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  
   113         1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  
   114         1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  
   115         1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  
   116         1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  
   117         1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  
   118         1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  
   119         1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  
   120         1,  1,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  
   121         2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  
   122         3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  
   123         4,  4,  4,  4,  4,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1   
   129     const unsigned long BYTE_MASK = 0xBF;
   130     const unsigned long BYTE_MARK = 0x80;
   131     const unsigned long FIRST_BYTE_MARK[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
   135     else if ( input < 0x800 )
   137     else if ( input < 0x10000 )
   139     else if ( input < 0x200000 )
   142         { *length = 0; 
return; }    
   151             *output = (char)((input | BYTE_MARK) & BYTE_MASK);
   155             *output = (char)((input | BYTE_MARK) & BYTE_MASK);
   159             *output = (char)((input | BYTE_MARK) & BYTE_MASK);
   163             *output = (char)(input | FIRST_BYTE_MARK[*length]);
   178             return isalpha( anyByte );
   199             return isalnum( anyByte );
   246     int row = cursor.row;
   247     int col = cursor.col;
   248     const char* p = stamp;
   254         const unsigned char* pU = (
const unsigned char*)p;
   297                 col = (col / tabsize + 1) * tabsize;
   300             case TIXML_UTF_LEAD_0:
   303                     if ( *(p+1) && *(p+2) )
   307                         if ( *(pU+1)==TIXML_UTF_LEAD_1 && *(pU+2)==TIXML_UTF_LEAD_2 )
   309                         else if ( *(pU+1)==0xbfU && *(pU+2)==0xbeU )
   311                         else if ( *(pU+1)==0xbfU && *(pU+2)==0xbfU )
   328                     int step = TiXmlBase::utf8ByteTable[*((
unsigned char*)p)];
   346     assert( cursor.row >= -1 );
   347     assert( cursor.col >= -1 );
   363             const unsigned char* pU = (
const unsigned char*)p;
   366             if (    *(pU+0)==TIXML_UTF_LEAD_0
   367                  && *(pU+1)==TIXML_UTF_LEAD_1
   373             else if(*(pU+0)==TIXML_UTF_LEAD_0
   380             else if(*(pU+0)==TIXML_UTF_LEAD_0
   396         while ( *p && (
IsWhiteSpace( *p ) || *p == 
'\n' || *p ==
'\r') )
   404  bool TiXmlBase::StreamWhiteSpace( TIXML_ISTREAM * in, 
TIXML_STRING * tag )
   408         if ( !in->good() ) 
return false;
   415         *tag += (char) in->get();
   419  bool TiXmlBase::StreamTo( TIXML_ISTREAM * in, 
int character, 
TIXML_STRING * tag )
   425         if ( c == character )
   450          && ( 
IsAlpha( (
unsigned char) *p, encoding ) || *p == 
'_' ) )
   453                 &&  (       
IsAlphaNum( (
unsigned char ) *p, encoding )
   474     if ( *(p+1) && *(p+1) == 
'#' && *(p+2) )
   476         unsigned long ucs = 0;
   483             if ( !*(p+3) ) 
return 0;
   486             q = strchr( q, 
';' );
   488             if ( !q || !*q ) 
return 0;
   495                 if ( *q >= 
'0' && *q <= 
'9' )
   496                     ucs += mult * (*q - 
'0');
   497                 else if ( *q >= 
'a' && *q <= 
'f' )
   498                     ucs += mult * (*q - 
'a' + 10);
   499                 else if ( *q >= 
'A' && *q <= 
'F' )
   500                     ucs += mult * (*q - 
'A' + 10 );
   510             if ( !*(p+2) ) 
return 0;
   513             q = strchr( q, 
';' );
   515             if ( !q || !*q ) 
return 0;
   522                 if ( *q >= 
'0' && *q <= 
'9' )
   523                     ucs += mult * (*q - 
'0');
   540         return p + delta + 1;
   544     for( i=0; i<NUM_ENTITY; ++i )
   546         if ( strncmp( entity[i].str, p, entity[i].strLength ) == 0 )
   548             assert( strlen( entity[i].str ) == entity[i].strLength );
   549             *value = entity[i].chr;
   551             return ( p + entity[i].strLength );
   578         while ( *q && *tag && 
ToLower( *q, encoding ) == 
ToLower( *tag, encoding ) )
   589         while ( *q && *tag && *q == *tag )
   605                                     bool caseInsensitive,
   610          || !condenseWhiteSpace )   
   614                 && !
StringEqual( p, endTag, caseInsensitive, encoding )
   618             char cArr[4] = { 0, 0, 0, 0 };
   619             p = 
GetChar( p, cArr, &len, encoding );
   620             text->append( cArr, len );
   625         bool whitespace = 
false;
   630                 && !
StringEqual( p, endTag, caseInsensitive, encoding ) )
   632             if ( *p == 
'\r' || *p == 
'\n' )
   652                 char cArr[4] = { 0, 0, 0, 0 };
   653                 p = 
GetChar( p, cArr, &len, encoding );
   657                     text->append( cArr, len );
   661     return p + strlen( endTag );
   666 void TiXmlDocument::StreamIn( TIXML_ISTREAM * in, 
TIXML_STRING * tag )
   675     if ( !StreamTo( in, 
'<', tag ) )
   683         int tagIndex = (int) tag->length();
   684         while ( in->good() && in->peek() != 
'>' )
   704                 node->StreamIn( in, tag );
   762         const unsigned char* pU = (
const unsigned char*)p;
   763         if (    *(pU+0) && *(pU+0) == TIXML_UTF_LEAD_0
   764              && *(pU+1) && *(pU+1) == TIXML_UTF_LEAD_1
   765              && *(pU+2) && *(pU+2) == TIXML_UTF_LEAD_2 )
   768             useMicrosoftBOM = 
true;
   781         TiXmlNode* node = Identify( p, encoding );
   784             p = node->
Parse( p, &data, encoding );
   785             LinkEndChild( node );
   834     errorLocation.Clear();
   835     if ( pError && data )
   837         data->
Stamp( pError, encoding );
   838         errorLocation = data->
Cursor();
   848     if( !p || !*p || *p != 
'<' )
   868     const char* xmlHeader = { 
"<?xml" };
   869     const char* commentHeader = { 
"<!--" };
   870     const char* dtdHeader = { 
"<!" };
   871     const char* cdataHeader = { 
"<![CDATA[" };
   876             TIXML_LOG( 
"XML parsing Declaration\n" );
   880     else if ( 
StringEqual( p, commentHeader, 
false, encoding ) )
   883             TIXML_LOG( 
"XML parsing Comment\n" );
   887     else if ( 
StringEqual( p, cdataHeader, 
false, encoding ) )
   890             TIXML_LOG( 
"XML parsing CDATA\n" );
   896     else if ( 
StringEqual( p, dtdHeader, 
false, encoding ) )
   899             TIXML_LOG( 
"XML parsing Unknown(1)\n" );
   903     else if (    
IsAlpha( *(p+1), encoding )
   907             TIXML_LOG( 
"XML parsing Element\n" );
   914             TIXML_LOG( 
"XML parsing Unknown(2)\n" );
   922         returnNode->
parent = 
this;
   934 void TiXmlElement::StreamIn (TIXML_ISTREAM * in, 
TIXML_STRING * tag)
   954     if ( tag->length() < 3 ) 
return;
   959     if (    tag->at( tag->length() - 1 ) == 
'>'   960          && tag->at( tag->length() - 2 ) == 
'/' )
   965     else if ( tag->at( tag->length() - 1 ) == 
'>' )
   973             StreamWhiteSpace( in, tag );
   976             if ( in->good() && in->peek() != 
'<' )
   980                 text.StreamIn( in, tag );
   989             if ( !in->good() ) 
return;
   990             assert( in->peek() == 
'<' );
   991             int tagIndex = (int) tag->length();
   993             bool closingTag = 
false;
   994             bool firstCharFound = 
false;
  1016                 if ( !firstCharFound && c != 
'<' && !
IsWhiteSpace( c ) )
  1018                     firstCharFound = 
true;
  1047                 const char* tagloc = tag->c_str() + tagIndex;
  1051                 node->StreamIn( in, tag );
  1075         data->
Stamp( p, encoding );
  1088     const char* pErr = p;
  1090     p = 
ReadName( p, &value, encoding );
  1123         else if ( *p == 
'>' )
  1129             p = ReadValue( p, data, encoding );     
  1134             if ( 
StringEqual( p, endTag.c_str(), 
false, encoding ) )
  1136                 p += endTag.length();
  1156             const char* pErr = p;
  1157             p = attrib->
Parse( p, data, encoding );
  1175             attributeSet.Add( attrib );
  1187     const char* pWithWhiteSpace = p;
  1205                 p = textNode->
Parse( p, data, encoding );
  1211                 p = textNode->
Parse( pWithWhiteSpace, data, encoding );
  1214             if ( !textNode->
Blank() )
  1215                 LinkEndChild( textNode );
  1230                 TiXmlNode* node = Identify( p, encoding );
  1233                     p = node->
Parse( p, data, encoding );
  1234                     LinkEndChild( node );
  1242         pWithWhiteSpace = p;
  1254 #ifdef TIXML_USE_STL  1255 void TiXmlUnknown::StreamIn( TIXML_ISTREAM * in, 
TIXML_STRING * tag )
  1257     while ( in->good() )
  1286         data->
Stamp( p, encoding );
  1289     if ( !p || !*p || *p != 
'<' )
  1297     while ( p && *p && *p != 
'>' )
  1312 #ifdef TIXML_USE_STL  1313 void TiXmlComment::StreamIn( TIXML_ISTREAM * in, 
TIXML_STRING * tag )
  1315     while ( in->good() )
  1329              && tag->at( tag->length() - 2 ) == 
'-'  1330              && tag->at( tag->length() - 3 ) == 
'-' )
  1349         data->
Stamp( p, encoding );
  1352     const char* startTag = 
"<!--";
  1353     const char* endTag   = 
"-->";
  1355     if ( !
StringEqual( p, startTag, 
false, encoding ) )
  1360     p += strlen( startTag );
  1361     p = 
ReadText( p, &value, 
false, endTag, 
false, encoding );
  1369     if ( !p || !*p ) 
return 0;
  1373         tabsize = document->TabSize();
  1377         data->
Stamp( p, encoding );
  1381     const char* pErr = p;
  1382     p = 
ReadName( p, &name, encoding );
  1389     if ( !p || !*p || *p != 
'=' )
  1409         p = 
ReadText( p, &value, 
false, end, 
false, encoding );
  1411     else if ( *p == 
'"' )
  1415         p = 
ReadText( p, &value, 
false, end, 
false, encoding );
  1425                 && *p != 
'/' && *p != 
'>' )                     
  1434 #ifdef TIXML_USE_STL  1435 void TiXmlText::StreamIn( TIXML_ISTREAM * in, 
TIXML_STRING * tag )
  1451              && tag->at( tag->length() - 2 ) == 
']'  1452              && tag->at( tag->length() - 3 ) == 
']' )
  1460         while ( in->good() )
  1487         data->
Stamp( p, encoding );
  1491     const char* 
const startTag = 
"<![CDATA[";
  1492     const char* 
const endTag   = 
"]]>";
  1494     if ( cdata || 
StringEqual( p, startTag, 
false, encoding ) )
  1498         if ( !
StringEqual( p, startTag, 
false, encoding ) )
  1503         p += strlen( startTag );
  1515         p = 
ReadText( p, &dummy, 
false, endTag, 
false, encoding );
  1520         bool ignoreWhite = 
true;
  1522         const char* end = 
"<";
  1523         p = 
ReadText( p, &value, ignoreWhite, end, 
false, encoding );
  1530 #ifdef TIXML_USE_STL  1531 void TiXmlDeclaration::StreamIn( TIXML_ISTREAM * in, 
TIXML_STRING * tag )
  1533     while ( in->good() )
  1560     if ( !p || !*p || !
StringEqual( p, 
"<?xml", 
true, _encoding ) )
  1567         data->
Stamp( p, _encoding );
  1585         if ( 
StringEqual( p, 
"version", 
true, _encoding ) )
  1588             p = attrib.
Parse( p, data, _encoding );
  1589             version = attrib.
Value();
  1591         else if ( 
StringEqual( p, 
"encoding", 
true, _encoding ) )
  1594             p = attrib.
Parse( p, data, _encoding );
  1595             encoding = attrib.
Value();
  1597         else if ( 
StringEqual( p, 
"standalone", 
true, _encoding ) )
  1600             p = attrib.
Parse( p, data, _encoding );
  1601             standalone = attrib.
Value();
  1615     for ( 
unsigned i=0; i<value.length(); i++ )
 
const char * Encoding() const 
Encoding. Will return an empty string if none was found. 
 
void Stamp(const char *now, TiXmlEncoding encoding)
 
static int ToLower(int v, TiXmlEncoding encoding)
 
const char * Value() const 
Return the value of this attribute. 
 
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
 
TiXmlNode * Identify(const char *start, TiXmlEncoding encoding)
 
static bool IsWhiteSpace(char c)
 
static const int utf8ByteTable[256]
 
static const char * SkipWhiteSpace(const char *, TiXmlEncoding encoding)
 
const TIXML_STRING & NameTStr() const 
 
static const char * ReadText(const char *in, TIXML_STRING *text, bool ignoreWhiteSpace, const char *endTag, bool ignoreCase, TiXmlEncoding encoding)
 
An attribute is a name-value pair. 
 
Always the top level node. 
 
const char * ReadValue(const char *in, TiXmlParsingData *prevData, TiXmlEncoding encoding)
 
static int IsAlphaNum(unsigned char anyByte, TiXmlEncoding encoding)
 
static bool StringEqual(const char *p, const char *endTag, bool ignoreCase, TiXmlEncoding encoding)
 
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
 
virtual const char * Parse(const char *p, TiXmlParsingData *data=0, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
Parse the given null terminated block of xml data. 
 
void SetCDATA(bool _cdata)
Turns on or off a CDATA representation of text. 
 
The parent class for everything in the Document Object Model. 
 
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
 
static void ConvertUTF32ToUTF8(unsigned long input, char *output, int *length)
 
static const char * GetEntity(const char *in, char *value, int *length, TiXmlEncoding encoding)
 
virtual const TiXmlDeclaration * ToDeclaration() const 
Cast to a more defined type. Will return null if not of the requested type. 
 
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
 
friend class TiXmlElement
 
void SetError(int err, const char *errorLocation, TiXmlParsingData *prevData, TiXmlEncoding encoding)
 
void SetDocument(TiXmlDocument *doc)
 
const TiXmlEncoding TIXML_DEFAULT_ENCODING
 
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)=0
 
const unsigned char TIXML_UTF_LEAD_0
 
const unsigned char TIXML_UTF_LEAD_1
 
static int IsAlpha(unsigned char anyByte, TiXmlEncoding encoding)
 
const unsigned char TIXML_UTF_LEAD_2
 
const TiXmlCursor & Cursor()
 
void SetValue(const char *_value)
Set the value. 
 
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute. 
 
virtual const TiXmlElement * ToElement() const 
Cast to a more defined type. Will return null if not of the requested type. 
 
In correct XML the declaration is the first entry in the file. 
 
Any tag that tinyXml doesn't recognize is saved as an unknown. 
 
static const char * ReadName(const char *p, TIXML_STRING *name, TiXmlEncoding encoding)
 
static const char * GetChar(const char *p, char *_value, int *length, TiXmlEncoding encoding)
 
static const char * errorString[TIXML_ERROR_STRING_COUNT]
 
static bool IsWhiteSpaceCondensed()
Return the current white space setting. 
 
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)