Brief description of class still missing. More...
#include <XMLParser.h>
Classes | |
class | Object |
class | Tag |
Public Member Functions | |
XMLClass::Error | parse (XMLClass *object) |
void | setLine (int l) |
void | setPointer (const QChar *ptr) |
XMLParser (XMLStream *s, XMLContext *context=0) | |
~XMLParser () |
Brief description of class still missing.
Full description of class still missing
QGpCoreTools::XMLParser::XMLParser | ( | XMLStream * | s, |
XMLContext * | context = 0 |
||
) |
Description of constructor still missing
: _current(context), _member(XMLMember::Unknown), _stream(s) { _line=1; }
Description of destructor still missing
{ qDeleteAll(_tmpStrings); }
XMLClass::Error QGpCoreTools::XMLParser::parse | ( | XMLClass * | object | ) |
References QGpCoreTools::XMLClass::ErrorEndTagNotFound, QGpCoreTools::XMLClass::ErrorEndTruncatedContext, QGpCoreTools::XMLClass::ErrorEndTruncatedTag, QGpCoreTools::StringSection::isEmpty(), QGpCoreTools::XMLClass::NoError, QGpCoreTools::StringSection::set(), QGpCoreTools::StringSection::setEnd(), and QGpCoreTools::StringSection::toString().
Referenced by QGpCoreTools::XMLClass::restore().
{ _current.setObject(object); //#define XML_DEBUG #ifdef XML_DEBUG printf("Entering context %s\n", _current->xml_tagName().toAscii().data()); #endif _error=XMLClass::NoError; // In case restore is called for an XML item with no children, just content // For normal situations this should not happen. It is mostly used by GenericItem and XMLDummy _content.set(_ptr, 0); _specChar=0; /* The buffer may start with other data that must be skipped while not inside the right context. The buffer is parsed until it finds a root tag corresponding to tagName */ while(true) { switch (_ptr->unicode()) { case 0x000A: // '\n' _line++; break; case 0x0026: { // '&' if( !_specChar) _specChar=_ptr; // keep track of first occurence of & in content skipSpecChar(); } break; case 0x003C: { // '<' _content.setEnd(_ptr); setTag(); switch(_tagType) { case Attributes: qDeleteAll(_tmpStrings); _tmpStrings.clear(); _attributes.clear(); setAttributes(); switch(_tagType) { case OpenTagAttributes: #ifdef XML_DEBUG printf("%5i=%5i === <%s att>\n", __LINE__, _line, _tag.toString().toAscii().data()); #endif openContext(); break; case SingleTagAttributes: #ifdef XML_DEBUG printf("%5i=%5i === <%s att/>\n", __LINE__, _line, _tag.toString().toAscii().data()); #endif smallContext(); break; default: break; } break; case OpenTagNoAttributes: qDeleteAll(_tmpStrings); _tmpStrings.clear(); _attributes.clear(); #ifdef XML_DEBUG printf("%5i=%5i === <%s>\n", __LINE__, _line, _tag.toString().toAscii().data()); #endif openContext(); break; case CloseTag: #ifdef XML_DEBUG printf("%5i=%5i === %s</%s>\n", __LINE__, _line, _content.toString().toAscii().data(), _tag.toString().toAscii().data()); #endif closeContext(); break; case SingleTagNoAttributes: qDeleteAll(_tmpStrings); _tmpStrings.clear(); _attributes.clear(); #ifdef XML_DEBUG printf("%5i=%5i === <%s/>\n", __LINE__, _line, _tag.toString().toAscii().data()); #endif smallContext(); break; default: break; } } break; case 0x0000: // END if(_error!=XMLClass::NoError) { } else if(_tag.isEmpty()) { finish(XMLClass::ErrorEndTruncatedTag); } else if(_tagStack.size() > 2) { finish(XMLClass::ErrorEndTruncatedContext); } else if(!_current.object()->xml_polished()) { finish(XMLClass::ErrorEndTagNotFound); } return _error; default: break; } _ptr++; } }
void QGpCoreTools::XMLParser::setLine | ( | int | l | ) | [inline] |
Referenced by QGpCoreTools::XMLClass::restore().
{_line=l;}
void QGpCoreTools::XMLParser::setPointer | ( | const QChar * | ptr | ) | [inline] |
Referenced by QGpCoreTools::XMLClass::restore().
{_ptr=ptr;}