aGrUM 2.3.2
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 ()

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 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.

204 {
205 assert(start);
206 stamp = start;
207 tabsize = _tabsize;
208 cursor.row = row;
209 cursor.col = col;
210 }

References cursor, stamp, and tabsize.

Member Function Documentation

◆ Cursor()

const TiXmlCursor & TiXmlParsingData::Cursor ( )
inline

Definition at line 200 of file tinyxmlparser.cpp.

200{ return cursor; }

References cursor.

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

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.

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:64
@ TIXML_ENCODING_UTF8
Definition tinyxml.h:181
const unsigned char TIXML_UTF_LEAD_0
const unsigned char TIXML_UTF_LEAD_1
const unsigned char TIXML_UTF_LEAD_2

References cursor, stamp, tabsize, TIXML_ENCODING_UTF8, TIXML_UTF_LEAD_0, TIXML_UTF_LEAD_1, TIXML_UTF_LEAD_2, and TiXmlBase::utf8ByteTable.

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

Here is the caller graph for this function:

◆ TiXmlDocument

friend class TiXmlDocument
friend

Definition at line 195 of file tinyxmlparser.cpp.

References TiXmlDocument.

Referenced by TiXmlDocument.

Member Data Documentation

◆ cursor

TiXmlCursor TiXmlParsingData::cursor
private

Definition at line 212 of file tinyxmlparser.cpp.

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

◆ stamp

const char* TiXmlParsingData::stamp
private

Definition at line 213 of file tinyxmlparser.cpp.

Referenced by TiXmlParsingData(), and Stamp().

◆ tabsize

int TiXmlParsingData::tabsize
private

Definition at line 214 of file tinyxmlparser.cpp.

Referenced by TiXmlParsingData(), and Stamp().


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