Back to index

nux  3.0.0
Public Member Functions | Private Member Functions | Private Attributes | Friends
TiXmlParsingData Class Reference
Collaboration diagram for TiXmlParsingData:
Collaboration graph
[legend]

List of all members.

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 198 of file tinyxmlparser.cpp.


Constructor & Destructor Documentation

TiXmlParsingData::TiXmlParsingData ( const char *  start,
int  _tabsize,
int  row,
int  col 
) [inline, private]

Definition at line 211 of file tinyxmlparser.cpp.

  {
    assert ( start );
    stamp = start;
    tabsize = _tabsize;
    cursor.row = row;
    cursor.col = col;
  }

Member Function Documentation

Definition at line 204 of file tinyxmlparser.cpp.

  {
    return cursor;
  }

Here is the caller graph for this function:

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

Definition at line 226 of file tinyxmlparser.cpp.

{
  assert ( now );

  // Do nothing if the tabsize is 0.
  if ( tabsize < 1 )
  {
    return;
  }

  // Get the current row, column.
  int row = cursor.row;
  int col = cursor.col;
  const char *p = stamp;
  assert ( p );

  while ( p < now )
  {
    // Treat p as unsigned, so we have a happy compiler.
    const unsigned char *pU = (const unsigned char *) p;

    // Code contributed by Fletcher Dunn: (modified by lee)
    switch (*pU)
    {
      case 0:
        // We *should* never get here, but in case we do, don't
        // advance past the terminating null character, ever
        return;

      case '\r':
        // bump down to the next line
        ++row;
        col = 0;
        // Eat the character
        ++p;

        // Check for \r\n sequence, and treat this as a single character
        if (*p == '\n')
        {
          ++p;
        }

        break;

      case '\n':
        // bump down to the next line
        ++row;
        col = 0;

        // Eat the character
        ++p;

        // Check for \n\r sequence, and treat this as a single
        // character.  (Yes, this bizarre thing does occur still
        // on some arcane platforms...)
        if (*p == '\r')
        {
          ++p;
        }

        break;

      case '\t':
        // Eat the character
        ++p;

        // Skip to next tab stop
        col = (col / tabsize + 1) * tabsize;
        break;

      case TIXML_UTF_LEAD_0:

        if ( encoding == TIXML_ENCODING_UTF8 )
        {
          if ( * (p + 1) && * (p + 2) )
          {
            // In these cases, don't advance the column. These are
            // 0-width spaces.
            if ( * (pU + 1) == TIXML_UTF_LEAD_1 && * (pU + 2) == TIXML_UTF_LEAD_2 )
              p += 3;
            else if ( * (pU + 1) == 0xbfU && * (pU + 2) == 0xbeU )
              p += 3;
            else if ( * (pU + 1) == 0xbfU && * (pU + 2) == 0xbfU )
              p += 3;
            else
            {
              p += 3;  // A normal character.
              ++col;
            }
          }
        }
        else
        {
          ++p;
          ++col;
        }

        break;

      default:

        if ( encoding == TIXML_ENCODING_UTF8 )
        {
          // Eat the 1 to 4 byte utf8 character.
          int step = TiXmlBase::utf8ByteTable[* ( (const unsigned char *) p) ];

          if ( step == 0 )
            step = 1;              // Error case from bad encoding, but handle gracefully.

          p += step;

          // Just advance one column, of course.
          ++col;
        }
        else
        {
          ++p;
          ++col;
        }

        break;
    }
  }

  cursor.row = row;
  cursor.col = col;
  assert ( cursor.row >= -1 );
  assert ( cursor.col >= -1 );
  stamp = p;
  assert ( stamp );
}

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class TiXmlDocument [friend]

Definition at line 200 of file tinyxmlparser.cpp.


Member Data Documentation

Definition at line 220 of file tinyxmlparser.cpp.

const char* TiXmlParsingData::stamp [private]

Definition at line 221 of file tinyxmlparser.cpp.

Definition at line 222 of file tinyxmlparser.cpp.


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