Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef XMLPARSER_H
00029 #define XMLPARSER_H
00030
00031 #include "XMLClass.h"
00032 #include "Translations.h"
00033
00034 namespace QGpCoreTools {
00035
00036 class XMLParser
00037 {
00038 TRANSLATIONS("XMLParser")
00039 public:
00040 XMLParser(XMLStream * s, XMLContext * context=0);
00041 ~XMLParser();
00042
00043 void setLine(int l) {_line=l;}
00044 void setPointer(const QChar * ptr) {_ptr=ptr;}
00045 XMLClass::Error parse(XMLClass * object);
00046 private:
00047 void openContext();
00048 void closeContext();
00049 void smallContext();
00050 QString currentContextTag();
00051 void restoreBinaryData();
00052 void restoreBinaryData200510();
00053 void skipSpecChar();
00054 void skipDoubleQuoteString();
00055 void skipSimpleQuoteString();
00056 void skip();
00057 void restoreSpecChar();
00058 void setTag();
00059 void setAttributes();
00060 void finish(XMLClass::Error err);
00061 static QChar specialCharacter(const StringSection& code, bool& ok);
00062
00063 class Tag
00064 {
00065 public:
00066 Tag() : _member(XMLMember::Unknown) {}
00067 Tag(const StringSection& t) : _member(XMLMember::Unknown), _tag(t) {}
00068 Tag(const StringSection& t, const XMLMember& m) : _member(m), _tag(t) {}
00069 Tag(const Tag& t) : _member(t._member), _tag(t._tag) {}
00070
00071 const XMLMember& member() const {return _member;}
00072 const StringSection& tag() const {return _tag;}
00073 private:
00074 XMLMember _member;
00075 StringSection _tag;
00076 };
00077
00078 class Object
00079 {
00080 public:
00081 Object() : _context(0), _object(0) {}
00082 Object(XMLContext * context, XMLClass * object=0) : _context(context), _object(object) {}
00083 Object(const Object& o) : _context(o._context), _object(o._object) {}
00084
00085 void setObject(XMLClass * object) {_object=object;}
00086 XMLContext * context() const {return _context;}
00087 XMLClass * object() const {return _object;}
00088 private:
00089 XMLContext * _context;
00090 XMLClass * _object;
00091 };
00092
00093 QStack<Tag> _tagStack;
00094 QStack<Object> _objectStack;
00095
00096 Object _current;
00097 StringSection _tag;
00098 XMLMember _member;
00099 StringSection _content;
00100 XMLRestoreAttributes _attributes;
00101
00102 XMLStream * _stream;
00103 const QChar * _ptr;
00104 int _line;
00105 XMLClass::Error _error;
00106 const QChar * _specChar;
00107 enum TagType {Unknown, OpenTagNoAttributes, OpenTagAttributes, SingleTagNoAttributes, SingleTagAttributes,
00108 Attributes, QuestionTagNoAttributes, QuestionTagAttributes, CloseTag};
00109 TagType _tagType;
00110
00111
00112 QVector<QString *> _tmpStrings;
00113 };
00114
00115 }
00116
00117 #endif // XMLPARSER_H