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

Util Class Reference

#include <Util.h>

List of all members.


Detailed Description

Widely used utilities.

This class can not be instantiated, but contains useful (?) static functions.

Typical usage:

  include "Util.h"

  char  * str = Util::strDup( otherStr);
  

Author:
Author
darkeye
Version:
Revision
1.11

Definition at line 66 of file Util.h.

Static Public Member Functions

static unsigned int strLen (const char *str) throw ( Exception )
 Determine a C string's length.
static void strCpy (char *dest, const char *src) throw ( Exception )
 Copy a C string into another.
static void strCat (char *dest, const char *src) throw ( Exception )
 Concatenate a string to another's end.
static char * strDup (const char *str) throw ( Exception )
 Duplicate a string by allocating space with new[].
static bool strEq (const char *str1, const char *str2, unsigned int len=0) throw ( Exception )
 Determine wether two string are equal.
static long int strToL (const char *str, int base=10) throw ( Exception )
 Convert a string to long.
static double strToD (const char *str) throw ( Exception )
 Convert a string to double.
static char * fileAddDate (const char *str) throw ( Exception )
 Add current date to a file name, before the file extension (if any).
static char * base64Encode (const char *str) throw ( Exception )
 Convert a string into base64 encoding.
static void conv (unsigned int bitsPerSample, unsigned char *pcmBuffer, unsigned int lenPcmBuffer, short int *outBuffer, bool isBigEndian=true) throw ( Exception )
 Convert an unsigned char buffer holding 8 or 16 bit PCM values with channels interleaved to a short int buffer, still with channels interleaved.
static void conv (short int *shortBuffer, unsigned int lenShortBuffer, float **floatBuffers, unsigned int channels) throw ( Exception )
 Convert a short buffer holding PCM values with channels interleaved to one or more float buffers, one for each channel.
static void conv8 (unsigned char *pcmBuffer, unsigned int lenPcmBuffer, short int *leftBuffer, short int *rightBuffer, unsigned int channels) throw ( Exception )
 Convert a char buffer holding 8 bit PCM values to a short buffer.
static void conv16 (unsigned char *pcmBuffer, unsigned int lenPcmBuffer, short int *leftBuffer, short int *rightBuffer, unsigned int channels, bool isBigEndian) throw ( Exception )
 Convert a char buffer holding 16 bit PCM values to a short buffer.

Protected Member Functions

 Util (void) throw ( Exception )
 Default constructor.
 Util (const Util &e) throw ( Exception )
 Copy constructor.
 ~Util (void) throw ( Exception )
 Destructor.
Utiloperator= (const Util &u) throw ( Exception )
 Assignment operator.


Constructor & Destructor Documentation

Util::Util void   )  throw ( Exception ) [inline, protected]
 

Default constructor.

Always throws an Exception.

Exceptions:
Exception 

Definition at line 83 of file Util.h.

Util::Util const Util e  )  throw ( Exception ) [inline, protected]
 

Copy constructor.

Always throws an Exception.

Exceptions:
Exception 

Definition at line 94 of file Util.h.

Util::~Util void   )  throw ( Exception ) [inline, protected]
 

Destructor.

Always throws an Exception.

Exceptions:
Exception 

Definition at line 105 of file Util.h.


Member Function Documentation

char * Util::base64Encode const char *  str  )  throw ( Exception ) [static]
 

Convert a string into base64 encoding.

base64 is described in RFC 2045, section 6.8 The returned string must be freed with delete[].

Parameters:
str the string to convert.
Returns:
the supplied string in base64 encoding.
Exceptions:
Exception 

Definition at line 170 of file Util.cpp.

Referenced by IceCast2::sendLogin().

void Util::conv short int *  shortBuffer,
unsigned int  lenShortBuffer,
float **  floatBuffers,
unsigned int  channels
throw ( Exception ) [static]
 

Convert a short buffer holding PCM values with channels interleaved to one or more float buffers, one for each channel.

Parameters:
shortBuffer the input buffer
lenShortBuffer total length of the input buffer
floatBuffers an array of float buffers, each (lenShortBuffer / channels) long
channels number of channels to separate the input to

Definition at line 365 of file Util.cpp.

void Util::conv unsigned int  bitsPerSample,
unsigned char *  pcmBuffer,
unsigned int  lenPcmBuffer,
short int *  outBuffer,
bool  isBigEndian = true
throw ( Exception ) [static]
 

Convert an unsigned char buffer holding 8 or 16 bit PCM values with channels interleaved to a short int buffer, still with channels interleaved.

Parameters:
bitsPerSample the number of bits per sample in the input
pcmBuffer the input buffer
lenPcmBuffer the number of samples total in pcmBuffer (e.g. if 2 channel input, this is twice the number of sound samples)
outBuffer the output buffer, must be big enough
isBigEndian true if the input is big endian, false otherwise

Definition at line 314 of file Util.cpp.

void Util::conv16 unsigned char *  pcmBuffer,
unsigned int  lenPcmBuffer,
short int *  leftBuffer,
short int *  rightBuffer,
unsigned int  channels,
bool  isBigEndian
throw ( Exception ) [static]
 

Convert a char buffer holding 16 bit PCM values to a short buffer.

Parameters:
pcmBuffer buffer holding 16 bit PCM audio values, channels are interleaved
lenPcmBuffer length of pcmBuffer
leftBuffer put the left channel here (must be big enough)
rightBuffer put the right channel here (not touched if mono, must be big enough)
channels number of channels (1 = mono, 2 = stereo)
isBigEndian true if input is big endian, false otherwise

Definition at line 426 of file Util.cpp.

void Util::conv8 unsigned char *  pcmBuffer,
unsigned int  lenPcmBuffer,
short int *  leftBuffer,
short int *  rightBuffer,
unsigned int  channels
throw ( Exception ) [static]
 

Convert a char buffer holding 8 bit PCM values to a short buffer.

Parameters:
pcmBuffer buffer holding 8 bit PCM audio values, channels are interleaved
lenPcmBuffer length of pcmBuffer
leftBuffer put the left channel here (must be big enough)
rightBuffer put the right channel here (not touched if mono, must be big enough)
channels number of channels (1 = mono, 2 = stereo)

Definition at line 386 of file Util.cpp.

char * Util::fileAddDate const char *  str  )  throw ( Exception ) [static]
 

Add current date to a file name, before the file extension (if any).

Parameters:
str the string to convert (file name).
Returns:
the new string with the date appended before extension of the file name. the string has to be deleted with delete[] after it is not needed
Exceptions:
Exception 

Definition at line 274 of file Util.cpp.

Util& Util::operator= const Util u  )  throw ( Exception ) [inline, protected]
 

Assignment operator.

Always throws an Exception.

Parameters:
u the object to assign to this one.
Exceptions:
Exception 

Definition at line 117 of file Util.h.

void Util::strCat char *  dest,
const char *  src
throw ( Exception ) [static]
 

Concatenate a string to another's end.

Parameters:
dest the string to concatenate to. Storage size of dest must be at least Util::strLen(dest) + Util::strLen(src) + 1 long.
src the string to concatenate.
Exceptions:
Exception 

Definition at line 133 of file Util.cpp.

Referenced by IceCast2::sendLogin().

void Util::strCpy char *  dest,
const char *  src
throw ( Exception ) [static]
 

Copy a C string into another.

Parameters:
dest place for the copy. Storage size must be at least Util::strLen(src) + 1 long.
src the string to copy.
Exceptions:
Exception 

Definition at line 118 of file Util.cpp.

Referenced by IceCast2::sendLogin().

char * Util::strDup const char *  str  )  throw ( Exception ) [static]
 

Duplicate a string by allocating space with new[].

The returned string must be freed with delete[].

Parameters:
str the string to duplicate.
Exceptions:
Exception 

Definition at line 149 of file Util.cpp.

bool Util::strEq const char *  str1,
const char *  str2,
unsigned int  len = 0
throw ( Exception ) [static]
 

Determine wether two string are equal.

Parameters:
str1 one of the strings.
str2 the other string.
len check the first most len characters. if 0, check the whole string
Returns:
true if the two strings are equal, false othersize.
Exceptions:
Exception 

Definition at line 214 of file Util.cpp.

Referenced by AudioSource::createDspSource(), and IceCast2::sendLogin().

unsigned int Util::strLen const char *  str  )  throw ( Exception ) [static]
 

Determine a C string's length.

Parameters:
str a zero-terminated C string.
Returns:
length of str
Exceptions:
Exception 

Definition at line 100 of file Util.cpp.

Referenced by IceCast2::sendLogin().

double Util::strToD const char *  str  )  throw ( Exception ) [static]
 

Convert a string to double.

Parameters:
str the string to convert.
Returns:
the value of str as a double
Exceptions:
Exception 

Definition at line 253 of file Util.cpp.

long int Util::strToL const char *  str,
int  base = 10
throw ( Exception ) [static]
 

Convert a string to long.

Parameters:
str the string to convert.
base numeric base of number in str.
Returns:
the value of str as a long int
Exceptions:
Exception 

Definition at line 230 of file Util.cpp.

Referenced by main().


The documentation for this class was generated from the following files:
Generated on Fri May 19 15:36:49 2006 for DarkIce by  doxygen 1.4.4