aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
TiXmlParsingData Class Reference
+ Collaboration diagram for TiXmlParsingData:

Public Member Functions

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

Friends

class TiXmlDocument
 

Detailed Description

Definition at line 194 of file tinyxmlparser.cpp.

Constructor & Destructor Documentation

◆ TiXmlParsingData()

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

Definition at line 204 of file tinyxmlparser.cpp.

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

Referenced by TiXmlDocument::Parse().

204  {
205  assert(start);
206  stamp = start;
207  tabsize = _tabsize;
208  cursor.row = row;
209  cursor.col = col;
210  }
const char * stamp
TiXmlCursor cursor
+ Here is the caller graph for this function:

Member Function Documentation

◆ Cursor()

const TiXmlCursor& TiXmlParsingData::Cursor ( )
inline

Definition at line 200 of file tinyxmlparser.cpp.

References cursor.

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

200 { return cursor; }
TiXmlCursor cursor
+ Here is the caller graph for this function:

◆ Stamp()

void TiXmlParsingData::Stamp ( const char *  now,
TiXmlEncoding  encoding 
)

Definition at line 217 of file tinyxmlparser.cpp.

References TiXmlCursor::col, cursor, TiXmlCursor::row, stamp, 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(), TiXmlStylesheetReference::Parse(), TiXmlUnknown::Parse(), and TiXmlDocument::SetError().

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

Friends And Related Function Documentation

◆ TiXmlDocument

friend class TiXmlDocument
friend

Definition at line 195 of file tinyxmlparser.cpp.

Referenced by TiXmlDocument::Parse().

Member Data Documentation

◆ cursor

TiXmlCursor TiXmlParsingData::cursor
private

Definition at line 212 of file tinyxmlparser.cpp.

Referenced by Cursor(), TiXmlDocument::Parse(), Stamp(), and TiXmlParsingData().

◆ stamp

const char* TiXmlParsingData::stamp
private

Definition at line 213 of file tinyxmlparser.cpp.

Referenced by Stamp(), and TiXmlParsingData().

◆ tabsize

int TiXmlParsingData::tabsize
private

Definition at line 214 of file tinyxmlparser.cpp.

Referenced by Stamp(), and TiXmlParsingData().


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