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 XMLADAPTIVEMODEL_H
00032 #define XMLADAPTIVEMODEL_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 "elementmodel.h"
00048 #include "options.h"
00049
00050
00058 namespace AdaptiveStructuralSymbols
00059 {
00061 enum Symbol
00062 {
00064 None = -1,
00065
00067 EndOfBlock = 0,
00068
00070 NewElement = 1,
00071
00073 KnownElement = 2,
00074
00076 EndElement = 3,
00077
00078 Characters = 4,
00079
00081 Comment = 1,
00082
00084 PI = 2,
00085
00087 CDATA = 3,
00088
00090 NACK = 0,
00091
00093 DifferentEdge = 0,
00094
00096 XmlDecl = 2,
00097
00099 Doctype = 3,
00100
00102 Default = 5,
00103
00105 EntityDecl = 6,
00106
00108 NotationDecl = 7,
00109
00111 StandaloneYes = 1,
00112
00114 StandaloneNo = 2,
00115
00117 StandaloneNotSpecified = 0,
00118
00120 HasInternalSubsetYes = 1,
00121
00123 HasInternalSubsetNo = 2,
00124
00126 IsParameterEntityYes = 1,
00127
00129 IsParameterEntityNo = 2,
00130
00132 EmptyString = 8
00133 };
00134 }
00135
00136
00137
00143 struct AdaptiveElementContext
00144 {
00146 XmlChar *name;
00147
00149 ElementModeler *modeler;
00150 };
00151
00152
00154 typedef HashTable<unsigned long, AdaptiveElementContext, List, 3079> AdaptiveElementTable;
00155
00157 typedef HashTable<unsigned long, XmlChar, List, 3079> AttributeNamesTable;
00158
00159
00160
00166 class XmlAdaptiveModel : public XmlModelBase
00167 {
00168 public:
00170 XmlAdaptiveModel(void);
00171
00173 virtual ~XmlAdaptiveModel(void);
00174
00176 virtual bool manageEvent(XmlModelEvent *event);
00177
00185 virtual void setGrammar(GrammarBase *gr) { grammar = gr; }
00186
00188 virtual void setSAXEmitter(SAXEmitter *emitter, void *data = 0);
00189
00190
00192 virtual void receiveData(XmlChar *data, size_t size);
00193
00194
00195 protected:
00197 GrammarBase *grammar;
00198
00199
00201 bool inCDATA;
00202
00204 bool inCharacters;
00205
00207 bool inComment;
00208
00214 char inPI;
00215
00217 bool inProlog;
00218
00220 bool inNACK;
00221
00223 bool inDoctype;
00224
00226 bool inAttr;
00227
00229 bool inAttrValue;
00230
00232 bool firstAttrRead;
00233
00235 bool nackEndedInCharacters;
00236
00242 int attrPos;
00243
00249 AdaptiveStructuralSymbols::Symbol state;
00250
00252 ElementIds *elementIds;
00253
00255 AdaptiveElementTable *elements;
00256
00258 AttributeNamesTable *attributeNames;
00259
00261 ElementNamesList *elementNamesList;
00262
00264 unsigned long elementCounter;
00265
00266
00267
00269 AttributeIds *attributeIds;
00270
00272 AttributeNamesList *attributeNamesList;
00273
00275 unsigned long attributeCounter;
00276
00277
00278
00284 Stack<unsigned long> *elementStack;
00285
00286
00288 Stack<ElementModelerInfo> elementModelerStack;
00289
00291 List<ElementModeler> elementModelerList;
00292
00293
00295 size_t clueEdge;
00296
00298 bool readingNackData;
00299
00305 XmlChar *buffer;
00306
00308 size_t bufferLength;
00309
00310
00311
00317 size_t fibBits;
00318
00324 unsigned long fibCode;
00325
00327 bool fibLastWasOne;
00328
00330 DataQueue *dataQueue;
00331
00337 SAXEmitter *saxEmitter;
00338
00344 void *userData;
00345 };
00346
00347
00348 #endif //XMLADAPTIVEMODEL_H