OBT::TiXmlParsingData Class Reference

Collaboration diagram for OBT::TiXmlParsingData:

Collaboration graph
[legend]

List of all members.

Public Member Functions

void Stamp (const char *now, TiXmlEncoding encoding)
const TiXmlCursorCursor ()
void Stamp (const char *now, TiXmlEncoding encoding)
const TiXmlCursorCursor ()

Private Member Functions

 TiXmlParsingData (const char *start, int _tabsize, int row, int col)
 TiXmlParsingData (const char *start, int _tabsize, int row, int col)

Private Attributes

TiXmlCursor cursor
const char * stamp
int tabsize
const char * stamp

Friends

class TiXmlDocument


Detailed Description

Definition at line 173 of file OBTtinyxmlparser.cpp.


Constructor & Destructor Documentation

OBT::TiXmlParsingData::TiXmlParsingData ( const char *  start,
int  _tabsize,
int  row,
int  col 
) [inline, private]

Definition at line 183 of file OBTtinyxmlparser.cpp.

00184         {
00185                 assert( start );
00186                 stamp = start;
00187                 tabsize = _tabsize;
00188                 cursor.row = row;
00189                 cursor.col = col;
00190         }

OBT::TiXmlParsingData::TiXmlParsingData ( const char *  start,
int  _tabsize,
int  row,
int  col 
) [inline, private]

Definition at line 183 of file tiny/OBTtinyxmlparser.cpp.

References OBT::TiXmlCursor::col, cursor, OBT::TiXmlCursor::row, stamp, and tabsize.

00184         {
00185                 assert( start );
00186                 stamp = start;
00187                 tabsize = _tabsize;
00188                 cursor.row = row;
00189                 cursor.col = col;
00190         }


Member Function Documentation

void OBT::TiXmlParsingData::Stamp ( const char *  now,
TiXmlEncoding  encoding 
)

Definition at line 198 of file OBTtinyxmlparser.cpp.

References OBT::TiXmlCursor::col, cursor, OBT::TiXmlCursor::row, stamp, tabsize, OBT::TIXML_ENCODING_UTF8, OBT::TIXML_UTF_LEAD_0, OBT::TIXML_UTF_LEAD_1, OBT::TIXML_UTF_LEAD_2, and OBT::TiXmlBase::utf8ByteTable.

Referenced by OBT::TiXmlDeclaration::Parse(), OBT::TiXmlText::Parse(), OBT::TiXmlAttribute::Parse(), OBT::TiXmlComment::Parse(), OBT::TiXmlUnknown::Parse(), OBT::TiXmlElement::Parse(), and OBT::TiXmlDocument::SetError().

00199 {
00200         assert( now );
00201 
00202         // Do nothing if the tabsize is 0.
00203         if ( tabsize < 1 )
00204         {
00205                 return;
00206         }
00207 
00208         // Get the current row, column.
00209         int row = cursor.row;
00210         int col = cursor.col;
00211         const char* p = stamp;
00212         assert( p );
00213 
00214         while ( p < now )
00215         {
00216                 // Treat p as unsigned, so we have a happy compiler.
00217                 const unsigned char* pU = (const unsigned char*)p;
00218 
00219                 // Code contributed by Fletcher Dunn: (modified by lee)
00220                 switch (*pU) {
00221                         case 0:
00222                                 // We *should* never get here, but in case we do, don't
00223                                 // advance past the terminating null character, ever
00224                                 return;
00225 
00226                         case '\r':
00227                                 // bump down to the next line
00228                                 ++row;
00229                                 col = 0;                                
00230                                 // Eat the character
00231                                 ++p;
00232 
00233                                 // Check for \r\n sequence, and treat this as a single character
00234                                 if (*p == '\n') {
00235                                         ++p;
00236                                 }
00237                                 break;
00238 
00239                         case '\n':
00240                                 // bump down to the next line
00241                                 ++row;
00242                                 col = 0;
00243 
00244                                 // Eat the character
00245                                 ++p;
00246 
00247                                 // Check for \n\r sequence, and treat this as a single
00248                                 // character.  (Yes, this bizarre thing does occur still
00249                                 // on some arcane platforms...)
00250                                 if (*p == '\r') {
00251                                         ++p;
00252                                 }
00253                                 break;
00254 
00255                         case '\t':
00256                                 // Eat the character
00257                                 ++p;
00258 
00259                                 // Skip to next tab stop
00260                                 col = (col / tabsize + 1) * tabsize;
00261                                 break;
00262 
00263                         case TIXML_UTF_LEAD_0:
00264                                 if ( encoding == TIXML_ENCODING_UTF8 )
00265                                 {
00266                                         if ( *(p+1) && *(p+2) )
00267                                         {
00268                                                 // In these cases, don't advance the column. These are
00269                                                 // 0-width spaces.
00270                                                 if ( *(pU+1)==TIXML_UTF_LEAD_1 && *(pU+2)==TIXML_UTF_LEAD_2 )
00271                                                         p += 3; 
00272                                                 else if ( *(pU+1)==0xbfU && *(pU+2)==0xbeU )
00273                                                         p += 3; 
00274                                                 else if ( *(pU+1)==0xbfU && *(pU+2)==0xbfU )
00275                                                         p += 3; 
00276                                                 else
00277                                                         { p +=3; ++col; }       // A normal character.
00278                                         }
00279                                 }
00280                                 else
00281                                 {
00282                                         ++p;
00283                                         ++col;
00284                                 }
00285                                 break;
00286 
00287                         default:
00288                                 if ( encoding == TIXML_ENCODING_UTF8 )
00289                                 {
00290                                         // Eat the 1 to 4 byte utf8 character.
00291                                         int step = TiXmlBase::utf8ByteTable[*((const unsigned char*)p)];
00292                                         if ( step == 0 )
00293                                                 step = 1;               // Error case from bad encoding, but handle gracefully.
00294                                         p += step;
00295 
00296                                         // Just advance one column, of course.
00297                                         ++col;
00298                                 }
00299                                 else
00300                                 {
00301                                         ++p;
00302                                         ++col;
00303                                 }
00304                                 break;
00305                 }
00306         }
00307         cursor.row = row;
00308         cursor.col = col;
00309         assert( cursor.row >= -1 );
00310         assert( cursor.col >= -1 );
00311         stamp = p;
00312         assert( stamp );
00313 }

const TiXmlCursor& OBT::TiXmlParsingData::Cursor (  )  [inline]

Definition at line 179 of file OBTtinyxmlparser.cpp.

Referenced by OBT::TiXmlDeclaration::Parse(), OBT::TiXmlText::Parse(), OBT::TiXmlAttribute::Parse(), OBT::TiXmlComment::Parse(), OBT::TiXmlUnknown::Parse(), OBT::TiXmlElement::Parse(), OBT::TiXmlDocument::Parse(), and OBT::TiXmlDocument::SetError().

00179 { return cursor; }

void OBT::TiXmlParsingData::Stamp ( const char *  now,
TiXmlEncoding  encoding 
)

const TiXmlCursor& OBT::TiXmlParsingData::Cursor (  )  [inline]

Definition at line 179 of file tiny/OBTtinyxmlparser.cpp.

References cursor.

00179 { return cursor; }


Friends And Related Function Documentation

TiXmlDocument [friend]

Definition at line 175 of file OBTtinyxmlparser.cpp.


Member Data Documentation

TiXmlCursor OBT::TiXmlParsingData::cursor [private]

Definition at line 192 of file OBTtinyxmlparser.cpp.

Referenced by Cursor(), OBT::TiXmlDocument::Parse(), Stamp(), and TiXmlParsingData().

const char* OBT::TiXmlParsingData::stamp [private]

Definition at line 193 of file OBTtinyxmlparser.cpp.

Referenced by Stamp(), and TiXmlParsingData().

int OBT::TiXmlParsingData::tabsize [private]

Definition at line 194 of file OBTtinyxmlparser.cpp.

Referenced by Stamp(), and TiXmlParsingData().

const char* OBT::TiXmlParsingData::stamp [private]

Definition at line 193 of file tiny/OBTtinyxmlparser.cpp.


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