00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00030
00031
00036 #ifndef _ASN1XERCPPTYPES_H_
00037 #define _ASN1XERCPPTYPES_H_
00038
00039 #include "rtxmlsrc/rtSaxCppParser.h"
00040 #include "rtsrc/asn1CppTypes.h"
00041 #include "rtxersrc/asn1xer.h"
00042 #include "rtxsrc/rtxMemBuf.h"
00043
00044 class OSRTInputStream;
00045
00054
00055
00066 class EXTERNXER ASN1XERMessageBuffer : public ASN1MessageBuffer {
00067 protected:
00076 ASN1XERMessageBuffer (Type bufferType);
00077
00087 ASN1XERMessageBuffer (Type bufferType, OSRTContext* pContext) :
00088 ASN1MessageBuffer (bufferType, pContext) {}
00089
00090 public:
00091 } ;
00092
00093
00101 class EXTERNXER ASN1XEREncodeBuffer : public ASN1XERMessageBuffer {
00102 public:
00107 ASN1XEREncodeBuffer ();
00108
00115 ASN1XEREncodeBuffer (OSBOOL canonical);
00116
00125 ASN1XEREncodeBuffer (OSBOOL canonical, OSRTContext* pContext,
00126 size_t initBufSize = 0);
00127
00136 ASN1XEREncodeBuffer (OSOCTET* pMsgBuf, size_t msgBufLen);
00137
00150 ASN1XEREncodeBuffer (OSOCTET* pMsgBuf, size_t msgBufLen,
00151 OSBOOL canonical, OSBOOL openType = FALSE);
00158 inline size_t getMsgLen () {
00159 return (getCtxtPtr()->buffer.byteIndex);
00160 }
00161
00173 int init ();
00174
00184 virtual OSBOOL isA (Type bufferType) {
00185 return bufferType == XEREncode;
00186 }
00192 inline void setCanonical() { rtxCtxtSetFlag (getCtxtPtr(), ASN1CANXER); }
00193
00201 inline void setOpenType () { rtxCtxtSetFlag (getCtxtPtr(), ASN1OPENTYPE); }
00202
00213 long write (const char* filename);
00214
00223 long write (FILE* fp);
00224 } ;
00225
00232 class EXTERNXER ASN1XERShdMemHpEncBuf : public ASN1XEREncodeBuffer {
00233 protected:
00234 void* mpSavedMemHeap;
00235
00236 public:
00245 ASN1XERShdMemHpEncBuf (OSBOOL canonical, OSRTContext* pContext,
00246 size_t initBufSize = 0);
00247
00254 ASN1XERShdMemHpEncBuf (OSBOOL canonical);
00255
00259 ~ASN1XERShdMemHpEncBuf();
00260 } ;
00261
00262
00270 class EXTERNXER ASN1XERSAXDecodeHandler : public OSXMLDefaultHandlerIF
00271 {
00272 protected:
00273 ASN1XERState mCurrState;
00274 int mCurrElemID;
00275 int mLevel, mStartLevel;
00276 const char* mpTypeName;
00277 struct ErrorInfo {
00278 int stat;
00279 const char* file;
00280 int line;
00281 } errorInfo;
00282 public:
00283
00287 ASN1XERSAXDecodeHandler () :
00288 mCurrState(XERINIT), mCurrElemID(0), mLevel(0), mpTypeName(0) {}
00289
00290 virtual int startElement
00291 (const OSUTF8CHAR* const uri,
00292 const OSUTF8CHAR* const localname,
00293 const OSUTF8CHAR* const qname,
00294 const OSUTF8CHAR* const* attrs);
00295
00296 virtual int characters
00297 (const OSUTF8CHAR* const chars, unsigned int length);
00298
00299 virtual int endElement
00300 (const OSUTF8CHAR* const uri,
00301 const OSUTF8CHAR* const localname,
00302 const OSUTF8CHAR* const qname);
00303
00304 virtual void startDocument();
00305 virtual void endDocument ();
00306
00307
00308 virtual void resetErrorInfo ();
00309 virtual void setErrorInfo (int status, const char* file = 0, int line = 0);
00310 virtual int getErrorInfo (int* status, const char** file, int* line);
00311
00312
00313
00314
00315
00316
00317
00318
00326 inline ASN1XERState getState() { return mCurrState; }
00327 virtual int finalize() { return 0; }
00328 OSCTXT* finalizeMemBuf (OSRTMessageBufferIF* msgBuf, OSRTMEMBUF& memBuf);
00329 virtual void init (int level = 0) {
00330 mCurrState = XERINIT; mStartLevel = mLevel = level;
00331 }
00332
00340 inline OSBOOL isComplete () { return mLevel == mStartLevel; }
00341 void setTypeName (const char* typeName) {
00342 mpTypeName = typeName;
00343 }
00344 } ;
00345
00346
00347
00357 class EXTERNXER ASN1XERDecodeBuffer : public ASN1XERMessageBuffer {
00358 protected:
00359
00365 union {
00369 const char* fileName;
00374 OSRTInputStreamIF* pInputStream;
00375
00379 struct {
00383 const OSOCTET* pMemBuf;
00384
00388 int bufSize;
00389 } memBuf;
00390 } mInput;
00391
00392 enum {
00393 INPUT_FILE,
00394 INPUT_STREAM,
00395 INPUT_STREAM_ATTACHED,
00396 INPUT_MEMORY
00397 } mInputId;
00398 public:
00399
00409 ASN1XERDecodeBuffer (const char* xmlFile);
00410
00423 ASN1XERDecodeBuffer (const OSOCTET* msgbuf,
00424 size_t numocts,
00425 OSBOOL openType = FALSE);
00426
00436 ASN1XERDecodeBuffer (OSRTInputStreamIF& inputStream,
00437 OSBOOL openType = FALSE);
00438
00439 ~ASN1XERDecodeBuffer ();
00440
00450 virtual int decodeXML (OSXMLReaderClass* pReader);
00451
00459 inline const char* getXmlFileName() {
00460 return (mInputId == INPUT_FILE) ? mInput.fileName : 0;
00461 }
00462
00474 virtual int initBuffer (OSRTMEMBUF& membuf) {
00475 return ASN1XERMessageBuffer::initBuffer (membuf);
00476 }
00477
00488 virtual int initBuffer (const OSUTF8CHAR* str);
00489
00500 virtual int initBuffer (OSUNICHAR* str) { return RTERR_NOTSUPP; }
00501
00502 virtual OSBOOL isA (Type bufferType) {
00503 return bufferType == XERDecode;
00504 }
00505
00506 inline void setOpenType () { rtxCtxtSetFlag (getCtxtPtr(), ASN1OPENTYPE); }
00507 } ;
00508
00518 #endif // _ASN1XERCPPTYPES_H_