FEDRA emulsion software from the OPERA Collaboration
TiXmlParsingData Class Reference
Collaboration diagram for TiXmlParsingData:

Public Member Functions

const TiXmlCursorCursor () const
 
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
 

Constructor & Destructor Documentation

◆ TiXmlParsingData()

TiXmlParsingData::TiXmlParsingData ( const char *  start,
int  _tabsize,
int  row,
int  col 
)
inlineprivate
182  {
183  assert( start );
184  stamp = start;
185  tabsize = _tabsize;
186  cursor.row = row;
187  cursor.col = col;
188  }
const char * stamp
Definition: tinyxmlparser.cpp:191
int tabsize
Definition: tinyxmlparser.cpp:192
TiXmlCursor cursor
Definition: tinyxmlparser.cpp:190
int col
Definition: tinyxml.h:105
int row
Definition: tinyxml.h:104

Member Function Documentation

◆ Cursor()

const TiXmlCursor& TiXmlParsingData::Cursor ( ) const
inline
177 { return cursor; }

◆ Stamp()

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

Friends And Related Function Documentation

◆ TiXmlDocument

friend class TiXmlDocument
friend

Member Data Documentation

◆ cursor

TiXmlCursor TiXmlParsingData::cursor
private

◆ stamp

const char* TiXmlParsingData::stamp
private

◆ tabsize

int TiXmlParsingData::tabsize
private

The documentation for this class was generated from the following file: