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
00058 class ASN1CBitStrSizeHolder {
00059 public:
00060 virtual ASN1CBitStrSizeHolder* clone () = 0;
00061 virtual OSUINT32 getValue () const = 0;
00062 virtual int setValue (OSUINT32 value) = 0;
00063
00064 virtual ~ASN1CBitStrSizeHolder() {}
00065 } ;
00066
00067 class ASN1CBitStrSizeHolder8 : public ASN1CBitStrSizeHolder {
00068 protected:
00069 OSUINT8& mSize;
00070
00071 public:
00072 ASN1CBitStrSizeHolder8 (OSUINT8& value) : mSize(value) {}
00073 virtual ASN1CBitStrSizeHolder* clone () {
00074 return new ASN1CBitStrSizeHolder8 (mSize);
00075 }
00076 virtual OSUINT32 getValue () const { return mSize; }
00077 virtual int setValue (OSUINT32 value);
00078
00079 virtual ~ASN1CBitStrSizeHolder8() {}
00080
00081 private:
00082 ASN1CBitStrSizeHolder8& operator= (const ASN1CBitStrSizeHolder8&) {
00083 return *this;
00084 }
00085 } ;
00086
00087 class ASN1CBitStrSizeHolder16 : public ASN1CBitStrSizeHolder {
00088 protected:
00089 OSUINT16& mSize;
00090
00091 public:
00092 ASN1CBitStrSizeHolder16 (OSUINT16& value) : mSize(value) {}
00093 virtual ASN1CBitStrSizeHolder* clone () {
00094 return new ASN1CBitStrSizeHolder16 (mSize);
00095 }
00096 virtual OSUINT32 getValue () const { return mSize; }
00097 virtual int setValue (OSUINT32 value);
00098
00099 virtual ~ASN1CBitStrSizeHolder16() {}
00100
00101 private:
00102 ASN1CBitStrSizeHolder16& operator= (const ASN1CBitStrSizeHolder16&) {
00103 return *this;
00104 }
00105 } ;
00106
00107 class ASN1CBitStrSizeHolder32 : public ASN1CBitStrSizeHolder {
00108 protected:
00109 OSUINT32& mSize;
00110
00111 public:
00112 ASN1CBitStrSizeHolder32 (OSUINT32& value) : mSize(value) {}
00113 virtual ASN1CBitStrSizeHolder* clone () {
00114 return new ASN1CBitStrSizeHolder32 (mSize);
00115 }
00116 virtual OSUINT32 getValue () const { return mSize; }
00117 virtual int setValue (OSUINT32 value);
00118
00119 virtual ~ASN1CBitStrSizeHolder32() {}
00120
00121 private:
00122 ASN1CBitStrSizeHolder32& operator= (const ASN1CBitStrSizeHolder32&) {
00123 return *this;
00124 }
00125 } ;
00126
00127 class EXTRTCLASS ASN1CBitStr : public ASN1CType {
00128 private:
00129 OSUINT32 _numbits;
00130 OSOCTET* _units;
00131
00132 protected:
00133 OSOCTET** mpUnits;
00134 OSUINT32 mMaxNumBits;
00135 ASN1CBitStrSizeHolder* mpNumBits;
00136 OSUINT32 mUnitsUsed;
00137 OSUINT32 mUnitsAllocated;
00138 OSBOOL mDynAlloc;
00139
00140 private:
00141 OSOCTET* allocateMemory (OSUINT32 sz);
00142 OSOCTET* reallocateMemory
00143 (OSOCTET* old, OSUINT32 oldBufSz, OSUINT32 newBufSz);
00144 void freeMemory (OSOCTET* mem);
00145
00146
00147
00148
00149
00150
00151 void recalculateUnitsUsed();
00152
00153
00154
00155
00156
00157 int checkCapacity (OSUINT32 unitsRequired);
00158
00159
00160
00161
00162
00163 OSOCTET getBits (OSUINT32 j);
00164
00165 void privateInit (OSUINT32 nbits);
00166 void privateInit (OSOCTET* bitStr, OSUINT32 maxNumbits_);
00167 void privateInit (ASN1TDynBitStr& bitStr);
00168
00169 protected:
00170
00171
00172
00173
00174 EXTRTMETHOD ASN1CBitStr (OSRTMessageBufferIF& msgBuf);
00175
00176
00177
00178
00179
00180 EXTRTMETHOD ASN1CBitStr();
00181
00182
00183
00184
00185
00186
00187 EXTRTMETHOD ASN1CBitStr (OSRTContext& ctxt);
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197 EXTRTMETHOD ASN1CBitStr
00198 (OSOCTET* pBits, OSUINT32& numbits, OSUINT32 maxNumbits);
00199
00200 EXTRTMETHOD ASN1CBitStr
00201 (OSOCTET* pBits, OSUINT8& numbits, OSUINT32 maxNumbits);
00202
00203 EXTRTMETHOD ASN1CBitStr
00204 (OSOCTET* pBits, OSUINT16& numbits, OSUINT32 maxNumbits);
00205
00206
00207 EXTRTMETHOD ASN1CBitStr (OSOCTET* pBits, OSUINT32 maxNumbits);
00208
00209
00210
00211
00212
00213
00214
00215 EXTRTMETHOD ASN1CBitStr (ASN1TDynBitStr& bitStr);
00216
00217 void initBase (OSOCTET* pBits, OSUINT32 numbits, OSUINT32 maxNumbits);
00218
00219 EXTRTMETHOD void init
00220 (OSOCTET* pBits, OSUINT32& numbits, OSUINT32 maxNumbits);
00221
00222 EXTRTMETHOD void init
00223 (OSOCTET* pBits, OSUINT8& numbits, OSUINT32 maxNumbits);
00224
00225 EXTRTMETHOD void init
00226 (OSOCTET* pBits, OSUINT16& numbits, OSUINT32 maxNumbits);
00227
00228 EXTRTMETHOD void init (ASN1TDynBitStr& bitStr);
00229
00230 public:
00240 EXTRTMETHOD ASN1CBitStr (OSRTMessageBufferIF& msgbuf, OSUINT32 nbits);
00241
00253 EXTRTMETHOD ASN1CBitStr
00254 (OSRTMessageBufferIF& msgbuf, OSOCTET* bitStr,
00255 OSUINT32& numbits, OSUINT32 maxNumbits_);
00256
00257 EXTRTMETHOD ASN1CBitStr
00258 (OSRTMessageBufferIF& msgbuf, OSOCTET* bitStr,
00259 OSUINT8& numbits, OSUINT32 maxNumbits_);
00260
00261 EXTRTMETHOD ASN1CBitStr
00262 (OSRTMessageBufferIF& msgbuf, OSOCTET* bitStr,
00263 OSUINT16& numbits, OSUINT32 maxNumbits_);
00264
00265 EXTRTMETHOD ASN1CBitStr
00266 (OSRTMessageBufferIF& msgbuf, OSOCTET* bitStr, OSUINT32 maxNumbits_);
00267
00268
00269
00270
00271
00272
00273 EXTRTMETHOD ASN1CBitStr
00274 (OSRTMessageBufferIF& msgBuf, ASN1TDynBitStr& bitStr);
00275
00276
00277
00278
00279
00280 EXTRTMETHOD ASN1CBitStr (OSRTContext& ctxt, OSUINT32 nbits);
00281
00282
00283
00284
00285
00286
00287
00288
00289 EXTRTMETHOD ASN1CBitStr
00290 (OSRTContext& ctxt, OSOCTET* bitStr,
00291 OSUINT32& octsNumbits, OSUINT32 maxNumbits_);
00292
00293 EXTRTMETHOD ASN1CBitStr
00294 (OSRTContext& ctxt, OSOCTET* bitStr,
00295 OSUINT8& octsNumbits, OSUINT32 maxNumbits_);
00296
00297 EXTRTMETHOD ASN1CBitStr
00298 (OSRTContext& ctxt, OSOCTET* bitStr,
00299 OSUINT16& octsNumbits, OSUINT32 maxNumbits_);
00300
00301 EXTRTMETHOD ASN1CBitStr
00302 (OSRTContext& ctxt, OSOCTET* bitStr, OSUINT32 maxNumbits_);
00303
00304
00305
00306
00307
00308
00309 EXTRTMETHOD ASN1CBitStr (OSRTContext& ctxt, ASN1TDynBitStr& bitStr);
00310
00311
00312
00313
00314 EXTRTMETHOD ASN1CBitStr (const ASN1CBitStr& bitStr);
00315
00316
00317
00318
00319 EXTRTMETHOD ASN1CBitStr (const ASN1CBitStr& bitStr, OSBOOL extendable);
00320
00321
00322 EXTRTMETHOD ~ASN1CBitStr();
00323
00335
00336
00337
00338
00339
00340
00341
00342 EXTRTMETHOD int set (OSUINT32 bitIndex);
00343
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369 EXTRTMETHOD int set (OSUINT32 fromIndex, OSUINT32 toIndex);
00370
00383
00384
00385
00386 inline int change (OSUINT32 bitIndex, OSBOOL value) {
00387 return (value) ? set (bitIndex) : clear (bitIndex);
00388 }
00389
00402
00403
00404
00405
00406
00407
00408
00409 EXTRTMETHOD int clear (OSUINT32 bitIndex);
00410
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436 EXTRTMETHOD int clear (OSUINT32 fromIndex, OSUINT32 toIndex);
00437
00446
00447
00448
00449 EXTRTMETHOD void clear();
00450
00466
00467
00468
00469
00470
00471
00472
00473
00474 EXTRTMETHOD int invert (OSUINT32 bitIndex);
00475
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505 EXTRTMETHOD int invert(OSUINT32 fromIndex, OSUINT32 toIndex);
00506
00518
00519
00520
00521 EXTRTMETHOD OSBOOL get(OSUINT32 bitIndex);
00522
00528
00529
00530
00531 inline OSBOOL isSet(OSUINT32 bitIndex) { return get(bitIndex); }
00532
00541
00542
00543
00544
00545 inline OSBOOL isEmpty() { return (mUnitsUsed == 0); }
00546
00555
00556
00557
00558
00559 EXTRTMETHOD OSUINT32 size() const;
00560
00572
00573
00574
00575
00576
00577 EXTRTMETHOD OSUINT32 length() const;
00578
00588
00589
00590
00591
00592 EXTRTMETHOD OSUINT32 cardinality() const;
00593
00607
00608
00609
00610 EXTRTMETHOD int getBytes (OSOCTET* pBuf, OSUINT32 bufSz);
00611
00637 EXTRTMETHOD int get
00638 (OSUINT32 fromIndex, OSUINT32 toIndex, OSOCTET* pBuf, OSUINT32 bufSz);
00639
00657 EXTRTMETHOD int doAnd (const OSOCTET* pOctstr, OSUINT32 octsNumbits);
00658
00670 inline int doAnd (const ASN1TDynBitStr& bitStr) {
00671 return doAnd(bitStr.data, bitStr.numbits);
00672 }
00673
00684 inline int doAnd(const ASN1CBitStr& bitStr) {
00685 return doAnd(*bitStr.mpUnits, bitStr.length());
00686 }
00687
00688
00705 EXTRTMETHOD int doOr(const OSOCTET* pOctstr, OSUINT32 octsNumbits);
00706
00718 inline int doOr(const ASN1TDynBitStr& bitStr) {
00719 return doOr(bitStr.data, bitStr.numbits);
00720 }
00721
00732 inline int doOr(const ASN1CBitStr& bitStr) {
00733 return doOr(*bitStr.mpUnits, bitStr.length());
00734 }
00735
00752 EXTRTMETHOD int doXor(const OSOCTET* pOctstr, OSUINT32 octsNumbits);
00753
00765 inline int doXor(const ASN1TDynBitStr& bitStr) {
00766 return doXor(bitStr.data, bitStr.numbits);
00767 }
00768
00779 inline int doXor(const ASN1CBitStr& bitStr) {
00780 return doXor(*bitStr.mpUnits, bitStr.length());
00781 }
00782
00797
00798
00799
00800
00801
00802
00803
00804
00805
00806 EXTRTMETHOD int doAndNot(const OSOCTET* pOctstr, OSUINT32 octsNumbits);
00807
00822 inline int doAndNot(const ASN1TDynBitStr& bitStr) {
00823 return doAndNot(bitStr.data, bitStr.numbits);
00824 }
00825
00839 inline int doAndNot(const ASN1CBitStr& bitStr) {
00840 return doAndNot(*bitStr.mpUnits, bitStr.length());
00841 }
00842
00856
00857
00858
00859 EXTRTMETHOD int shiftLeft(OSUINT32 shift);
00860
00874
00875
00876
00877 EXTRTMETHOD int shiftRight(OSUINT32 shift);
00878
00885
00886
00887
00888 EXTRTMETHOD OSUINT32 unusedBitsInLastUnit();
00889
00900
00901
00902
00903
00904
00905 EXTRTMETHOD operator ASN1TDynBitStr();
00906
00916
00917
00918
00919
00920 EXTRTMETHOD operator ASN1TDynBitStr*();
00921 } ;
00922 #else
00923 typedef class _ASN1CBitStr : public ASN1CType {
00924 public:
00925 _ASN1CBitStr (OSRTMessageBufferIF& msgBuf, OSUINT32 nbits) :
00926 ASN1CType (msgBuf) {}
00927
00928 _ASN1CBitStr (OSRTMessageBufferIF& msgBuf, OSOCTET* bitStr,
00929 OSUINT32& octsNumbits, OSUINT32 maxNumbits_) :
00930 ASN1CType (msgBuf) {}
00931
00932 _ASN1CBitStr (OSRTMessageBufferIF& msgBuf, ASN1TDynBitStr& bitStr) :
00933 ASN1CType (msgBuf) {}
00934 } ASN1CBitStr;
00935 #endif // _NO_UTILS_CLASSES
00936 #endif // _ASN1CBITSTR_H_
00937