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

Bitarray< T > Class Template Reference

Compact struct of items with variable bit length. More...

List of all members.

Public Member Functions

 Bitarray (Bitstream &bs)
void Write (Bitstream &bs) const
int Get (int i) const
void Set (int i, int x)
int Max (int i) const
unsigned int operator^ (int i) const


Detailed Description

template<typename T>
class Bitarray< T >

Compact struct of items with variable bit length.

In ordinary C struct items must end on byte boundary, but in MP3 files fields have variable bit length. This class works line C struct, but unfortunately operator '.' can't be overloaded, I had to use '^' with low priority. Items can be selected via an enum to emulate C struct.

Definition at line 20 of file bitarray.h.


Constructor & Destructor Documentation

template<typename T>
Bitarray< T >::Bitarray Bitstream bs  )  [inline]
 

Constructor

Reads needed bits from Bitstream

Parameters:
bs Input Bitstream

Definition at line 31 of file bitarray.h.


Member Function Documentation

template<typename T>
int Bitarray< T >::Get int  i  )  const [inline]
 

Returns value of an field

Warning:
Field can't spread over integer boundary!
Parameters:
i Field number
Returns:
Field value

Definition at line 53 of file bitarray.h.

Referenced by Bitarray< mp3_frame_header >::operator^().

template<typename T>
int Bitarray< T >::Max int  i  )  const [inline]
 

Get maximum value of a field

Parameters:
i Field number
Returns:
Maximum value of a field

Definition at line 89 of file bitarray.h.

template<typename T>
unsigned int Bitarray< T >::operator^ int  i  )  const [inline]
 

Returns value of a field

Just a shortcut for get() to imitate C struct, so bitarray^field can be used instead of bitarray.get(field), if 'field' is enumeration value.

Warning:
Operator^ has a low priority!
Parameters:
i Field number
Returns:
Field value

Definition at line 105 of file bitarray.h.

template<typename T>
void Bitarray< T >::Set int  i,
int  x
[inline]
 

Sets value of a field

Warning:
Field can't spread over a byte boundary!
Parameters:
i Field number
x Field value

Definition at line 69 of file bitarray.h.

Referenced by FrameHeader::Enlarge().

template<typename T>
void Bitarray< T >::Write Bitstream bs  )  const [inline]
 

Writes bits to Bitstream

Parameters:
bs Output Bitstream

Definition at line 41 of file bitarray.h.

Referenced by FrameHeader::Write().


Generated on Wed Sep 6 00:18:17 2006 for Kraken by  doxygen 1.4.4