00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00028 #ifndef _ASN1XERCPPTYPES_H_
00029 #define _ASN1XERCPPTYPES_H_
00030
00031 #include "rtxmlsrc/rtSaxCppParser.h"
00032 #include "rtsrc/asn1CppTypes.h"
00033 #include "rtxersrc/asn1xer.h"
00034 #include "rtxsrc/rtxMemBuf.h"
00035
00036 class OSRTInputStream;
00037
00046
00047
00058 class EXTERNXER ASN1XERMessageBuffer : public ASN1MessageBuffer {
00059 protected:
00068 ASN1XERMessageBuffer (Type bufferType);
00069
00079 ASN1XERMessageBuffer (Type bufferType, OSRTContext* pContext) :
00080 ASN1MessageBuffer (bufferType, pContext) {}
00081
00082 public:
00083 } ;
00084
00085
00093 class EXTERNXER ASN1XEREncodeBuffer : public ASN1XERMessageBuffer {
00094 public:
00099 ASN1XEREncodeBuffer ();
00100
00107 ASN1XEREncodeBuffer (OSBOOL canonical);
00108
00117 ASN1XEREncodeBuffer (OSBOOL canonical, OSRTContext* pContext,
00118 size_t initBufSize = 0);
00119
00128 ASN1XEREncodeBuffer (OSOCTET* pMsgBuf, size_t msgBufLen);
00129
00142 ASN1XEREncodeBuffer (OSOCTET* pMsgBuf, size_t msgBufLen,
00143 OSBOOL canonical, OSBOOL openType = FALSE);
00150 inline size_t getMsgLen () {
00151 return (getCtxtPtr()->buffer.byteIndex);
00152 }
00153
00165 int init ();
00166
00176 virtual OSBOOL isA (Type bufferType) {
00177 return bufferType == XEREncode;
00178 }
00184 inline void setCanonical() { rtxCtxtSetFlag (getCtxtPtr(), ASN1CANXER); }
00185
00193 inline void setOpenType () { rtxCtxtSetFlag (getCtxtPtr(), ASN1OPENTYPE); }
00194
00205 long write (const char* filename);
00206
00215 long write (FILE* fp);
00216 } ;
00217
00224 class EXTERNXER ASN1XERShdMemHpEncBuf : public ASN1XEREncodeBuffer {
00225 protected:
00226 void* mpSavedMemHeap;
00227
00228 public:
00237 ASN1XERShdMemHpEncBuf (OSBOOL canonical, OSRTContext* pContext,
00238 size_t initBufSize = 0);
00239
00246 ASN1XERShdMemHpEncBuf (OSBOOL canonical);
00247
00251 ~ASN1XERShdMemHpEncBuf();
00252 } ;
00253
00254
00262 class EXTERNXER ASN1XERSAXDecodeHandler : public OSXMLDefaultHandlerIF
00263 {
00264 protected:
00265 ASN1XERState mCurrState;
00266 int mCurrElemID;
00267 int mLevel, mStartLevel;
00268 const char* mpTypeName;
00269 struct ErrorInfo {
00270 int stat;
00271 const char* file;
00272 int line;
00273 } errorInfo;
00274 public:
00275
00279 ASN1XERSAXDecodeHandler () :
00280 mCurrState(XERINIT), mCurrElemID(0), mLevel(0), mpTypeName(0) {}
00281
00282 virtual int startElement
00283 (const OSUTF8CHAR* const uri,
00284 const OSUTF8CHAR* const localname,
00285 const OSUTF8CHAR* const qname,
00286 const OSUTF8CHAR* const* attrs);
00287
00288 virtual int characters
00289 (const OSUTF8CHAR* const chars, unsigned int length);
00290
00291 virtual int endElement
00292 (const OSUTF8CHAR* const uri,
00293 const OSUTF8CHAR* const localname,
00294 const OSUTF8CHAR* const qname);
00295
00296 virtual void startDocument();
00297 virtual void endDocument ();
00298
00299
00300 virtual void resetErrorInfo ();
00301 virtual void setErrorInfo (int status, const char* file = 0, int line = 0);
00302 virtual int getErrorInfo (int* status, const char** file, int* line);
00303
00304
00305
00306
00307
00308
00309
00310
00318 inline ASN1XERState getState() { return mCurrState; }
00319 virtual int finalize() { return 0; }
00320 OSCTXT* finalizeMemBuf (OSRTMessageBufferIF* msgBuf, OSRTMEMBUF& memBuf);
00321 virtual void init (int level = 0) {
00322 mCurrState = XERINIT; mStartLevel = mLevel = level;
00323 }
00324
00332 inline OSBOOL isComplete () { return mLevel == mStartLevel; }
00333 void setTypeName (const char* typeName) {
00334 mpTypeName = typeName;
00335 }
00336 } ;
00337
00338
00339
00349 class EXTERNXER ASN1XERDecodeBuffer : public ASN1XERMessageBuffer {
00350 protected:
00351
00357 union {
00361 const char* fileName;
00366 OSRTInputStreamIF* pInputStream;
00367
00371 struct {
00375 const OSOCTET* pMemBuf;
00376
00380 OSSIZE bufSize;
00381 } memBuf;
00382 } mInput;
00383
00384 enum {
00385 INPUT_FILE,
00386 INPUT_STREAM,
00387 INPUT_STREAM_ATTACHED,
00388 INPUT_MEMORY
00389 } mInputId;
00390 public:
00391
00401 ASN1XERDecodeBuffer (const char* xmlFile);
00402
00415 ASN1XERDecodeBuffer (const OSOCTET* msgbuf,
00416 size_t numocts,
00417 OSBOOL openType = FALSE);
00418
00428 ASN1XERDecodeBuffer (OSRTInputStreamIF& inputStream,
00429 OSBOOL openType = FALSE);
00430
00431 ~ASN1XERDecodeBuffer ();
00432
00442 virtual int decodeXML (OSXMLReaderClass* pReader);
00443
00451 inline const char* getXmlFileName() {
00452 return (mInputId == INPUT_FILE) ? mInput.fileName : 0;
00453 }
00454
00466 virtual int initBuffer (OSRTMEMBUF& membuf) {
00467 return ASN1XERMessageBuffer::initBuffer (membuf);
00468 }
00469
00480 virtual int initBuffer (const OSUTF8CHAR* str);
00481
00492 virtual int initBuffer (OSUNICHAR* str) { return RTERR_NOTSUPP; }
00493
00494 virtual OSBOOL isA (Type bufferType) {
00495 return bufferType == XERDecode;
00496 }
00497
00498 inline void setOpenType () { rtxCtxtSetFlag (getCtxtPtr(), ASN1OPENTYPE); }
00499 } ;
00500
00510 #endif // _ASN1XERCPPTYPES_H_