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 private:
00081 ASN1CBitStrSizeHolder8& operator= (const ASN1CBitStrSizeHolder8&) {
00082 return *this;
00083 }
00084 } ;
00085
00086 class ASN1CBitStrSizeHolder16 : public ASN1CBitStrSizeHolder {
00087 protected:
00088 OSUINT16& mSize;
00089
00090 public:
00091 ASN1CBitStrSizeHolder16 (OSUINT16& value) : mSize(value) {}
00092 virtual ASN1CBitStrSizeHolder* clone () {
00093 return new ASN1CBitStrSizeHolder16 (mSize);
00094 }
00095 virtual OSUINT32 getValue () const { return mSize; }
00096 virtual int setValue (OSUINT32 value);
00097
00098 virtual ~ASN1CBitStrSizeHolder16() {}
00099 private:
00100 ASN1CBitStrSizeHolder16& operator= (const ASN1CBitStrSizeHolder16&) {
00101 return *this;
00102 }
00103 } ;
00104
00105 class ASN1CBitStrSizeHolder32 : public ASN1CBitStrSizeHolder {
00106 protected:
00107 OSUINT32& mSize;
00108
00109 public:
00110 ASN1CBitStrSizeHolder32 (OSUINT32& value) : mSize(value) {}
00111 virtual ASN1CBitStrSizeHolder* clone () {
00112 return new ASN1CBitStrSizeHolder32 (mSize);
00113 }
00114 virtual OSUINT32 getValue () const { return mSize; }
00115 virtual int setValue (OSUINT32 value);
00116
00117 virtual ~ASN1CBitStrSizeHolder32() {}
00118 private:
00119 ASN1CBitStrSizeHolder32& operator= (const ASN1CBitStrSizeHolder32&) {
00120 return *this;
00121 }
00122 } ;
00123
00124 class EXTRTCLASS ASN1CBitStr : public ASN1CType {
00125 private:
00126 OSUINT32 _numbits;
00127 OSOCTET* _units;
00128
00129 protected:
00130 OSOCTET** mpUnits;
00131 OSUINT32 mMaxNumBits;
00132 ASN1CBitStrSizeHolder* mpNumBits;
00133 OSUINT32 mUnitsUsed;
00134 OSUINT32 mUnitsAllocated;
00135 OSBOOL mDynAlloc;
00136
00137 private:
00138 OSOCTET* allocateMemory (OSUINT32 sz);
00139 OSOCTET* reallocateMemory
00140 (OSOCTET* old, OSUINT32 oldBufSz, OSUINT32 newBufSz);
00141 void freeMemory (OSOCTET* mem);
00142
00143
00144
00145
00146
00147
00148 void recalculateUnitsUsed();
00149
00150
00151
00152
00153
00154 int checkCapacity (OSUINT32 unitsRequired);
00155
00156
00157
00158
00159
00160 OSOCTET getBits (OSUINT32 j);
00161
00162 void privateInit (OSUINT32 nbits);
00163 void privateInit (OSOCTET* bitStr, OSUINT32 maxNumbits_);
00164 void privateInit (ASN1TDynBitStr& bitStr);
00165
00166 protected:
00167
00168
00169
00170
00171 EXTRTMETHOD ASN1CBitStr (OSRTMessageBufferIF& msgBuf);
00172
00173
00174
00175
00176
00177 EXTRTMETHOD ASN1CBitStr();
00178
00179
00180
00181
00182
00183
00184 EXTRTMETHOD ASN1CBitStr (OSRTContext& ctxt);
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194 EXTRTMETHOD ASN1CBitStr
00195 (OSOCTET* pBits, OSUINT32& numbits, OSUINT32 maxNumbits);
00196
00197 EXTRTMETHOD ASN1CBitStr
00198 (OSOCTET* pBits, OSUINT8& numbits, OSUINT32 maxNumbits);
00199
00200 EXTRTMETHOD ASN1CBitStr
00201 (OSOCTET* pBits, OSUINT16& numbits, OSUINT32 maxNumbits);
00202
00203
00204 EXTRTMETHOD ASN1CBitStr (OSOCTET* pBits, OSUINT32 maxNumbits);
00205
00206
00207
00208
00209
00210
00211
00212 EXTRTMETHOD ASN1CBitStr (ASN1TDynBitStr& bitStr);
00213
00214 void initBase (OSOCTET* pBits, OSUINT32 numbits, OSUINT32 maxNumbits);
00215
00216 EXTRTMETHOD void init
00217 (OSOCTET* pBits, OSUINT32& numbits, OSUINT32 maxNumbits);
00218
00219 EXTRTMETHOD void init
00220 (OSOCTET* pBits, OSUINT8& numbits, OSUINT32 maxNumbits);
00221
00222 EXTRTMETHOD void init
00223 (OSOCTET* pBits, OSUINT16& numbits, OSUINT32 maxNumbits);
00224
00225 EXTRTMETHOD void init (ASN1TDynBitStr& bitStr);
00226
00227 public:
00237 EXTRTMETHOD ASN1CBitStr (OSRTMessageBufferIF& msgbuf, OSUINT32 nbits);
00238
00250 EXTRTMETHOD ASN1CBitStr
00251 (OSRTMessageBufferIF& msgbuf, OSOCTET* bitStr,
00252 OSUINT32& numbits, OSUINT32 maxNumbits_);
00253
00254 EXTRTMETHOD ASN1CBitStr
00255 (OSRTMessageBufferIF& msgbuf, OSOCTET* bitStr,
00256 OSUINT8& numbits, OSUINT32 maxNumbits_);
00257
00258 EXTRTMETHOD ASN1CBitStr
00259 (OSRTMessageBufferIF& msgbuf, OSOCTET* bitStr,
00260 OSUINT16& numbits, OSUINT32 maxNumbits_);
00261
00262 EXTRTMETHOD ASN1CBitStr
00263 (OSRTMessageBufferIF& msgbuf, OSOCTET* bitStr, OSUINT32 maxNumbits_);
00264
00265
00266
00267
00268
00269
00270 EXTRTMETHOD ASN1CBitStr
00271 (OSRTMessageBufferIF& msgBuf, ASN1TDynBitStr& bitStr);
00272
00273
00274
00275
00276
00277 EXTRTMETHOD ASN1CBitStr (OSRTContext& ctxt, OSUINT32 nbits);
00278
00279
00280
00281
00282
00283
00284
00285
00286 EXTRTMETHOD ASN1CBitStr
00287 (OSRTContext& ctxt, OSOCTET* bitStr,
00288 OSUINT32& octsNumbits, OSUINT32 maxNumbits_);
00289
00290 EXTRTMETHOD ASN1CBitStr
00291 (OSRTContext& ctxt, OSOCTET* bitStr,
00292 OSUINT8& octsNumbits, OSUINT32 maxNumbits_);
00293
00294 EXTRTMETHOD ASN1CBitStr
00295 (OSRTContext& ctxt, OSOCTET* bitStr,
00296 OSUINT16& octsNumbits, OSUINT32 maxNumbits_);
00297
00298 EXTRTMETHOD ASN1CBitStr
00299 (OSRTContext& ctxt, OSOCTET* bitStr, OSUINT32 maxNumbits_);
00300
00301
00302
00303
00304
00305
00306 EXTRTMETHOD ASN1CBitStr (OSRTContext& ctxt, ASN1TDynBitStr& bitStr);
00307
00308
00309
00310
00311 EXTRTMETHOD ASN1CBitStr (const ASN1CBitStr& bitStr);
00312
00313
00314
00315
00316 EXTRTMETHOD ASN1CBitStr (const ASN1CBitStr& bitStr, OSBOOL extendable);
00317
00318
00319 EXTRTMETHOD ~ASN1CBitStr();
00320
00332
00333
00334
00335
00336
00337
00338
00339 EXTRTMETHOD int set (OSUINT32 bitIndex);
00340
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366 EXTRTMETHOD int set (OSUINT32 fromIndex, OSUINT32 toIndex);
00367
00380
00381
00382
00383 inline int change (OSUINT32 bitIndex, OSBOOL value) {
00384 return (value) ? set (bitIndex) : clear (bitIndex);
00385 }
00386
00399
00400
00401
00402
00403
00404
00405
00406 EXTRTMETHOD int clear (OSUINT32 bitIndex);
00407
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433 EXTRTMETHOD int clear (OSUINT32 fromIndex, OSUINT32 toIndex);
00434
00443
00444
00445
00446 EXTRTMETHOD void clear();
00447
00463
00464
00465
00466
00467
00468
00469
00470
00471 EXTRTMETHOD int invert (OSUINT32 bitIndex);
00472
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502 EXTRTMETHOD int invert(OSUINT32 fromIndex, OSUINT32 toIndex);
00503
00515
00516
00517
00518 EXTRTMETHOD OSBOOL get(OSUINT32 bitIndex);
00519
00525
00526
00527
00528 inline OSBOOL isSet(OSUINT32 bitIndex) { return get(bitIndex); }
00529
00538
00539
00540
00541
00542 inline OSBOOL isEmpty() { return (mUnitsUsed == 0); }
00543
00552
00553
00554
00555
00556 EXTRTMETHOD OSUINT32 size() const;
00557
00569
00570
00571
00572
00573
00574 EXTRTMETHOD OSUINT32 length() const;
00575
00585
00586
00587
00588
00589 EXTRTMETHOD OSUINT32 cardinality() const;
00590
00604
00605
00606
00607 EXTRTMETHOD int getBytes (OSOCTET* pBuf, OSUINT32 bufSz);
00608
00634 EXTRTMETHOD int get
00635 (OSUINT32 fromIndex, OSUINT32 toIndex, OSOCTET* pBuf, OSUINT32 bufSz);
00636
00654 EXTRTMETHOD int doAnd (const OSOCTET* pOctstr, OSUINT32 octsNumbits);
00655
00667 inline int doAnd (const ASN1TDynBitStr& bitStr) {
00668 return doAnd(bitStr.data, bitStr.numbits);
00669 }
00670
00681 inline int doAnd(const ASN1CBitStr& bitStr) {
00682 return doAnd(*bitStr.mpUnits, bitStr.length());
00683 }
00684
00685
00702 EXTRTMETHOD int doOr(const OSOCTET* pOctstr, OSUINT32 octsNumbits);
00703
00715 inline int doOr(const ASN1TDynBitStr& bitStr) {
00716 return doOr(bitStr.data, bitStr.numbits);
00717 }
00718
00729 inline int doOr(const ASN1CBitStr& bitStr) {
00730 return doOr(*bitStr.mpUnits, bitStr.length());
00731 }
00732
00749 EXTRTMETHOD int doXor(const OSOCTET* pOctstr, OSUINT32 octsNumbits);
00750
00762 inline int doXor(const ASN1TDynBitStr& bitStr) {
00763 return doXor(bitStr.data, bitStr.numbits);
00764 }
00765
00776 inline int doXor(const ASN1CBitStr& bitStr) {
00777 return doXor(*bitStr.mpUnits, bitStr.length());
00778 }
00779
00794
00795
00796
00797
00798
00799
00800
00801
00802
00803 EXTRTMETHOD int doAndNot(const OSOCTET* pOctstr, OSUINT32 octsNumbits);
00804
00819 inline int doAndNot(const ASN1TDynBitStr& bitStr) {
00820 return doAndNot(bitStr.data, bitStr.numbits);
00821 }
00822
00836 inline int doAndNot(const ASN1CBitStr& bitStr) {
00837 return doAndNot(*bitStr.mpUnits, bitStr.length());
00838 }
00839
00853
00854
00855
00856 EXTRTMETHOD int shiftLeft(OSUINT32 shift);
00857
00871
00872
00873
00874 EXTRTMETHOD int shiftRight(OSUINT32 shift);
00875
00882
00883
00884
00885 EXTRTMETHOD OSUINT32 unusedBitsInLastUnit();
00886
00897
00898
00899
00900
00901
00902 EXTRTMETHOD operator ASN1TDynBitStr();
00903
00913
00914
00915
00916
00917 EXTRTMETHOD operator ASN1TDynBitStr*();
00918 } ;
00919 #else
00920 typedef class _ASN1CBitStr : public ASN1CType {
00921 public:
00922 _ASN1CBitStr (OSRTMessageBufferIF& msgBuf, OSUINT32 nbits) :
00923 ASN1CType (msgBuf) {}
00924
00925 _ASN1CBitStr (OSRTMessageBufferIF& msgBuf, OSOCTET* bitStr,
00926 OSUINT32& octsNumbits, OSUINT32 maxNumbits_) :
00927 ASN1CType (msgBuf) {}
00928
00929 _ASN1CBitStr (OSRTMessageBufferIF& msgBuf, ASN1TDynBitStr& bitStr) :
00930 ASN1CType (msgBuf) {}
00931 } ASN1CBitStr;
00932 #endif // _NO_UTILS_CLASSES
00933 #endif // _ASN1CBITSTR_H_
00934