Public Member Functions | |
void | Stamp (const char *now, TiXmlEncoding encoding) |
const TiXmlCursor & | Cursor () |
Private Member Functions | |
TiXmlParsingData (const char *start, int _tabsize, int row, int col) | |
Private Attributes | |
TiXmlCursor | cursor |
const char * | stamp |
int | tabsize |
Friends | |
class | TiXmlDocument |
Definition at line 173 of file tiny/tmp/OBTtinyxmlparser.cpp.
xmlTiny::TiXmlParsingData::TiXmlParsingData | ( | const char * | start, | |
int | _tabsize, | |||
int | row, | |||
int | col | |||
) | [inline, private] |
void xmlTiny::TiXmlParsingData::Stamp | ( | const char * | now, | |
TiXmlEncoding | encoding | |||
) |
Definition at line 198 of file tiny/tmp/OBTtinyxmlparser.cpp.
References xmlTiny::TiXmlCursor::col, cursor, xmlTiny::TiXmlCursor::row, stamp, tabsize, xmlTiny::TIXML_ENCODING_UTF8, xmlTiny::TIXML_UTF_LEAD_0, xmlTiny::TIXML_UTF_LEAD_1, xmlTiny::TIXML_UTF_LEAD_2, and xmlTiny::TiXmlBase::utf8ByteTable.
Referenced by xmlTiny::TiXmlDeclaration::Parse(), xmlTiny::TiXmlText::Parse(), xmlTiny::TiXmlAttribute::Parse(), xmlTiny::TiXmlComment::Parse(), xmlTiny::TiXmlUnknown::Parse(), xmlTiny::TiXmlElement::Parse(), and xmlTiny::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& xmlTiny::TiXmlParsingData::Cursor | ( | ) | [inline] |
Definition at line 179 of file tiny/tmp/OBTtinyxmlparser.cpp.
Referenced by xmlTiny::TiXmlDeclaration::Parse(), xmlTiny::TiXmlText::Parse(), xmlTiny::TiXmlAttribute::Parse(), xmlTiny::TiXmlComment::Parse(), xmlTiny::TiXmlUnknown::Parse(), xmlTiny::TiXmlElement::Parse(), xmlTiny::TiXmlDocument::Parse(), and xmlTiny::TiXmlDocument::SetError().
00179 { return cursor; }
friend class TiXmlDocument [friend] |
Definition at line 175 of file tiny/tmp/OBTtinyxmlparser.cpp.
TiXmlCursor xmlTiny::TiXmlParsingData::cursor [private] |
Definition at line 192 of file tiny/tmp/OBTtinyxmlparser.cpp.
Referenced by xmlTiny::TiXmlDocument::Parse(), and Stamp().
const char* xmlTiny::TiXmlParsingData::stamp [private] |
int xmlTiny::TiXmlParsingData::tabsize [private] |