00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _XMLPULLPARSERH
00023 #define _XMLPULLPARSERH
00024
00025 #include <map>
00026 #include <iostream>
00027 #include <sstream>
00028 #include <string>
00029 #include <vector>
00030 #ifdef HAVE_CONFIG_H //
00031 #include <config.h>
00032 #endif
00033 #include "wsdlpull_export.h"
00034
00035
00036 const int RESIZE_BUFFER = 16;
00037
00038
00039
00040 #define FEATURE_PROCESS_NAMESPACES "http://xmlpull.org/v1/doc/features.html#process-namespaces"
00041 #define FEATURE_REPORT_NAMESPACE_ATTRIBUTES "http://xmlpull.org/v1/doc/features.html#report-namespace-prefixes"
00042 #define FEATURE_PROCESS_DOCDECL "http://xmlpull.org/v1/doc/features.html#process-docdecl"
00043 #define FEATURE_VALIDATION "http://xmlpull.org/v1/doc/features.html#validation"
00044 #define NO_NAMESPACE ""
00045
00046 class WSDLPULL_EXPORT XmlPullParser
00047 {
00048 public:
00049
00050 XmlPullParser (std::istream & is);
00051
00052 XmlPullParser (void);
00053 ~XmlPullParser (void);
00054 bool getFeature (std::string feature);
00055 std::string getInputEncoding ();
00056 void defineEntityReplacementText (std::string entity, std::string value);
00057 int getNamespaceCount (int depth);
00058 std::string getNamespacePrefix (int pos);
00059 std::string getNamespaceUri (int pos);
00060 std::string getNamespace (std::string prefix);
00061
00062 int getDepth ();
00063 std::string getPositionDescription ();
00064 int getLineNumber ()
00065 {
00066 return line;
00067 }
00068 int getColumnNumber ()
00069 {
00070 return column;
00071 }
00072 bool isWhitespace ();
00073 std::string getText ();
00074 const char *getTextCharacters (int *poslen);
00075 std::string getNamespace ()
00076 {
00077 return Ns;
00078 }
00079 std::string getName ()
00080 {
00081 return name;
00082 }
00083 std::string getPrefix ()
00084 {
00085 return prefix;
00086 }
00087 bool isEmptyElementTag ();
00088 int getAttributeCount ()
00089 {
00090 return attributeCount;
00091 }
00092 std::string getAttributeType (int )
00093 {
00094 return "CDATA";
00095 }
00096 bool isAttributeDefault (int )
00097 {
00098 return false;
00099 }
00100 std::string getAttributeNamespace (int index);
00101 std::string getAttributeName (int index);
00102 std::string getAttributePrefix (int index);
00103 std::string getAttributeValue (int index);
00104 std::string getAttributeValue (std::string ns, std::string name);
00105 int getEventType ()
00106 {
00107 return type;
00108 }
00109
00110 int next ();
00111 int nextToken ();
00112 int nextTag ();
00113 void prevTag();
00114
00115
00116
00117 void require (int type, std::string ns, std::string name);
00118 std::string nextText ();
00119 void setFeature (std::string feature, bool value);
00120 void skipSubTree() ;
00121
00122
00123
00124
00125 enum
00126 {
00127 START_DOCUMENT ,
00128 END_DOCUMENT,
00129 START_TAG,
00130 END_TAG,
00131 TEXT,
00132 CDSECT,
00133 ENTITY_REF,
00134 IGNORABLE_WHITESPACE,
00135 PROCESSING_INSTRUCTION,
00136 COMMENT,
00137 DOCDECL
00138 };
00139 private:
00140 void commonInit (void);
00141 void initBuf (void);
00142
00143
00144 std::string state (int eventType);
00145 bool isProp (std::string n1, bool prop, std::string n2);
00146 bool adjustNsp ();
00147 std::string *ensureCapacity (std::string * arr, int required);
00148 void exception (std::string desc);
00149
00150
00151
00152
00153 void nextImpl ();
00154 int parseLegacy (bool push);
00155
00156
00157
00158
00159 void parseDoctype (bool push);
00160
00161
00162 void parseEndTag ();
00163 int peekType ();
00164 std::string get (int pos);
00165 void push (int c);
00166
00167
00168 void parseStartTag (bool xmldecl);
00169
00170
00171
00172
00173
00174 void pushEntity ();
00175
00176
00177
00178
00179
00180
00181 void pushText (int delimiter, bool resolveEntities);
00182 void read (char c);
00183 int read ();
00184
00185
00186 int peekbuf (int pos);
00187 std::string readName ();
00188 void skip ();
00189 std::string unexpected_eof;
00190 std::string illegal_type;
00191 int LEGACY;
00192 int XML_DECL;
00193
00194
00195 std::string version;
00196 bool standalone;
00197
00198
00199 bool processNsp;
00200 bool relaxed;
00201 std::map < std::string, std::string > entityMap;
00202 int depth;
00203 std::vector < std::string > nspStack;
00204 std::vector < std::string > elementStack;
00205 int *nspCounts;
00206 int nspSize;
00207
00208
00209 std::string encoding;
00210 char *srcBuf;
00211 int srcPos;
00212 int srcCount;
00213 int srcBuflength;
00214
00215
00216 int line;
00217 int column;
00218
00219
00220 char *txtBuf;
00221 int txtPos;
00222 int txtBufSize;
00223
00224
00225 int type;
00226 std::string text;
00227 bool isWspace,skipNextTag;
00228 std::string Ns;
00229 std::string prefix;
00230 std::string name;
00231 bool degenerated;
00232 int attributeCount;
00233 std::vector < std::string > attributes;
00234
00235 std::istream & reader;
00236
00237
00238
00239
00240 int peek[2];
00241 int peekCount;
00242 bool wasCR;
00243 bool unresolved;
00244 bool token;
00245 };
00246 #endif