00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00026 #ifdef __GNUG__
00027 # pragma interface
00028 #endif
00029
00030
00031 #ifndef XMLSIMPLEMODEL_H
00032 #define XMLSIMPLEMODEL_H
00033
00034
00035
00036 #include "defs.h"
00037 #include "fibonacci.h"
00038 #include "funneldevice.h"
00039 #include "hashtable.h"
00040 #include "list.h"
00041 #include "queue.h"
00042 #include "saxemitter.h"
00043 #include "stack.h"
00044 #include "textcodec.h"
00045 #include "xmlchar.h"
00046 #include "xmlmodelbase.h"
00047 #include "options.h"
00048
00049
00051 namespace StructuralSymbols
00052 {
00054 enum Symbol
00055 {
00057 None = -1,
00058
00060 EndOfBlock = 0,
00061
00063 NewElement = 1,
00064
00066 KnownElement = 2,
00067
00069 EndElement = 3,
00070
00071
00073 Comment = 4,
00074
00076 PI = 5,
00077
00079 Doctype = 6,
00080
00082 XmlDecl = 7,
00083
00085 CDATA = 8,
00086
00088 Attributes = 11,
00089
00091 EntityDecl = 14,
00092
00094 NotationDecl = 15,
00095
00097 Default = 16,
00098
00100 StandaloneYes = 1,
00101
00103 StandaloneNo = 2,
00104
00106 StandaloneNotSpecified = 0,
00107
00109 HasInternalSubsetYes = 1,
00110
00112 HasInternalSubsetNo = 2,
00113
00115 IsParameterEntityYes = 1,
00116
00118 IsParameterEntityNo = 2,
00119
00121 EmptyString = 18,
00122
00123 };
00124 }
00125
00126
00130 struct SimpleElementContext
00131 {
00133 XmlChar *name;
00134 };
00135
00136
00138 typedef HashTable<unsigned long, SimpleElementContext, List, 3079> SimpleElementTable;
00139
00140
00141
00147 class XmlSimpleModel : public XmlModelBase
00148 {
00149 public:
00151 XmlSimpleModel(void);
00152
00154 virtual ~XmlSimpleModel(void);
00155
00157 virtual bool manageEvent(XmlModelEvent *event);
00158
00166 virtual void setGrammar(GrammarBase *gr) { grammar = gr; }
00167
00169 virtual void setSAXEmitter(SAXEmitter *emitter, void *data = 0);
00170
00172 virtual void receiveData(XmlChar *data, size_t size);
00173
00174
00175 protected:
00177 GrammarBase *grammar;
00178
00179
00181 bool inCDATA;
00182
00184 bool inDoctype;
00185
00187 bool elementHasAttributes;
00188
00190 bool attributeListComplete;
00191
00197 StructuralSymbols::Symbol state;
00198
00200 ElementIds *elementIds;
00201
00203 SimpleElementTable *elements;
00204
00206 ElementNamesList *elementNamesList;
00207
00209 unsigned long elementCounter;
00210
00216 Stack<unsigned long> *elementStack;
00217
00223 XmlChar *buffer;
00224
00226 size_t bufferLength;
00227
00228
00229
00235 size_t fibBits;
00236
00242 unsigned long fibCode;
00243
00245 bool fibLastWasOne;
00246
00248 DataQueue *dataQueue;
00249
00255 SAXEmitter *saxEmitter;
00256
00262 void *userData;
00263 };
00264
00265
00266 #endif //XMLSIMPLEMODEL_H