Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

uint28 Class Reference

Class representation of an unsigned 28-bit integer for use in an ID3v2 tag. More...

#include <uint28.h>

List of all members.

Public Methods

 uint28 (uint32 val=0)
 Default constructor. More...

 uint28 (const uchar *data)
 Creates a uint28 object from a character string. More...

 uint28 (const uint28 &rhs)
 Copy constructor. More...

virtual ~uint28 ()
uint28 & operator= (uint32 val)
 Assigns a uint28 object a new value. More...

uint28 & operator= (const uint28 &rhs)
 Assignment operator. More...

uint28 & operator= (const uchar *data)
 Unsigned Character string assignment operator. More...

uint28 & operator= (const char *data)
 Character string assignment operator. More...

uint32 to_uint32 () const
 Converts the unsigned 28-bit integer object to a built-in unsigned 32-bit integer. More...

size_t Parse (const uchar *data)
 Extracts a 28-bit integer from a character string. More...

size_t Parse (const char *data)
size_t Render (uchar *) const
 Renders a 28-bit integer to a character string. More...

size_t Render (char *) const

Static Public Attributes

const unsigned short BITSUSED = 7
 The number of bits used per byte of an unsigned 28-bit integer *. More...

const uint32 MINVAL = 0
 The minimum value this class can represent *. More...

const uint32 MAXVAL = MASK(BITSUSED*sizeof(uint32))
 The maximum value this class can represent (2^28-1) *. More...


Detailed Description

Class representation of an unsigned 28-bit integer for use in an ID3v2 tag.

The ID3v2 tag specification (http://www.id3.org) defines an unsigned 28-bit integer in which the most-significant bit in each of the integer's 4 bytes is set to 0. This is done to avoid having integers in an id3v2 tag that might be mistaken for an MP3 sync-signal, which is why this representation is sometimes referred to as "syncsafe integers."

Since these 4 bits are unavailable as representation of the integer, this leaves 28 bits to define its value. Therefore a uint28 object can represent values between 0 and 2^28-1 (or ~256M)

To be useful within id3lib's implementation of the ID3v2 spec, the uint28 class enables instantiations to be created from and written to 4-byte (or more) character buffers. In keeping with the ID3v2 spec, uint28 numbers use a big-endian byte ordering, such that the number 0x12345678 is represented as 0x12 0x34 0x56 0x78 in byte form. A big-endian representation of 255, normally 0x00 0x00 0x00 0xFF for 32-bit integers, would be 0x00 0x00 0x01 0x7F for a 28-bit integer.


Constructor & Destructor Documentation

uint28::uint28 uint32 val = 0 [inline, explicit]
 

Default constructor.

Parameters:
val   The initial value for the (defaults to 0)

uint28::uint28 const uchar * data [inline, explicit]
 

Creates a uint28 object from a character string.

Parameters:
data   The character string to parse to create the uint28 object

uint28::uint28 const uint28 & rhs [inline]
 

Copy constructor.

Parameters:
rhs   The uint28 object to copy

virtual uint28::~uint28 [inline, virtual]
 


Member Function Documentation

size_t uint28::Parse const char * data
 

size_t uint28::Parse const uchar * data
 

Extracts a 28-bit integer from a character string.

Parameters:
data   The character string to parse (should be at least 4 characters in length)
Returns:
The number of characters parsed (should always be 4)

size_t uint28::Render char * data const
 

size_t uint28::Render uchar * data const
 

Renders a 28-bit integer to a character string.

Parameters:
data   The character string to render to (should be at least 4 characters in length)
Returns:
The number of characters render (should always be 4)

uint28& uint28::operator= const char * data [inline]
 

Character string assignment operator.

Parameters:
data   The character string from which to extract a 28-bit integer (must be at least 4 characters long)
Returns:
The newly-assigned uint28 object (*this)

uint28& uint28::operator= const uchar * data [inline]
 

Unsigned Character string assignment operator.

Parameters:
data   The character string from which to extract a 28-bit integer (must be at least 4 characters long)
Returns:
The newly-assigned uint28 object (*this)

uint28& uint28::operator= const uint28 & rhs [inline]
 

Assignment operator.

Parameters:
rhs   The uint28 object to copy
Returns:
The newly-assigned uint28 object (*this)

uint28& uint28::operator= uint32 val [inline]
 

Assigns a uint28 object a new value.

If the value assigned is greater than can be represented,

Parameters:
val   The new value to assign to this uint28 object (should be less than 2^28)
Returns:
The newly-assigned uint28 object (*this)

uint32 uint28::to_uint32 const [inline]
 

Converts the unsigned 28-bit integer object to a built-in unsigned 32-bit integer.


Member Data Documentation

const unsigned short uint28::BITSUSED = 7 [static]
 

The number of bits used per byte of an unsigned 28-bit integer *.

const uint32 uint28::MAXVAL = MASK(BITSUSED*sizeof(uint32)) [static]
 

The maximum value this class can represent (2^28-1) *.

const uint32 uint28::MINVAL = 0 [static]
 

The minimum value this class can represent *.


The documentation for this class was generated from the following files:
Generated at Wed Sep 5 16:53:39 2001 for id3lib by doxygen1.2.9.1 written by Dimitri van Heesch, © 1997-2001