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 _ASN1PERCPPTYPES_H_
00029 #define _ASN1PERCPPTYPES_H_
00030
00031 #include "rtpersrc/asn1per.h"
00032 #include "rtsrc/asn1CppTypes.h"
00033 #include "rtxsrc/rtxBitEncode.h"
00034
00035 class OSRTStream;
00036 class OSRTInputStream;
00037 class OSRTOutputStream;
00038
00055
00064 class EXTPERCLASS ASN1PERMessageBuffer : public ASN1MessageBuffer {
00065 protected:
00066
00077 EXTPERMETHOD ASN1PERMessageBuffer (Type bufferType, OSBOOL aligned);
00078
00088 EXTPERMETHOD ASN1PERMessageBuffer (OSRTStream& stream, OSBOOL aligned);
00089
00103 EXTPERMETHOD ASN1PERMessageBuffer
00104 (Type bufferType, OSOCTET* pMsgBuf, size_t msgBufLen, OSBOOL aligned);
00105
00121 EXTPERMETHOD ASN1PERMessageBuffer
00122 (Type bufferType, OSOCTET* pMsgBuf, size_t msgBufLen,
00123 OSBOOL aligned, OSRTContext *pContext);
00124
00125 public:
00126
00133 inline void binDump (const char* varname) {
00134 pu_bindump (getCtxtPtr(), (char*)varname);
00135 }
00136
00143 inline void hexDump () {
00144 pu_hexdump (getCtxtPtr());
00145 }
00146
00152 inline size_t getMsgLen () {
00153 return pu_getMsgLen (getCtxtPtr());
00154 }
00155
00162 inline OSBOOL isAligned () {
00163 return (getCtxtPtr()->buffer.aligned);
00164 }
00165
00175 inline void setTrace (OSBOOL value) {
00176 pu_setTrace (getCtxtPtr(), value);
00177 }
00178
00196 EXTPERMETHOD int setBuffer (const OSOCTET* pMsgBuf, size_t msgBufLen);
00197
00198
00199 inline void BinDump (const char* varname) { binDump (varname); }
00200 inline void HexDump () { hexDump (); }
00201 inline int GetMsgLen () { return (int)getMsgLen (); }
00202 inline void SetTrace (OSBOOL value) { setTrace (value); }
00203 } ;
00204
00205
00212 class EXTPERCLASS ASN1PEREncodeBuffer : public ASN1PERMessageBuffer {
00213 public:
00222 ASN1PEREncodeBuffer (OSBOOL aligned) :
00223 ASN1PERMessageBuffer (PEREncode, aligned) {}
00224
00236 ASN1PEREncodeBuffer (OSOCTET* pMsgBuf, size_t msgBufLen, OSBOOL aligned)
00237 : ASN1PERMessageBuffer (PEREncode, pMsgBuf, msgBufLen, aligned) {}
00238
00239
00253 ASN1PEREncodeBuffer (OSOCTET *pMsgBuf, size_t msgBufLen, OSBOOL aligned,
00254 OSRTContext *pContext) : ASN1PERMessageBuffer (PEREncode, pMsgBuf,
00255 msgBufLen, aligned, pContext) { }
00256
00266 EXTPERMETHOD ASN1PEREncodeBuffer
00267 (OSRTOutputStream& ostream, OSBOOL aligned);
00268
00275 inline int byteAlign () {
00276 return pe_byte_align (getCtxtPtr());
00277 }
00278
00287 inline int encodeBit (OSBOOL value) {
00288 return rtxEncBit (getCtxtPtr(), value);
00289 }
00290
00303 inline int encodeBits
00304 (const OSOCTET* pvalue, size_t nbits, OSUINT32 bitOffset = 0) {
00305 return (0 == bitOffset) ?
00306 rtxEncBitsFromByteArray (getCtxtPtr(), pvalue, nbits) :
00307 rtxCopyBits (getCtxtPtr(), pvalue, nbits, bitOffset);
00308 }
00309
00315 inline size_t getMsgBitCnt () {
00316 return pe_GetMsgBitCnt (getCtxtPtr());
00317 }
00318
00328 virtual EXTPERMETHOD OSOCTET* getMsgCopy ();
00329
00335 virtual EXTPERMETHOD const OSOCTET* getMsgPtr ();
00336
00348 EXTPERMETHOD int init ();
00349
00359 virtual OSBOOL isA (int bufferType) {
00360 return bufferType == PEREncode;
00361 }
00362
00363
00364 inline int GetMsgBitCnt () { return (int)getMsgBitCnt(); }
00365
00366 } ;
00367
00368
00376 class EXTPERCLASS ASN1PERDecodeBuffer : public ASN1PERMessageBuffer {
00377 public:
00385 ASN1PERDecodeBuffer (OSBOOL aligned) :
00386 ASN1PERMessageBuffer (PERDecode, aligned)
00387 {}
00388
00399 ASN1PERDecodeBuffer (const OSOCTET* pMsgBuf,
00400 size_t msgBufLen, OSBOOL aligned) :
00401 ASN1PERMessageBuffer (PERDecode, (OSOCTET*)pMsgBuf, msgBufLen, aligned)
00402 {}
00403
00416 ASN1PERDecodeBuffer (const OSOCTET* pMsgBuf,
00417 size_t msgBufLen, OSBOOL aligned,
00418 OSRTContext *pContext) :
00419 ASN1PERMessageBuffer (PERDecode, (OSOCTET*)pMsgBuf, msgBufLen, aligned,
00420 pContext) {}
00421
00431 EXTPERMETHOD ASN1PERDecodeBuffer (OSRTInputStream& istream, OSBOOL aligned);
00432
00441 EXTPERMETHOD ASN1PERDecodeBuffer (const char* filePath, OSBOOL aligned);
00442
00449 inline int byteAlign () {
00450 return pd_byte_align (getCtxtPtr());
00451 }
00452
00462 virtual OSBOOL isA (int bufferType) {
00463 return bufferType == PERDecode;
00464 }
00465
00475 EXTPERMETHOD int peekByte (OSOCTET& ub);
00476
00486 EXTPERMETHOD int readBinaryFile (const char* filePath);
00487
00499 EXTPERMETHOD int readBytes (OSOCTET* buffer, size_t bufsize, size_t nbytes);
00500
00501 } ;
00502
00503
00510 #endif