ASN1CBitStr Class Reference
[Control (ASN1C_) Base Classes]

#include <ASN1CBitStr.h>

Inheritance diagram for ASN1CBitStr:
ASN1CType

List of all members.

Public Member Functions

EXTRTMETHOD ASN1CBitStr (OSRTMessageBufferIF &msgbuf, OSUINT32 nbits)
EXTRTMETHOD ASN1CBitStr (OSRTMessageBufferIF &msgbuf, OSOCTET *bitStr, OSUINT32 &numbits, OSUINT32 maxNumbits_)
EXTRTMETHOD ASN1CBitStr (OSRTMessageBufferIF &msgbuf, OSOCTET *bitStr, OSUINT8 &numbits, OSUINT32 maxNumbits_)
EXTRTMETHOD ASN1CBitStr (OSRTMessageBufferIF &msgbuf, OSOCTET *bitStr, OSUINT16 &numbits, OSUINT32 maxNumbits_)
EXTRTMETHOD ASN1CBitStr (OSRTMessageBufferIF &msgbuf, OSOCTET *bitStr, OSUINT32 maxNumbits_)
EXTRTMETHOD ASN1CBitStr (OSRTMessageBufferIF &msgBuf, ASN1TDynBitStr &bitStr)
EXTRTMETHOD ASN1CBitStr (OSRTContext &ctxt, OSUINT32 nbits)
EXTRTMETHOD ASN1CBitStr (OSRTContext &ctxt, OSOCTET *bitStr, OSUINT32 &octsNumbits, OSUINT32 maxNumbits_)
EXTRTMETHOD ASN1CBitStr (OSRTContext &ctxt, OSOCTET *bitStr, OSUINT8 &octsNumbits, OSUINT32 maxNumbits_)
EXTRTMETHOD ASN1CBitStr (OSRTContext &ctxt, OSOCTET *bitStr, OSUINT16 &octsNumbits, OSUINT32 maxNumbits_)
EXTRTMETHOD ASN1CBitStr (OSRTContext &ctxt, OSOCTET *bitStr, OSUINT32 maxNumbits_)
EXTRTMETHOD ASN1CBitStr (OSRTContext &ctxt, ASN1TDynBitStr &bitStr)
EXTRTMETHOD ASN1CBitStr (const ASN1CBitStr &bitStr)
EXTRTMETHOD ASN1CBitStr (const ASN1CBitStr &bitStr, OSBOOL extendable)
EXTRTMETHOD int set (OSUINT32 bitIndex)
EXTRTMETHOD int set (OSUINT32 fromIndex, OSUINT32 toIndex)
int change (OSUINT32 bitIndex, OSBOOL value)
EXTRTMETHOD int clear (OSUINT32 bitIndex)
EXTRTMETHOD int clear (OSUINT32 fromIndex, OSUINT32 toIndex)
EXTRTMETHOD void clear ()
EXTRTMETHOD int invert (OSUINT32 bitIndex)
EXTRTMETHOD int invert (OSUINT32 fromIndex, OSUINT32 toIndex)
EXTRTMETHOD OSBOOL get (OSUINT32 bitIndex)
OSBOOL isSet (OSUINT32 bitIndex)
OSBOOL isEmpty ()
EXTRTMETHOD OSUINT32 size () const
EXTRTMETHOD OSUINT32 length () const
EXTRTMETHOD OSUINT32 cardinality () const
EXTRTMETHOD int getBytes (OSOCTET *pBuf, OSUINT32 bufSz)
EXTRTMETHOD int get (OSUINT32 fromIndex, OSUINT32 toIndex, OSOCTET *pBuf, OSUINT32 bufSz)
EXTRTMETHOD int doAnd (const OSOCTET *pOctstr, OSUINT32 octsNumbits)
int doAnd (const ASN1TDynBitStr &bitStr)
int doAnd (const ASN1CBitStr &bitStr)
EXTRTMETHOD int doOr (const OSOCTET *pOctstr, OSUINT32 octsNumbits)
int doOr (const ASN1TDynBitStr &bitStr)
int doOr (const ASN1CBitStr &bitStr)
EXTRTMETHOD int doXor (const OSOCTET *pOctstr, OSUINT32 octsNumbits)
int doXor (const ASN1TDynBitStr &bitStr)
int doXor (const ASN1CBitStr &bitStr)
EXTRTMETHOD int doAndNot (const OSOCTET *pOctstr, OSUINT32 octsNumbits)
int doAndNot (const ASN1TDynBitStr &bitStr)
int doAndNot (const ASN1CBitStr &bitStr)
EXTRTMETHOD int shiftLeft (OSUINT32 shift)
EXTRTMETHOD int shiftRight (OSUINT32 shift)
EXTRTMETHOD OSUINT32 unusedBitsInLastUnit ()
EXTRTMETHOD operator ASN1TDynBitStr ()
EXTRTMETHOD operator ASN1TDynBitStr * ()

Protected Member Functions

EXTRTMETHOD ASN1CBitStr (OSRTMessageBufferIF &msgBuf)
EXTRTMETHOD ASN1CBitStr (OSRTContext &ctxt)
EXTRTMETHOD ASN1CBitStr (OSOCTET *pBits, OSUINT32 &numbits, OSUINT32 maxNumbits)
EXTRTMETHOD ASN1CBitStr (OSOCTET *pBits, OSUINT8 &numbits, OSUINT32 maxNumbits)
EXTRTMETHOD ASN1CBitStr (OSOCTET *pBits, OSUINT16 &numbits, OSUINT32 maxNumbits)
EXTRTMETHOD ASN1CBitStr (OSOCTET *pBits, OSUINT32 maxNumbits)
EXTRTMETHOD ASN1CBitStr (ASN1TDynBitStr &bitStr)
void initBase (OSOCTET *pBits, OSUINT32 numbits, OSUINT32 maxNumbits)
EXTRTMETHOD void init (OSOCTET *pBits, OSUINT32 &numbits, OSUINT32 maxNumbits)
EXTRTMETHOD void init (OSOCTET *pBits, OSUINT8 &numbits, OSUINT32 maxNumbits)
EXTRTMETHOD void init (OSOCTET *pBits, OSUINT16 &numbits, OSUINT32 maxNumbits)
EXTRTMETHOD void init (ASN1TDynBitStr &bitStr)

Protected Attributes

OSOCTET ** mpUnits
OSUINT32 mMaxNumBits
ASN1CBitStrSizeHoldermpNumBits
OSUINT32 mUnitsUsed
OSUINT32 mUnitsAllocated
OSBOOL mDynAlloc

Detailed Description

ASN.1 bit string control class. The ASN1CBitStr class is derived from the ASN1CType base class. It is used as the base class for generated control classes for the ASN.1 BIT STRING type. This class provides utility methods for operating on the bit string referenced by the generated class. This class can also be used inline to operate on bits within generated BIT STRING elements in a SEQUENCE, SET, or CHOICE construct.


Constructor & Destructor Documentation

EXTRTMETHOD ASN1CBitStr::ASN1CBitStr ( OSRTMessageBufferIF &  msgbuf,
OSUINT32  nbits 
)

This constructor creates an empty bit string. If the nbits argument is zero, the bit string is set to be dynamic; otherwise, the capacity is set to nbits.

Parameters:
msgbuf - ASN.1 message buffer or stream object.
nbits - Number of bits this bit string can contain (zero if unbounded.
EXTRTMETHOD ASN1CBitStr::ASN1CBitStr ( OSRTMessageBufferIF &  msgbuf,
OSOCTET *  bitStr,
OSUINT32 &  numbits,
OSUINT32  maxNumbits_ 
)

This constructor creates a bit string from an array of bits. The constructor does not copy the bit string data, it just references the given data variables. All operations on the bit string cause the referenced items to be updated directly.

Parameters:
msgbuf - ASN.1 message buffer or stream object.
bitStr - Pointer to static byte array
numbits - Reference to length of bit string (in bits)
maxNumbits_ - sets maximum length in bits

Member Function Documentation

EXTRTMETHOD OSUINT32 ASN1CBitStr::cardinality (  )  const

This method calculates the cardinality of the target bit string.

Cardinality of the bit string is the number of bits set to 1.

Parameters:
- none
Returns:
The number of bytes of space actually in use by this bit string to represent the bit values.
int ASN1CBitStr::change ( OSUINT32  bitIndex,
OSBOOL  value 
) [inline]

Changes the bit at the specified index to the specified value.

Parameters:
bitIndex Relative index of bit to set in string. Bit index 0 refers to the MS bit (bit 8) in the first octet. The index values then progress from left to right (MS to LS bits).
value Boolean value to which the bit is to be set.
Returns:
Completion status of operation: 0 - if succeed
  • 0 (0) = success
  • negative return value is error.
EXTRTMETHOD void ASN1CBitStr::clear (  ) 

This version of the clear method sets all bits in the bit string to zero.

Parameters:
- none
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
EXTRTMETHOD int ASN1CBitStr::clear ( OSUINT32  fromIndex,
OSUINT32  toIndex 
)

This version of the clear method sets the bits from the specified fromIndex (inclusive) to the specified toIndex (exclusive) to zero.

Parameters:
fromIndex Relative start index (inclusive) of bits in string. Bit index 0 refers to the MS bit (bit 8) in the first octet. The index values then progress from left to right (MS to LS bits).
toIndex Relative end index (exclusive) of bits in string. Bit index 0 refers to the MS bit (bit 8) in the first octet. The index values then progress from left to right (MS to LS bits).
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
EXTRTMETHOD int ASN1CBitStr::clear ( OSUINT32  bitIndex  ) 

This version of the clear method sets the given bit in the target string to zero.

Parameters:
bitIndex Relative index of bit in string. Bit index 0 refers to the MS bit (bit 8) in the first octet. The index values then progress from left to right (MS to LS bits).
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
int ASN1CBitStr::doAnd ( const ASN1CBitStr bitStr  )  [inline]

This method performs a logical AND of the target bit string with the argument bit string.

Parameters:
bitStr A reference to another bit string represented by ASN1CBitStr type for performing logical operation.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.

References length().

int ASN1CBitStr::doAnd ( const ASN1TDynBitStr bitStr  )  [inline]

This method performs a logical AND of the target bit string with the argument bit string.

Parameters:
bitStr A reference t another bit string represented by ASN1TDynBitStr type for performing logical operation.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
EXTRTMETHOD int ASN1CBitStr::doAnd ( const OSOCTET *  pOctstr,
OSUINT32  octsNumbits 
)

Performs a logical AND of this target bit set with the argument bit set.

Returns: 0 - if succeed, or ASN_E_INVLEN - if 'octsNumbits' is negative, or RTERR_INVPARAM - if pOctstr is the same bit string as this or null, or other error codes (see asn1type.h).

Parameters:
pOctstr A pointer to octets of another bit string for performing logical operation.
octsNumbits A number of bits in arguent bit string.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
int ASN1CBitStr::doAndNot ( const ASN1CBitStr bitStr  )  [inline]

This method performs a logical ANDNOT of the target bit string with the argument bit string.

Logical ANDNOT clears all of the bits in this bit string whose corresponding bit is set in the specified bit string.

Parameters:
bitStr A reference to another bit string represented by ASN1CBitStr type for performing logical operation.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.

References length().

int ASN1CBitStr::doAndNot ( const ASN1TDynBitStr bitStr  )  [inline]

This method performs a logical ANDNOT of the target bit string with the argument bit string.

Logical ANDNOT clears all of the bits in this bit string whose corresponding bit is set in the specified bit string.

Parameters:
bitStr A reference t another bit string represented by ASN1TDynBitStr type for performing logical operation.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
EXTRTMETHOD int ASN1CBitStr::doAndNot ( const OSOCTET *  pOctstr,
OSUINT32  octsNumbits 
)

This method performs a logical ANDNOT of the target bit string with the argument bit string.

Logical ANDNOT clars all of the bits in this bit string whose corresponding bit is set in the specified bit string.

Parameters:
pOctstr A pointer to octets of another bit string for performing logical operation.
octsNumbits A number of bits in arguent bit string.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
int ASN1CBitStr::doOr ( const ASN1CBitStr bitStr  )  [inline]

This method performs a logical OR of the target bit string with the argument bit string.

Parameters:
bitStr A reference to another bit string represented by ASN1CBitStr type for performing logical operation.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.

References length().

int ASN1CBitStr::doOr ( const ASN1TDynBitStr bitStr  )  [inline]

This method performs a logical OR of the target bit string with the argument bit string.

Parameters:
bitStr A reference t another bit string represented by ASN1TDynBitStr type for performing logical operation.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
EXTRTMETHOD int ASN1CBitStr::doOr ( const OSOCTET *  pOctstr,
OSUINT32  octsNumbits 
)

Performs a logical OR of this target bit set with the argument bit set.

Returns: 0 - if succeed, or ASN_E_INVLEN - if 'octsNumbits' is negative, or RTERR_INVPARAM - if pOctstr is the same bit string as this or null, or other error codes (see asn1type.h).

Parameters:
pOctstr A pointer to octets of another bit string for performing logical operation.
octsNumbits A number of bits in arguent bit string.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
int ASN1CBitStr::doXor ( const ASN1CBitStr bitStr  )  [inline]

This method performs a logical OR of the target bit string with the argument bit string.

Parameters:
bitStr A reference to another bit string represented by ASN1CBitStr type for performing logical operation.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.

References length().

int ASN1CBitStr::doXor ( const ASN1TDynBitStr bitStr  )  [inline]

This method performs a logical XOR of the target bit string with the argument bit string.

Parameters:
bitStr A reference t another bit string represented by ASN1TDynBitStr type for performing logical operation.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
EXTRTMETHOD int ASN1CBitStr::doXor ( const OSOCTET *  pOctstr,
OSUINT32  octsNumbits 
)

Performs a logical XOR of this target bit set with the argument bit set.

Returns: 0 - if succeed, or ASN_E_INVLEN - if 'octsNumbits' is negative, or RTERR_INVPARAM - if pOctstr is null, or other error codes (see asn1type.h).

Parameters:
pOctstr A pointer to octets of another bit string for performing logical operation.
octsNumbits A number of bits in arguent bit string.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
EXTRTMETHOD int ASN1CBitStr::get ( OSUINT32  fromIndex,
OSUINT32  toIndex,
OSOCTET *  pBuf,
OSUINT32  bufSz 
)

This version of the get method copies the bit string composed of bits from this bit string from the specified fromIndex (inclusive) to the specified toIndex (exclusive) into the given buffer.

Parameters:
fromIndex Relative start index (inclusive) of bits in string. Bit index 0 refers to the MS bit (bit 8) in the first octet. The index values then progress from left to right (MS to LS bits).
toIndex Relative end index (exclusive) of bits in string. Bit index 0 refers to the MS bit (bit 8) in the first octet. The index values then progress from left to right (MS to LS bits).
pBuf Pointer to destination buffer where bytes will be copied.
bufSz Size of the destination buffer. If the size of the buffer is not large enough to receive the entire bit string, a negative status value (RTERR_BUFOVFLOW) will be returned.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • RTERR_OUTOFBND index value is out of bounds
  • RTERR_RANGERR fromIndex > toIndex
  • other error codes (see asn1type.h).
EXTRTMETHOD OSBOOL ASN1CBitStr::get ( OSUINT32  bitIndex  ) 

This method returns the value of the bit with the specified index.

Parameters:
bitIndex Relative index of bit in string. Bit index 0 refers to the MS bit (bit 8) in the first octet. The index values then progress from left to right (MS to LS bits).
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
EXTRTMETHOD int ASN1CBitStr::getBytes ( OSOCTET *  pBuf,
OSUINT32  bufSz 
)

This method copies the bit string to the given buffer.

Parameters:
pBuf Pointer to the destination buffer where bytes will be copied.
bufSz Size of the destination buffer. If the size of the buffer is not large enough to receive the entire bit string, a negative status value (RTERR_BUFOVFLOW) will be returned.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
EXTRTMETHOD int ASN1CBitStr::invert ( OSUINT32  fromIndex,
OSUINT32  toIndex 
)

This version inverts the bits from the specified fromIndex (inclusive) to the specified toIndex (exclusive).

If the bit in the bit string is a zero, it will be set to 1; if the bit is a one, it will be set to 0.

Parameters:
fromIndex Relative start index (inclusive) of bits in string. Bit index 0 refers to the MS bit (bit 8) in the first octet. The index values then progress from left to right (MS to LS bits).
toIndex Relative end index (exclusive) of bits in string. Bit index 0 refers to the MS bit (bit 8) in the first octet. The index values then progress from left to right (MS to LS bits).
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
EXTRTMETHOD int ASN1CBitStr::invert ( OSUINT32  bitIndex  ) 

This version of the invert method inverts the given bit in the target string.

If the bit in the bit string is a zero, it will be set to 1; if the bit is a one, it will be set to 0.

Parameters:
bitIndex Relative index of bit in string. Bit index 0 refers to the MS bit (bit 8) in the first octet. The index values then progress from left to right (MS to LS bits).
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
OSBOOL ASN1CBitStr::isEmpty (  )  [inline]

This method returns TRUE if this bit string contains no bits that are set to 1.

Parameters:
- none
Returns:
TRUE, if the bit string contains no bits that are set to 1.
OSBOOL ASN1CBitStr::isSet ( OSUINT32  bitIndex  )  [inline]

This method is the same as ASN1CBitStr::get.

See also:
get (OSUINT32 bitIndex)
EXTRTMETHOD OSUINT32 ASN1CBitStr::length (  )  const

This method Calculates the "logical size" of the bith string.

The "logical size" is caluculated by noting the index of the highest set bit in the bit string plus one. Zero will be returned if the bit string contains no set bits. The highest bit in the bit string is the LS bit in the last octet set to 1.

Parameters:
- none
Returns:
Returns the "logical size" of this bit string.

Referenced by doAnd(), doAndNot(), doOr(), and doXor().

EXTRTMETHOD ASN1CBitStr::operator ASN1TDynBitStr (  ) 

This method returns a filled ANSDITDynBitStr variable.

Memory is not allocated when calling this method; only a pointer is assigned. Thus, the ASN1TDynBitStr variable is only valid while this ASN1CBitStr is in scope.

Parameters:
- none
Returns:
Filled ASN1TDynBitStr.
EXTRTMETHOD ASN1CBitStr::operator ASN1TDynBitStr * (  ) 

This method returns a pointer to the filled ANSDITDynBitStr variable.

Memory for the ASN1DynBitStr variable is alloced using memory memAlloc and bits are copied into it.

Parameters:
- none
Returns:
Pointer to a filled ASN1TDynBitStr.
EXTRTMETHOD int ASN1CBitStr::set ( OSUINT32  fromIndex,
OSUINT32  toIndex 
)

This version of teh set method sets the bits from the specified fromIndex (inclusive) to the specified toIndex (exclusive) to one.

Parameters:
fromIndex Relative start index (inclusive) of bits in the string. The bit index 0 refers to the MS bit (bit 8) in the first octet. The index values then progress from the left to right (MS to LS).
toIndex Relative end index (exclusive) of bits in the string. The bit index 0 refers to the MS bit (bit 8) in the first octet. The index values then progress from the left to right (MS to LS).
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
EXTRTMETHOD int ASN1CBitStr::set ( OSUINT32  bitIndex  ) 

This version of the set method sets the given bit in the target string.

Parameters:
bitIndex Relative index of the bit to set in the string. The bit idex 0 refers to the MS bit (bit 8) in the first octet. The index values then progress from the left to right (MS to LS).
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
EXTRTMETHOD int ASN1CBitStr::shiftLeft ( OSUINT32  shift  ) 

This method shifts all bits to the left by the number of specified in the shift operand.

If the bit string can dynamically grow, then the length of the bit string will be decreased by shift bits. Otherwise, bits that are shifted into the bitstring are filled with zeros from the right. Most left bits are lost.

Parameters:
shift Number of bits to be shifted.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
EXTRTMETHOD int ASN1CBitStr::shiftRight ( OSUINT32  shift  ) 

This method shifts all bits to the right by the number of specified in the shift operand.

If the bit string can dynamically grow, then the length of the bit string will be decreased by shift bits. Otherwise, bits that are shifted into the bitstring are filled with zeros from the left. Most right bits are lost.

Parameters:
shift Number of bits to be shifted.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
EXTRTMETHOD OSUINT32 ASN1CBitStr::size (  )  const

This method returns the number of bytes of space actually in use by this bit string to represent bit values.

Parameters:
- none
Returns:
Number of bytes of space actually in use by this bit string to represent bit values.
EXTRTMETHOD OSUINT32 ASN1CBitStr::unusedBitsInLastUnit (  ) 

This method returns the number of unused bits in the last octet.

Returns:
Number of bits in the last octet. It is equal to length() % 8.

The documentation for this class was generated from the following file: