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
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 index)
00093 {
00094 return "CDATA";
00095 }
00096 bool isAttributeDefault (int index)
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
00114
00115
00116 void require (int type, std::string ns, std::string name);
00117 std::string nextText ();
00118 void setFeature (std::string feature, bool value);
00119 void skipSubTree() ;
00120
00121
00122
00123
00124 enum
00125 {
00126 START_DOCUMENT ,
00127 END_DOCUMENT,
00128 START_TAG,
00129 END_TAG,
00130 TEXT,
00131 CDSECT,
00132 ENTITY_REF,
00133 IGNORABLE_WHITESPACE,
00134 PROCESSING_INSTRUCTION,
00135 COMMENT,
00136 DOCDECL
00137 };
00138 private:
00139 void commonInit (void);
00140 void initBuf (void);
00141
00142
00143 std::string state (int eventType);
00144 bool isProp (std::string n1, bool prop, std::string n2);
00145 bool adjustNsp ();
00146 std::string *ensureCapacity (std::string * arr, int required);
00147 void exception (std::string desc);
00148
00152 void nextImpl ();
00153 int parseLegacy (bool push);
00154
00155
00156
00158 void parseDoctype (bool push);
00159
00160
00161 void parseEndTag ();
00162 int peekType ();
00163 std::string get (int pos);
00164 void push (int c);
00165
00167 void parseStartTag (bool xmldecl);
00168
00172
00173 void pushEntity ();
00174
00180 void pushText (int delimiter, bool resolveEntities);
00181 void read (char c);
00182 int read ();
00183
00185 int peekbuf (int pos);
00186 std::string readName ();
00187 void skip ();
00188 std::string unexpected_eof;
00189 std::string illegal_type;
00190 int LEGACY;
00191 int XML_DECL;
00192
00193
00194 std::string version;
00195 bool standalone;
00196
00197
00198 bool processNsp;
00199 bool relaxed;
00200 std::map < std::string, std::string > entityMap;
00201 int depth;
00202 std::vector < std::string > nspStack;
00203 std::vector < std::string > elementStack;
00204 int *nspCounts;
00205 int nspSize;
00206
00207
00208 std::string encoding;
00209 char *srcBuf;
00210 int srcPos;
00211 int srcCount;
00212 int srcBuflength;
00213
00214
00215 int line;
00216 int column;
00217
00218
00219 char *txtBuf;
00220 int txtPos;
00221 int txtBufSize;
00222
00223
00224 int type;
00225 std::string text;
00226 bool isWspace;
00227 std::string Ns;
00228 std::string prefix;
00229 std::string name;
00230 bool degenerated;
00231 int attributeCount;
00232 std::vector < std::string > attributes;
00233
00234 std::istream & reader;
00235
00239 int peek[2];
00240 int peekCount;
00241 bool wasCR;
00242 bool unresolved;
00243 bool token;
00244 };
00245 #endif