rtXmlPull.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __RTXMLPULL_H
00025 #define __RTXMLPULL_H
00026
00027 #include "rtxsrc/rtxCtype.h"
00028 #include "rtxsrc/rtxStream.h"
00029 #include "rtxsrc/rtxStreamBuffered.h"
00030 #include "rtxsrc/rtxErrCodes.h"
00031 #include "rtxsrc/rtxStreamDirectBuf.hh"
00032 #include "rtxmlsrc/osrtxml.h"
00033
00034
00035
00036
00037 #define MAX_DELAYED_TASK_SIZE 10
00038
00039
00040 #define OSXML_DEFAULT_QNAME_BUF_SIZE 10
00041
00042 #define OSXMLEVT_NONE 0
00043 #define OSXMLEVT_INITIAL OSXMLEVT_NONE
00044 #define OSXMLEVT_START_DOCUMENT 0x1
00045 #define OSXMLEVT_START_TAG 0x2
00046 #define OSXMLEVT_TEXT 0x4
00047 #define OSXMLEVT_END_TAG 0x8
00048 #define OSXMLEVT_END_DOCUMENT 0x10
00049 #define OSXMLEVT_COMMENT 0x20
00050 #define OSXMLEVT_PI 0x40
00051 #define OSXMLEVT_DTD 0x40
00052
00053 #define OSXMLEVT_USED_FLAG 0x80000000u
00054 #define OSXMLEVT_ID_MASK (~OSXMLEVT_USED_FLAG)
00055 #define OSXMLEVT_ALL_MASK OSXMLEVT_ID_MASK
00056
00057 #define XMLPREADER(pctxt) ((OSXMLCtxtInfo*) pctxt->pXMLInfo)->pXmlPPReader
00058
00059 typedef enum {
00060 OSXMLS_HEADER = -1,
00061 OSXMLS_COMMENT = -2,
00062 OSXMLS_START_ELEMENT = -3,
00063 OSXMLS_DTD = -4,
00064 OSXMLS_CONTENT = -5,
00065 OSXMLS_PI = -6,
00066 OSXMLS_END_ELEMENT = -7,
00067 OSXMLS_CDATA = -8,
00068
00069 OSXMLS_LAST = -9
00070 } OSXMLStates;
00071
00072 typedef enum {
00073 OSXMLSI_HEADER = -OSXMLS_HEADER-1,
00074 OSXMLSI_COMMENT = -OSXMLS_COMMENT-1,
00075 OSXMLSI_START_ELEMENT = -OSXMLS_START_ELEMENT-1,
00076 OSXMLSI_DTD = -OSXMLS_DTD-1,
00077 OSXMLSI_CONTENT = -OSXMLS_CONTENT-1,
00078 OSXMLSI_PI = -OSXMLS_PI-1,
00079 OSXMLSI_END_ELEMENT = -OSXMLS_END_ELEMENT-1,
00080 OSXMLSI_CDATA = -OSXMLS_CDATA-1,
00081
00082 OSXMLSI_LAST = -OSXMLS_LAST-1
00083 } OSXMLStatesIndex;
00084
00085 typedef enum {
00086 OSXMLDM_NONE = 0,
00087 OSXMLDM_SIMULATED,
00088 OSXMLDM_CONTENT
00089 } OSXMLDataMode;
00090
00091 typedef enum {
00092 OSXMLNSI_UNQUALIFIED = 0,
00093 OSXMLNSI_UNKNOWN = -1,
00094 OSXMLNSI_UNCHECKED = -2,
00095 OSXMLNSI_XSI = -3,
00096 OSXMLNSI_XMLNS = -4,
00097 OSXMLNSI_XML = -5,
00098 OSXMLNSI_SOAP_ENVELOPE = -6,
00099 OSXMLNSI_XSD = -7
00100 } OSXMLNsIndex;
00101
00102 typedef struct {
00103 size_t offset;
00104 size_t length;
00105 } OSXMLStrFragOffset;
00106
00107 typedef struct {
00108 OSXMLStrFragment mQName;
00109 OSXMLStrFragment mLocalName;
00110 OSXMLStrFragment mPrefix;
00111
00112 OSUTF8CHAR mBuffer[OSXML_DEFAULT_QNAME_BUF_SIZE];
00113 } OSXMLElementName;
00114
00115 typedef struct OSXMLEvent {
00116 OSUINT32 mId;
00117 OSINT32 mLevel;
00118 } OSXMLEvent;
00119
00120 typedef struct OSXMLDataCtxt {
00121 OSINT32 mDataLevel;
00122 OSXMLDataMode mDataMode;
00123
00124
00125 int mnChunk;
00126 OSBOOL mbLastChunk;
00127 OSBOOL mbCDATA;
00128 OSXMLStrFragment mData;
00129
00130
00131 OSXMLStrFragment mSrcData;
00132 size_t mSrcDataOffset;
00133 OSBOOL mbInsTokenSeparator;
00134 } OSXMLDataCtxt;
00135
00136 typedef struct {
00137 OSXMLStrFragOffset mQName;
00138 OSXMLStrFragOffset mLocalName;
00139 OSXMLStrFragOffset mPrefix;
00140 } OSXMLElemNameOffset;
00141
00142 typedef struct OSXMLStack {
00143 void* mpStackArray;
00144 size_t mSize;
00145 size_t mUnitSize;
00146 size_t mCount;
00147 OSBOOL mbDynamic;
00148 } OSXMLStack;
00149
00150 typedef struct OSXMLRewindPos {
00151 size_t mPos;
00152 OSXMLEvent mEvent;
00153 OSXMLStrFragment mData;
00154 OSBOOL mbListMode;
00155 OSBOOL mbLastChunk;
00156 } OSXMLRewindPos;
00157
00158 typedef struct OSXMLSrcPos {
00159 OSUINT32 mLine;
00160 OSUINT32 mColumn;
00161 OSUINT32 mByteIdx;
00162 OSBOOL mbCR;
00163 } OSXMLSrcPos;
00164
00165 typedef struct OSXMLReader {
00166
00167 OSCTXT* mpCtxt;
00168 OSBOOL mbNoTransform;
00169 OSBOOL mbWSOnlyContext;
00170 OSBOOL mbMixedContext;
00171 OSBOOL mbListMode;
00172 OSBOOL mbSkipPullListElem;
00173 OSBOOL mbDecodeAsGroup;
00174 OSXMLWhiteSpaceMode mWhiteSpaceMode;
00175 OSXMLWhiteSpaceMode mStringWhiteSpaceMode;
00176 OSXMLEncoding mEncoding;
00177 OSXMLBOM mBOM;
00178
00179
00180 OSXMLEvent mLastEvent;
00181
00182 OSXMLElemNameOffset mElementName;
00183 OSBOOL mbHasAttributes;
00184 OSBOOL mbEmptyElement;
00185
00186 OSXMLStack mAttributes;
00187
00188 OSXMLStrFragment mCharacters;
00189 OSXMLStrFragment mData;
00190 OSBOOL mbLastChunk;
00191 OSBOOL mbCDATA;
00192 OSINT32 mLevel;
00193 OSINT32 mDecodeLevel;
00194
00195 int mError;
00196
00197 OSINT16 mElementNsIndex;
00198
00199
00200 int mState, mPrevState, mNewState;
00201 int mLocalStates [OSXMLSI_LAST];
00202 OSUTF8CHAR mCharBuf[10];
00203 OSUTF8CHAR* mpEscapeChar;
00204 OSUTF8CHAR* mpChars;
00205 size_t mMarkedByteIndex;
00206 OSXMLDataMode mDataMode;
00207
00208
00209 OSXMLStack mTagNamesStack;
00210
00211
00212 OSXMLStack mNamespacesStack;
00213 #ifdef OSXMLNS12
00214 const OSUTF8CHAR** mNamespaceTable;
00215 int mNamespacesNumber;
00216 const OSUTF8CHAR** mPrevNamespaceTable;
00217 int mPrevNamespacesNumber;
00218 #else
00219 const char** mNamespaceTable;
00220 int mNamespacesNumber;
00221 const char** mPrevNamespaceTable;
00222 int mPrevNamespacesNumber;
00223 #endif
00224
00225 OSOCTET mDelayedTasks [MAX_DELAYED_TASK_SIZE];
00226 size_t mDelayedTaskCount;
00227 size_t mDelayedTaskIndex;
00228
00229
00230 OSUTF8CHAR* mpBuffer;
00231 size_t mByteIndex;
00232 size_t mBufSize;
00233 size_t mReadSize;
00234 size_t mMarkedPos;
00235
00236 size_t mLastBlockSize;
00237 size_t mLastByteIndex;
00238
00239 OSBOOL mbBackoffEnabled;
00240 OSBOOL mbSysMemBuf;
00241
00242 OSXMLStack mRewindPosStack;
00243
00244
00245 OSXMLSrcPos mSrcPos;
00246
00247 } OSXMLReader;
00248
00249 #ifdef __cplusplus
00250 extern "C" {
00251 #endif
00252
00256 EXTXMLMETHOD struct OSXMLReader* rtXmlRdCreateXmlReader (OSCTXT* pctxt);
00257
00267 EXTXMLMETHOD OSXMLWhiteSpaceMode rtXmlRdSetWhiteSpaceMode
00268 (struct OSXMLReader* pReader, OSXMLWhiteSpaceMode whiteSpaceMode);
00269
00287 EXTXMLMETHOD long rtXmlRdFirstData (struct OSXMLReader* pReader, OSXMLDataCtxt* pDataCtxt);
00288
00302 EXTXMLMETHOD long rtXmlRdNextData (struct OSXMLReader* pReader, OSXMLDataCtxt* pDataCtxt);
00303
00310 EXTXMLMETHOD int rtXmlRdSkipCurrentLevel (struct OSXMLReader* pReader);
00311
00320 EXTXMLMETHOD int rtXmlRdNext (struct OSXMLReader* pReader);
00321
00328 EXTXMLMETHOD int rtXmlRdNextTag (struct OSXMLReader* pReader);
00329
00335 EXTXMLMETHOD int rtXmlRdNextEndTag (struct OSXMLReader* pReader);
00336
00342 EXTXMLMETHOD OSXMLEvent rtXmlRdGetLastEvent (struct OSXMLReader* pReader);
00343
00354 EXTXMLMETHOD int rtXmlRdGetTagName (struct OSXMLReader* pReader,
00355 OSXMLStrFragment* localName,
00356 OSINT16* namespaceIndex);
00357
00366 EXTXMLMETHOD int rtXmlRdGetAttributeCount (struct OSXMLReader* pReader);
00367
00378 EXTXMLMETHOD int rtXmlRdGetAttributeName (struct OSXMLReader* pReader,
00379 OSXMLNameFragments* pAttr,
00380 OSINT16* pNsidx,
00381 size_t index);
00382
00392 EXTXMLMETHOD int rtXmlRdSelectAttribute (struct OSXMLReader* pReader, size_t index);
00393
00404 EXTXMLMETHOD OSINT32 rtXmlRdGetCurrentLevel (struct OSXMLReader* pReader);
00405
00420 EXTXMLMETHOD int rtXmlRdNextEvent (struct OSXMLReader* pReader,
00421 OSUINT32 eventMask,
00422 OSINT32 maxLevel,
00423 OSXMLEvent* pLastEvent);
00424
00430 EXTXMLMETHOD OSXMLDataMode rtXmlRdGetDataMode (struct OSXMLReader* pReader);
00431
00438 EXTXMLMETHOD int rtXmlRdMarkLastEventDone (struct OSXMLReader* pReader);
00439
00446 EXTXMLMETHOD int rtXmlRdMarkLastEventActive (struct OSXMLReader* pReader);
00447
00451 EXTXMLMETHOD void rtXmlRdResetXmlReader (struct OSXMLReader* pReader);
00452
00453 EXTXMLMETHOD void rtXmlRdMarkPos (struct OSXMLReader* pReader);
00454 EXTXMLMETHOD void rtXmlRdRewindToMarkedPos (struct OSXMLReader* pReader);
00455 EXTXMLMETHOD void rtXmlRdResetMarkedPos (struct OSXMLReader* pReader);
00456
00457 EXTXMLMETHOD int rtXmlRdGetXSITypeAttr (struct OSXMLReader* pReader,
00458 const OSUTF8CHAR** ppAttrValue,
00459 OSINT16* nsidx, size_t* pLocalOffs);
00460
00464 EXTXMLMETHOD OSBOOL rtXmlRdIsEmpty (struct OSXMLReader* pReader);
00465
00466 EXTXMLMETHOD void rtXmlRdGetSourcePosition (struct OSXMLReader* pReader,
00467 OSUINT32* pLine,
00468 OSUINT32* pColumn,
00469 OSUINT32* pByteIndex,
00470 OSBOOL nextPos);
00471
00472 EXTXMLMETHOD void rtXmlRdErrAddSrcPos (struct OSXMLReader* pReader,
00473 OSBOOL nextPos);
00474
00475 EXTXMLMETHOD void rtXmlRdErrAddDataSrcPos (struct OSXMLReader* pReader,
00476 OSXMLDataCtxt* pDataCtxt,
00477 OSUINT32 offset);
00478
00479 #ifdef __cplusplus
00480 }
00481 #endif
00482
00483 #endif
00484