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

Constructor & Destructor Documentation

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

Definition at line 193 of file tinyxmlparser.cc.

References assert(), TiXmlCursor::col, cuy::col, cursor, TiXmlCursor::row, stamp, dqm_diff::start, and tabsize.

194  {
195  assert( start );
196  stamp = start;
197  tabsize = _tabsize;
198  cursor.row = row;
199  cursor.col = col;
200  }
tuple start
Check for commandline option errors.
Definition: dqm_diff.py:58
assert(m_qm.get())
const char * stamp
int col
Definition: cuy.py:1008
TiXmlCursor cursor

Member Function Documentation

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

Definition at line 208 of file tinyxmlparser.cc.

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

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

Friends And Related Function Documentation

friend class TiXmlDocument
friend

Definition at line 185 of file tinyxmlparser.cc.

Member Data Documentation

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

Definition at line 203 of file tinyxmlparser.cc.

Referenced by Stamp(), and TiXmlParsingData().

int TiXmlParsingData::tabsize
private

Definition at line 204 of file tinyxmlparser.cc.

Referenced by Stamp(), and TiXmlParsingData().