seven bits

bit::ibstream Class Reference
["Deprecated Classes"]

#include <bit/ibstream.h>

Inheritance diagram for bit::ibstream:

bit::bstream

List of all members.


Detailed Description

Manage an input stream with facilities for bitwise extraction.

Author:
Rick L Vinyard Jr

Public Member Functions

 ibstream ()
 Create an ibstream with no attached stream source.
 ibstream (std::istream &input)
 Create an ibstream from a standard stream source.
virtual ~ibstream ()
 Performs any stream cleanup including output of any remaining bits.
size_t read_octets (unsigned char *buf, size_t octets)
 MSB read of up to n octets into a memory buffer.
size_t read_octets (unsigned char *buf, size_t bufsize, size_t octets)
 LSB read of up to n octets into a memory buffer of size m with zero padding.
size_t read_bits (unsigned char *buf, size_t bits)
 MSB bit read of up to n bits into a memory buffer.
size_t read_bits (unsigned char *buf, size_t bufsize, size_t bits)
 LSB bit read of up to n bits into a memory buffer of size m octets with zero padding.
template<typename T>
size_t read_octets (T &t, size_t n=sizeof(T))
 LSB read of up to n octets into variable t with zero padding.
size_t read_octets (uint16_t &t, size_t n=2)
size_t read_octets (uint32_t &t, size_t n=4)
size_t read_octets (uint64_t &t, size_t n=8)
size_t read_octets (int16_t &t, size_t n=2)
size_t read_octets (int32_t &t, size_t n=4)
size_t read_octets (int64_t &t, size_t n=8)
template<typename T>
size_t read_bits (T &t, size_t n=sizeof(T)*8)
 LSB read of up to n bits into variable t with zero padding.
size_t read_bits (uint16_t &t, size_t n=2)
size_t read_bits (uint32_t &t, size_t n=4)
size_t read_bits (uint64_t &t, size_t n=8)
size_t read_bits (int16_t &t, size_t n=2)
size_t read_bits (int32_t &t, size_t n=4)
size_t read_bits (int64_t &t, size_t n=8)
void attach_stream (std::istream &stream, bool clearbits=false)
 Set the associated input stream to stream.
void detach_stream (bool clearbits=false)
 Remove the currently attached stream.

Protected Attributes

std::istream * m_input
 A pointer to the associated input stream.

Friends

ibstreamoperator>> (ibstream &s, const bits &b)
ibstreamoperator>> (ibstream &s, const octets &o)
ibstreamoperator>> (ibstream &s, const whole &w)
template<typename T>
ibstreamoperator>> (ibstream &s, T &t)

Constructor & Destructor Documentation

ibstream::ibstream (  ) 

Create an ibstream with no attached stream source.

ibstream::ibstream ( std::istream &  input  ) 

Create an ibstream from a standard stream source.

The stream source will be used to retrieve actual data from.

ibstream::~ibstream (  )  [virtual]

Performs any stream cleanup including output of any remaining bits.


Member Function Documentation

size_t ibstream::read_octets ( unsigned char *  buf,
size_t  octets 
)

MSB read of up to n octets into a memory buffer.

This method will only result in whole octet reads. Thus, if there are 4 bits buffered, a request for 4 octets is made, and 2 octets are actually available only 2 octets will be read with 4 bits still buffered.

Returns:
the number of octets read

References m_input, bit::bstream::m_leftoverbits, bit::bstream::m_masks, and bit::bstream::m_numleftoverbits.

Referenced by bit::operator>>(), read_bits(), and read_octets().

size_t ibstream::read_octets ( unsigned char *  buf,
size_t  bufsize,
size_t  octets 
)

LSB read of up to n octets into a memory buffer of size m with zero padding.

LSB, is not necessarily x86 little endian! A read of 1234 into a 6 octet buffer results in 001234. If n is greater than m, only m octets will be read.

Returns:
the number of octets read.

References m_input, and read_octets().

size_t ibstream::read_bits ( unsigned char *  buf,
size_t  bits 
)

MSB bit read of up to n bits into a memory buffer.

Returns:
the number of bits read

References m_input, bit::bstream::m_leftoverbits, bit::bstream::m_masks, bit::bstream::m_numleftoverbits, and read_octets().

Referenced by bit::operator>>(), and read_bits().

size_t ibstream::read_bits ( unsigned char *  buf,
size_t  bufsize,
size_t  bits 
)

LSB bit read of up to n bits into a memory buffer of size m octets with zero padding.

No adjustment is made for x86 integer or any other architectures or types.

Returns:
the number of bits read

References m_input, bit::bstream::m_numleftoverbits, and read_bits().

template<typename T>
size_t bit::ibstream::read_octets ( T &  t,
size_t  n = sizeof(T) 
) [inline]

LSB read of up to n octets into variable t with zero padding.

For architecture specific integer types the "right" thing is done to result in a usable value. The default is to read the entire variable off the stream.

References m_input, and read_octets().

size_t ibstream::read_octets ( uint16_t &  t,
size_t  n = 2 
)

References m_input, and read_octets().

size_t ibstream::read_octets ( uint32_t &  t,
size_t  n = 4 
)

References m_input, and read_octets().

size_t ibstream::read_octets ( uint64_t &  t,
size_t  n = 8 
)

References m_input, and read_octets().

size_t ibstream::read_octets ( int16_t &  t,
size_t  n = 2 
)

References m_input, and read_octets().

size_t ibstream::read_octets ( int32_t &  t,
size_t  n = 4 
)

References m_input, and read_octets().

size_t ibstream::read_octets ( int64_t &  t,
size_t  n = 8 
)

References m_input, and read_octets().

template<typename T>
size_t bit::ibstream::read_bits ( T &  t,
size_t  n = sizeof(T)*8 
) [inline]

LSB read of up to n bits into variable t with zero padding.

For architecture specific integer types the "right" thing is done to result in a usable value. The default is to read the entire variable off the stream.

References m_input, bit::bstream::m_numleftoverbits, and read_bits().

size_t ibstream::read_bits ( uint16_t &  t,
size_t  n = 2 
)

size_t ibstream::read_bits ( uint32_t &  t,
size_t  n = 4 
)

size_t ibstream::read_bits ( uint64_t &  t,
size_t  n = 8 
)

size_t ibstream::read_bits ( int16_t &  t,
size_t  n = 2 
)

size_t ibstream::read_bits ( int32_t &  t,
size_t  n = 4 
)

size_t ibstream::read_bits ( int64_t &  t,
size_t  n = 8 
)

void ibstream::attach_stream ( std::istream &  stream,
bool  clearbits = false 
)

Set the associated input stream to stream.

Parameters:
clearbits If true any cached bits will be cleared, and if false (default) cached bits remain available for reading.

References m_input, bit::bstream::m_leftoverbits, and bit::bstream::m_numleftoverbits.

void ibstream::detach_stream ( bool  clearbits = false  ) 

Remove the currently attached stream.

Futher attempts to read will fail unless there are cached bits.

Parameters:
clearbits If true any cached bits will be cleared, and if false (default) cached bits remain available for reading.

References m_input, bit::bstream::m_leftoverbits, and bit::bstream::m_numleftoverbits.


Friends And Related Function Documentation

ibstream& operator>> ( ibstream s,
const bits b 
) [friend]

ibstream& operator>> ( ibstream s,
const octets o 
) [friend]

ibstream& operator>> ( ibstream s,
const whole w 
) [friend]

template<typename T>
ibstream& operator>> ( ibstream s,
T &  t 
) [friend]


Member Data Documentation

std::istream* bit::ibstream::m_input [protected]

A pointer to the associated input stream.

A reference is not used since it is anticipated that future versions will provide a constructor that does not require an associated stream.

Referenced by attach_stream(), detach_stream(), read_bits(), and read_octets().


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

Generated on Mon Nov 3 10:50:01 2008 for bit by doxygen 1.5.6