Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

Phx::BitVector Class Reference

The BitVector class contains a random-access array of bits. More...

#include <PhxBitVector.h>

List of all members.

Public Types

typedef uint32_t Bits
typedef uint32_t Bytes

Public Member Functions

 BitVector (Bits bitCount=16)
 BitVector (const uint8_t *buffer, Bits bitCount)
 BitVector (const BitVector &)
const BitVectoroperator= (const BitVector &)
uint8_t * data ()
 Returns a pointer to this vector's raw data.
const uint8_t * data () const
Bits bitCount () const
 The number of valid bits in this BitVector.
void bitCount (Bits bitCount)
 Sets the bit count attribute.
Bytes byteCount (void) const
 The number of valid bytes in this BitVector.
Bytes dataSize (void) const
 The size of the data() buffer in bytes.
void dataSize (Bytes dataSize)
 Sets the size of this BitVector's data() buffer.
String stringField (Bits bitIndex) const
 Reads a String starting from the given index.
double doubleField (Bits bitIndex) const
 Reads a double starting from the given index.
float floatField (Bits bitIndex) const
 Reads a float starting from the given index.
uint64_t uint64Field (Bits bitIndex) const
 Reads a uint64_t starting from the given index.
uint32_t uint32Field (Bits bitIndex) const
 Reads a uint32_t starting from the given index.
uint16_t uint16Field (Bits bitIndex) const
 Reads a uint16_t starting from the given index.
uint8_t uint8Field (Bits bitIndex) const
 Reads a uint8_t starting from the given index.
int64_t int64Field (Bits bitIndex) const
 Reads an int64_t starting from the given index.
int32_t int32Field (Bits bitIndex) const
 Reads an int32_t starting from the given index.
int16_t int16Field (Bits bitIndex) const
 Reads an int16_t starting from the given index.
int8_t int8Field (Bits bitIndex) const
 Reads a int8_t starting from the given index.
bool boolField (Bits bitIndex) const
 Reads an unsigned integer with a specified number of bits. Reads a signed integer with a specified number of bits. Reads a boolean from the given index.
void stringField (Bits bitIndex, const String &value)
 Reads a BitVector starting from the given index.
void doubleField (Bits bitIndex, double value)
void floatField (Bits bitIndex, float value)
void uint64Field (Bits bitIndex, uint64_t value)
void uint32Field (Bits bitIndex, uint32_t value)
void uint16Field (Bits bitIndex, uint16_t value)
void uint8Field (Bits bitIndex, uint8_t value)
void int64Field (Bits bitIndex, int64_t value)
void int32Field (Bits bitIndex, int32_t value)
void int16Field (Bits bitIndex, int16_t value)
void int8Field (Bits bitIndex, int8_t value)
void boolField (Bits bitIndex, bool value)

Classes

class  InputFile
 Represents a file from which BitVector's can be read. More...
class  InputStream
 A wrapper to BitVector that provides stream-style input (reading) semantics. More...
class  OutputFile
 Represents a file to which BitVector's can be stored. More...
class  OutputStream
 A wrapper to BitVector that provides stream-style output (writing) semantics. More...


Detailed Description

The BitVector class contains a random-access array of bits.

You can read/write various primitive types to the bit vector directly indexing into the array, or you can use the InputStream and OutputStream types for stream-style access.


Member Function Documentation

void Phx::BitVector::bitCount Bits  bitCount  ) 
 

Sets the bit count attribute.

This will set the bitCount attribute to a specified value. If more storage is necessary to hold the specified number of bits, then dataSize() will be set to accomodate this. If the new value is smaller than the current value, then the count is simply set and dataSize() will not be modified. However, all bits beyond the first bitCount bits will be set to zero (as is consistent with the definition of the bitCount() attribute).

This will be used quite rarely by clients. It exists so that clients which provide raw data directly to the BitVector by copying it into the data() buffer may specify how many valid bits of data are now contained in the BitVector.

Parameters:
bitCount The new number of valid bits that the BitVector will report via bitCount().

Bits Phx::BitVector::bitCount  )  const [inline]
 

The number of valid bits in this BitVector.

The allocated size of data() may be greater than necessary to contain these bits of data. However, any bits beyond the first bitCount() bits are zero.

Returns:
The number of bits of data stored in this BitVector.

bool Phx::BitVector::boolField Bits  bitIndex  )  const
 

Reads an unsigned integer with a specified number of bits. Reads a signed integer with a specified number of bits. Reads a boolean from the given index.

Parameters:
bitIndex The bit index at which to read the value.
Returns:
The boolean that was read from the given index.

Bytes Phx::BitVector::byteCount void   )  const [inline]
 

The number of valid bytes in this BitVector.

This is simply bitCount(), rounded up to the nearest number of bytes.

Returns:
(bitCount() + 7) / 8

uint8_t* Phx::BitVector::data  )  [inline]
 

Returns a pointer to this vector's raw data.

Returns:
A pointer to this vector's raw data.

void Phx::BitVector::dataSize Bytes  dataSize  ) 
 

Sets the size of this BitVector's data() buffer.

The buffer is guaranteed to be re-allocated to the given size (whether it is larger or smaller). The data will be truncated if necessary to do this (which will be reflected by the bitCount()) variable.

Parameters:
dataSize The new size for the internal data buffer, in bytes.

Bytes Phx::BitVector::dataSize void   )  const [inline]
 

The size of the data() buffer in bytes.

The actual number of valid (initialized) bits of data in the array may be less, as reported by bitCount(). The returned number here is the actual amount of memory allocated for the data() field, and hence is the maximum amount of raw data that could be copied into this BitVector from an external source.

Returns:
The total number of bytes allocated for the data() buffer.

double Phx::BitVector::doubleField Bits  bitIndex  )  const
 

Reads a double starting from the given index.

Parameters:
bitIndex The bit index at which to begin reading.
Returns:
The double that was read from the given index.

float Phx::BitVector::floatField Bits  bitIndex  )  const
 

Reads a float starting from the given index.

Parameters:
bitIndex The bit index at which to begin reading.
Returns:
The float that was read from the given index.

int16_t Phx::BitVector::int16Field Bits  bitIndex  )  const [inline]
 

Reads an int16_t starting from the given index.

Parameters:
bitIndex The bit index at which to begin reading.
Returns:
The int16_t that was read from the given index.

int32_t Phx::BitVector::int32Field Bits  bitIndex  )  const [inline]
 

Reads an int32_t starting from the given index.

Parameters:
bitIndex The bit index at which to begin reading.
Returns:
The int32_t that was read from the given index.

int64_t Phx::BitVector::int64Field Bits  bitIndex  )  const [inline]
 

Reads an int64_t starting from the given index.

Parameters:
bitIndex The bit index at which to begin reading.
Returns:
The int64_t that was read from the given index.

int8_t Phx::BitVector::int8Field Bits  bitIndex  )  const [inline]
 

Reads a int8_t starting from the given index.

Parameters:
bitIndex The bit index at which to begin reading.
Returns:
The int8_t that was read from the given index.

void Phx::BitVector::stringField Bits  bitIndex,
const String &  value
 

Reads a BitVector starting from the given index.

Another vector of bits can be embedded within a BitVector as a means of encapsulating vectors generated by other sources. The length of the original vector is included in the encapsulated data so the length (in bits) of the original vector is preserved.

Parameters:
bitIndex The bit index at which to begin reading.
Returns:
The BitField created from the data beginning at the given index.
Exceptions:
RangeException thrown if bitIndex is out of bounds. This may occur even if bitIndex < bitCount(), when formatting information would indicate that the start of the data is beyond the end of the vector.
InternalException thrown if the bit vector could not be constructed from the data beginning at bitIndex.

String Phx::BitVector::stringField Bits  bitIndex  )  const
 

Reads a String starting from the given index.

Parameters:
bitIndex The bit index at which to begin reading.
Returns:
The String that was read from the given index.

uint16_t Phx::BitVector::uint16Field Bits  bitIndex  )  const
 

Reads a uint16_t starting from the given index.

Parameters:
bitIndex The bit index at which to begin reading.
Returns:
The uint16_t that was read from the given index.

uint32_t Phx::BitVector::uint32Field Bits  bitIndex  )  const
 

Reads a uint32_t starting from the given index.

Parameters:
bitIndex The bit index at which to begin reading.
Returns:
The uint32_t that was read from the given index.

uint64_t Phx::BitVector::uint64Field Bits  bitIndex  )  const
 

Reads a uint64_t starting from the given index.

Parameters:
bitIndex The bit index at which to begin reading.
Returns:
The uint64_t that was read from the given index.

uint8_t Phx::BitVector::uint8Field Bits  bitIndex  )  const
 

Reads a uint8_t starting from the given index.

Parameters:
bitIndex The bit index at which to begin reading.
Returns:
The uint8_t that was read from the given index.


The documentation for this class was generated from the following file:
Generated on Mon Jul 10 19:45:30 2006 for Phoenix OSFS by  doxygen 1.4.2