bit::ibstream Class Reference
[Deprecated]

#include <bit/ibstream.h>

Inheritance diagram for bit::ibstream:

Inheritance graph
[legend]
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 std::istream &  input  ) 
 

Create an ibstream from a standard stream source.

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


Member Function Documentation

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.

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.

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.

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

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

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.

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.

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


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.


The documentation for this class was generated from the following files:
Generated on Thu Jul 6 14:38:09 2006 by  doxygen 1.4.6