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
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 #ifndef __XMLSOURCE_H__
00045 #define __XMLSOURCE_H__
00046
00047 #include <qxml.h>
00048 #include <qstring.h>
00049 #include <qstringlist.h>
00050 #include <qstack.h>
00051 #include <qdict.h>
00052 #include "datacache.h"
00053 #include "common.h"
00054
00055
00056 class DBXml : public DBAccess
00057 {
00058 public:
00059
00060 DBXml(DBStore *d);
00061 QString type();
00062 bool openSource(QIODevice *);
00063 bool saveSource(QIODevice *);
00064
00065 ~DBXml();
00066 };
00067
00068
00069 class DBXmlHandler : public QXmlDefaultHandler
00070 {
00071
00072 public:
00073 DBXmlHandler(DBStore *ds);
00074 virtual ~DBXmlHandler();
00075
00076
00077 QString errorProtocol();
00078
00079
00080 bool startDocument();
00081 bool startElement(const QString& namespaceURI, const QString& localName,
00082 const QString& qName, const QXmlAttributes& atts);
00083 bool endElement(const QString& namespaceURI, const QString& localName,
00084 const QString& qName);
00085 bool characters(const QString& ch);
00086
00087 QString errorString();
00088
00089 bool warning(const QXmlParseException& exception);
00090 bool error(const QXmlParseException& exception);
00091 bool fatalError(const QXmlParseException& exception);
00092
00093 private:
00094
00095 QStack<QString> stack;
00096 KeyList *current_keyrep;
00097 DataElem *current_data;
00098 TVVariant::KeyType last_key_type;
00099
00100 QString errorProt;
00101 DBStore *data_store;
00102
00103 enum State {
00104 StateInit,
00105 StateHeader,
00106 StateKey,
00107 StateDocument,
00108 StateRecord,
00109 StateField
00110 };
00111
00112 State state;
00113
00114 QDict<int> keyIndexList;
00115 int keyIndex;
00116 QString key;
00117 };
00118
00119 #endif