CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes | Friends
TiXmlParsingData Class Reference

Public Member Functions

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

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
 

Detailed Description

Definition at line 175 of file tinyxmlparser.cc.

Constructor & Destructor Documentation

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

Definition at line 185 of file tinyxmlparser.cc.

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

186  {
187  assert( start );
188  stamp = start;
189  tabsize = _tabsize;
190  cursor.row = row;
191  cursor.col = col;
192  }
const char * stamp
TiXmlCursor cursor

Member Function Documentation

const TiXmlCursor& TiXmlParsingData::Cursor ( )
inline
void TiXmlParsingData::Stamp ( const char *  now,
TiXmlEncoding  encoding 
)

Definition at line 200 of file tinyxmlparser.cc.

References TiXmlCursor::col, cursor, L1TEmulatorMonitor_cff::p, TiXmlCursor::row, stamp, ExpressReco_HICollisions_FallBack::step, tabsize, TIXML_ENCODING_UTF8, TIXML_UTF_LEAD_0, TIXML_UTF_LEAD_1, TIXML_UTF_LEAD_2, and TiXmlBase::utf8ByteTable.

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

201 {
202  assert( now );
203 
204  // Do nothing if the tabsize is 0.
205  if ( tabsize < 1 )
206  {
207  return;
208  }
209 
210  // Get the current row, column.
211  int row = cursor.row;
212  int col = cursor.col;
213  const char* p = stamp;
214  assert( p );
215 
216  while ( p < now )
217  {
218  // Treat p as unsigned, so we have a happy compiler.
219  const unsigned char* pU = (const unsigned char*)p;
220 
221  // Code contributed by Fletcher Dunn: (modified by lee)
222  switch (*pU) {
223  case 0:
224  // We *should* never get here, but in case we do, don't
225  // advance past the terminating null character, ever
226  return;
227 
228  case '\r':
229  // bump down to the next line
230  ++row;
231  col = 0;
232  // Eat the character
233  ++p;
234 
235  // Check for \r\n sequence, and treat this as a single character
236  if (*p == '\n') {
237  ++p;
238  }
239  break;
240 
241  case '\n':
242  // bump down to the next line
243  ++row;
244  col = 0;
245 
246  // Eat the character
247  ++p;
248 
249  // Check for \n\r sequence, and treat this as a single
250  // character. (Yes, this bizarre thing does occur still
251  // on some arcane platforms...)
252  if (*p == '\r') {
253  ++p;
254  }
255  break;
256 
257  case '\t':
258  // Eat the character
259  ++p;
260 
261  // Skip to next tab stop
262  col = (col / tabsize + 1) * tabsize;
263  break;
264 
265  case TIXML_UTF_LEAD_0:
266  if ( encoding == TIXML_ENCODING_UTF8 )
267  {
268  if ( *(p+1) && *(p+2) )
269  {
270  // In these cases, don't advance the column. These are
271  // 0-width spaces.
272  if ( *(pU+1)==TIXML_UTF_LEAD_1 && *(pU+2)==TIXML_UTF_LEAD_2 )
273  p += 3;
274  else if ( *(pU+1)==0xbfU && *(pU+2)==0xbeU )
275  p += 3;
276  else if ( *(pU+1)==0xbfU && *(pU+2)==0xbfU )
277  p += 3;
278  else
279  { p +=3; ++col; } // A normal character.
280  }
281  }
282  else
283  {
284  ++p;
285  ++col;
286  }
287  break;
288 
289  default:
290  if ( encoding == TIXML_ENCODING_UTF8 )
291  {
292  // Eat the 1 to 4 byte utf8 character.
293  int step = TiXmlBase::utf8ByteTable[*((const unsigned char*)p)];
294  if ( step == 0 )
295  step = 1; // Error case from bad encoding, but handle gracefully.
296  p += step;
297 
298  // Just advance one column, of course.
299  ++col;
300  }
301  else
302  {
303  ++p;
304  ++col;
305  }
306  break;
307  }
308  }
309  cursor.row = row;
310  cursor.col = col;
311  assert( cursor.row >= -1 );
312  assert( cursor.col >= -1 );
313  stamp = p;
314  assert( stamp );
315 }
static const int utf8ByteTable[256]
Definition: tinyxml.h:255
const unsigned char TIXML_UTF_LEAD_2
const char * stamp
const unsigned char TIXML_UTF_LEAD_0
const unsigned char TIXML_UTF_LEAD_1
TiXmlCursor cursor

Friends And Related Function Documentation

friend class TiXmlDocument
friend

Definition at line 177 of file tinyxmlparser.cc.

Member Data Documentation

TiXmlCursor TiXmlParsingData::cursor
private
const char* TiXmlParsingData::stamp
private

Definition at line 195 of file tinyxmlparser.cc.

Referenced by Stamp(), and TiXmlParsingData().

int TiXmlParsingData::tabsize
private

Definition at line 196 of file tinyxmlparser.cc.

Referenced by Stamp(), and TiXmlParsingData().