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 178 of file tinyxmlparser.cc.

Constructor & Destructor Documentation

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

Definition at line 188 of file tinyxmlparser.cc.

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

189  {
190  assert( start );
191  stamp = start;
192  tabsize = _tabsize;
193  cursor.row = row;
194  cursor.col = col;
195  }
const char * stamp
TiXmlCursor cursor

Member Function Documentation

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

Definition at line 203 of file tinyxmlparser.cc.

References TiXmlCursor::col, cursor, AlCaHLTBitMon_ParallelJobs::p, TiXmlCursor::row, stamp, launcher::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().

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

Member Data Documentation

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

Definition at line 198 of file tinyxmlparser.cc.

Referenced by Stamp(), and TiXmlParsingData().

int TiXmlParsingData::tabsize
private

Definition at line 199 of file tinyxmlparser.cc.

Referenced by Stamp(), and TiXmlParsingData().