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 #ifndef _ASN1CBITSTR_H_
00026 #define _ASN1CBITSTR_H_
00027
00028 #include "rtsrc/asn1CppTypes.h"
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 #ifndef _NO_UTILS_CLASSES
00048
00054 class ASN1CBitStrSizeHolder {
00055 public:
00056 virtual ASN1CBitStrSizeHolder* clone () = 0;
00057 virtual OSUINT32 getValue () const = 0;
00058 virtual int setValue (OSUINT32 value) = 0;
00059
00060 virtual ~ASN1CBitStrSizeHolder() {}
00061 } ;
00062
00066 class ASN1CBitStrSizeHolder8 : public ASN1CBitStrSizeHolder {
00067 protected:
00068 OSUINT8& mSize;
00069
00070 public:
00071 ASN1CBitStrSizeHolder8 (OSUINT8& value) : mSize(value) {}
00072 virtual ASN1CBitStrSizeHolder* clone () {
00073 return new ASN1CBitStrSizeHolder8 (mSize);
00074 }
00075 virtual OSUINT32 getValue () const { return mSize; }
00076 virtual int setValue (OSUINT32 value);
00077
00078 virtual ~ASN1CBitStrSizeHolder8() {}
00079
00080 private:
00081 ASN1CBitStrSizeHolder8& operator= (const ASN1CBitStrSizeHolder8&) {
00082 return *this;
00083 }
00084 } ;
00085
00089 class ASN1CBitStrSizeHolder16 : public ASN1CBitStrSizeHolder {
00090 protected:
00091 OSUINT16& mSize;
00092
00093 public:
00094 ASN1CBitStrSizeHolder16 (OSUINT16& value) : mSize(value) {}
00095 virtual ASN1CBitStrSizeHolder* clone () {
00096 return new ASN1CBitStrSizeHolder16 (mSize);
00097 }
00098 virtual OSUINT32 getValue () const { return mSize; }
00099 virtual int setValue (OSUINT32 value);
00100
00101 virtual ~ASN1CBitStrSizeHolder16() {}
00102
00103 private:
00104 ASN1CBitStrSizeHolder16& operator= (const ASN1CBitStrSizeHolder16&) {
00105 return *this;
00106 }
00107 } ;
00108
00112 class ASN1CBitStrSizeHolder32 : public ASN1CBitStrSizeHolder {
00113 protected:
00114 OSUINT32& mSize;
00115
00116 public:
00117 ASN1CBitStrSizeHolder32 (OSUINT32& value) : mSize(value) {}
00118 virtual ASN1CBitStrSizeHolder* clone () {
00119 return new ASN1CBitStrSizeHolder32 (mSize);
00120 }
00121 virtual OSUINT32 getValue () const { return mSize; }
00122 virtual int setValue (OSUINT32 value);
00123
00124 virtual ~ASN1CBitStrSizeHolder32() {}
00125
00126 private:
00127 ASN1CBitStrSizeHolder32& operator= (const ASN1CBitStrSizeHolder32&) {
00128 return *this;
00129 }
00130 } ;
00131
00141 class EXTRTCLASS ASN1CBitStr : public ASN1CType {
00142 private:
00143 OSUINT32 _numbits;
00144 OSOCTET* _units;
00145
00146 protected:
00147 OSOCTET** mpUnits;
00148 OSUINT32 mMaxNumBits;
00149 ASN1CBitStrSizeHolder* mpNumBits;
00150 OSUINT32 mUnitsUsed;
00151 OSUINT32 mUnitsAllocated;
00152 OSBOOL mDynAlloc;
00153
00154 private:
00155 OSOCTET* allocateMemory (OSUINT32 sz);
00156 OSOCTET* reallocateMemory
00157 (OSOCTET* old, OSUINT32 oldBufSz, OSUINT32 newBufSz);
00158 void freeMemory (OSOCTET* mem);
00159
00160
00161
00162
00163
00164
00165 void recalculateUnitsUsed();
00166
00167
00168
00169
00170
00171 int checkCapacity (OSUINT32 unitsRequired);
00172
00173
00174
00175
00176
00177 OSOCTET getBits (OSUINT32 j);
00178
00179 void privateInit (OSUINT32 nbits);
00180 void privateInit (OSOCTET* bitStr, OSUINT32 maxNumbits_);
00181 void privateInit (ASN1TDynBitStr& bitStr);
00182
00183 protected:
00184
00185
00186
00187
00188 EXTRTMETHOD ASN1CBitStr (OSRTMessageBufferIF& msgBuf);
00189
00190
00191
00192
00193
00194 EXTRTMETHOD ASN1CBitStr();
00195
00196
00197
00198
00199
00200
00201 EXTRTMETHOD ASN1CBitStr (OSRTContext& ctxt);
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211 EXTRTMETHOD ASN1CBitStr
00212 (OSOCTET* pBits, OSUINT32& numbits, OSUINT32 maxNumbits);
00213
00214 EXTRTMETHOD ASN1CBitStr
00215 (OSOCTET* pBits, OSUINT8& numbits, OSUINT32 maxNumbits);
00216
00217 EXTRTMETHOD ASN1CBitStr
00218 (OSOCTET* pBits, OSUINT16& numbits, OSUINT32 maxNumbits);
00219
00220
00221 EXTRTMETHOD ASN1CBitStr (OSOCTET* pBits, OSUINT32 maxNumbits);
00222
00223
00224
00225
00226
00227
00228
00229 EXTRTMETHOD ASN1CBitStr (ASN1TDynBitStr& bitStr);
00230
00231 void initBase (OSOCTET* pBits, OSUINT32 numbits, OSUINT32 maxNumbits);
00232
00233 EXTRTMETHOD void init
00234 (OSOCTET* pBits, OSUINT32& numbits, OSUINT32 maxNumbits);
00235
00236 EXTRTMETHOD void init
00237 (OSOCTET* pBits, OSUINT8& numbits, OSUINT32 maxNumbits);
00238
00239 EXTRTMETHOD void init
00240 (OSOCTET* pBits, OSUINT16& numbits, OSUINT32 maxNumbits);
00241
00242 EXTRTMETHOD void init (ASN1TDynBitStr& bitStr);
00243
00244 public:
00254 EXTRTMETHOD ASN1CBitStr (OSRTMessageBufferIF& msgbuf, OSUINT32 nbits);
00255
00267 EXTRTMETHOD ASN1CBitStr
00268 (OSRTMessageBufferIF& msgbuf, OSOCTET* bitStr,
00269 OSUINT32& numbits, OSUINT32 maxNumbits_);
00270
00271 EXTRTMETHOD ASN1CBitStr
00272 (OSRTMessageBufferIF& msgbuf, OSOCTET* bitStr,
00273 OSUINT8& numbits, OSUINT32 maxNumbits_);
00274
00275 EXTRTMETHOD ASN1CBitStr
00276 (OSRTMessageBufferIF& msgbuf, OSOCTET* bitStr,
00277 OSUINT16& numbits, OSUINT32 maxNumbits_);
00278
00279 EXTRTMETHOD ASN1CBitStr
00280 (OSRTMessageBufferIF& msgbuf, OSOCTET* bitStr, OSUINT32 maxNumbits_);
00281
00282
00283
00284
00285
00286
00287 EXTRTMETHOD ASN1CBitStr
00288 (OSRTMessageBufferIF& msgBuf, ASN1TDynBitStr& bitStr);
00289
00290
00291
00292
00293
00294 EXTRTMETHOD ASN1CBitStr (OSRTContext& ctxt, OSUINT32 nbits);
00295
00296
00297
00298
00299
00300
00301
00302
00303 EXTRTMETHOD ASN1CBitStr
00304 (OSRTContext& ctxt, OSOCTET* bitStr,
00305 OSUINT32& octsNumbits, OSUINT32 maxNumbits_);
00306
00307 EXTRTMETHOD ASN1CBitStr
00308 (OSRTContext& ctxt, OSOCTET* bitStr,
00309 OSUINT8& octsNumbits, OSUINT32 maxNumbits_);
00310
00311 EXTRTMETHOD ASN1CBitStr
00312 (OSRTContext& ctxt, OSOCTET* bitStr,
00313 OSUINT16& octsNumbits, OSUINT32 maxNumbits_);
00314
00315 EXTRTMETHOD ASN1CBitStr
00316 (OSRTContext& ctxt, OSOCTET* bitStr, OSUINT32 maxNumbits_);
00317
00318
00319
00320
00321
00322
00323 EXTRTMETHOD ASN1CBitStr (OSRTContext& ctxt, ASN1TDynBitStr& bitStr);
00324
00325
00326
00327
00328 EXTRTMETHOD ASN1CBitStr (const ASN1CBitStr& bitStr);
00329
00330
00331
00332
00333 EXTRTMETHOD ASN1CBitStr (const ASN1CBitStr& bitStr, OSBOOL extendable);
00334
00335
00336 EXTRTMETHOD ~ASN1CBitStr();
00337
00349
00350
00351
00352
00353
00354
00355
00356 EXTRTMETHOD int set (OSUINT32 bitIndex);
00357
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383 EXTRTMETHOD int set (OSUINT32 fromIndex, OSUINT32 toIndex);
00384
00397
00398
00399
00400 inline int change (OSUINT32 bitIndex, OSBOOL value) {
00401 return (value) ? set (bitIndex) : clear (bitIndex);
00402 }
00403
00416
00417
00418
00419
00420
00421
00422
00423 EXTRTMETHOD int clear (OSUINT32 bitIndex);
00424
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450 EXTRTMETHOD int clear (OSUINT32 fromIndex, OSUINT32 toIndex);
00451
00460
00461
00462
00463 EXTRTMETHOD void clear();
00464
00480
00481
00482
00483
00484
00485
00486
00487
00488 EXTRTMETHOD int invert (OSUINT32 bitIndex);
00489
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519 EXTRTMETHOD int invert(OSUINT32 fromIndex, OSUINT32 toIndex);
00520
00532
00533
00534
00535 EXTRTMETHOD OSBOOL get(OSUINT32 bitIndex);
00536
00542
00543
00544
00545 inline OSBOOL isSet(OSUINT32 bitIndex) { return get(bitIndex); }
00546
00555
00556
00557
00558
00559 inline OSBOOL isEmpty() { return (mUnitsUsed == 0); }
00560
00569
00570
00571
00572
00573 EXTRTMETHOD OSUINT32 size() const;
00574
00586
00587
00588
00589
00590
00591 EXTRTMETHOD OSUINT32 length() const;
00592
00602
00603
00604
00605
00606 EXTRTMETHOD OSUINT32 cardinality() const;
00607
00621
00622
00623
00624 EXTRTMETHOD int getBytes (OSOCTET* pBuf, OSUINT32 bufSz);
00625
00651 EXTRTMETHOD int get
00652 (OSUINT32 fromIndex, OSUINT32 toIndex, OSOCTET* pBuf, OSUINT32 bufSz);
00653
00671 EXTRTMETHOD int doAnd (const OSOCTET* pOctstr, OSUINT32 octsNumbits);
00672
00684 inline int doAnd (const ASN1TDynBitStr& bitStr) {
00685 return doAnd(bitStr.data, bitStr.numbits);
00686 }
00687
00698 inline int doAnd(const ASN1CBitStr& bitStr) {
00699 return doAnd(*bitStr.mpUnits, bitStr.length());
00700 }
00701
00702
00719 EXTRTMETHOD int doOr(const OSOCTET* pOctstr, OSUINT32 octsNumbits);
00720
00732 inline int doOr(const ASN1TDynBitStr& bitStr) {
00733 return doOr(bitStr.data, bitStr.numbits);
00734 }
00735
00746 inline int doOr(const ASN1CBitStr& bitStr) {
00747 return doOr(*bitStr.mpUnits, bitStr.length());
00748 }
00749
00766 EXTRTMETHOD int doXor(const OSOCTET* pOctstr, OSUINT32 octsNumbits);
00767
00779 inline int doXor(const ASN1TDynBitStr& bitStr) {
00780 return doXor(bitStr.data, bitStr.numbits);
00781 }
00782
00793 inline int doXor(const ASN1CBitStr& bitStr) {
00794 return doXor(*bitStr.mpUnits, bitStr.length());
00795 }
00796
00811
00812
00813
00814
00815
00816
00817
00818
00819
00820 EXTRTMETHOD int doAndNot(const OSOCTET* pOctstr, OSUINT32 octsNumbits);
00821
00836 inline int doAndNot(const ASN1TDynBitStr& bitStr) {
00837 return doAndNot(bitStr.data, bitStr.numbits);
00838 }
00839
00853 inline int doAndNot(const ASN1CBitStr& bitStr) {
00854 return doAndNot(*bitStr.mpUnits, bitStr.length());
00855 }
00856
00870
00871
00872
00873 EXTRTMETHOD int shiftLeft(OSUINT32 shift);
00874
00888
00889
00890
00891 EXTRTMETHOD int shiftRight(OSUINT32 shift);
00892
00899
00900
00901
00902 EXTRTMETHOD OSUINT32 unusedBitsInLastUnit();
00903
00914
00915
00916
00917
00918
00919 EXTRTMETHOD operator ASN1TDynBitStr();
00920
00930
00931
00932
00933
00934 EXTRTMETHOD operator ASN1TDynBitStr*();
00935 } ;
00936 #else
00937 typedef class _ASN1CBitStr : public ASN1CType {
00938 public:
00939 _ASN1CBitStr (OSRTMessageBufferIF& msgBuf, OSUINT32 nbits) :
00940 ASN1CType (msgBuf) {}
00941
00942 _ASN1CBitStr (OSRTMessageBufferIF& msgBuf, OSOCTET* bitStr,
00943 OSUINT32& octsNumbits, OSUINT32 maxNumbits_) :
00944 ASN1CType (msgBuf) {}
00945
00946 _ASN1CBitStr (OSRTMessageBufferIF& msgBuf, ASN1TDynBitStr& bitStr) :
00947 ASN1CType (msgBuf) {}
00948 } ASN1CBitStr;
00949 #endif // _NO_UTILS_CLASSES
00950 #endif // _ASN1CBITSTR_H_
00951