class Util

Widely used utilities. More...

Definition#include <Util.h>
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Static Methods

Protected Methods

Private 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);

static char base64Table[]

base64Table[]

[private]

inline  Util ( void )
throw ( Exception )

Util

[protected]

Default constructor. Always throws an Exception.

Throws: Exception

inline  Util ( const Util & e )
throw ( Exception )

Util

[protected]

Copy constructor. Always throws an Exception.

Throws: Exception

inline  ~Util ( void )
throw ( Exception )

~Util

[protected]

Destructor. Always throws an Exception.

Throws: Exception

inline Util &  operator= ( const Util & u )
throw ( Exception )

operator=

[protected]

Assignment operator. Always throws an Exception.

Parameters:
uthe object to assign to this one.

Throws: Exception

unsigned int  strLen ( const char * str )
throw ( Exception )

strLen

[static]

Determine a C string's length.

Parameters:
stra zero-terminated C string.

Returns: length of str

Throws: Exception

void  strCpy ( char * dest, const char * src )
throw ( Exception )

strCpy

[static]

Copy a C string into another.

Parameters:
destplace for the copy. Storage size must be at least Util::strLen(src) + 1 long.
strthe string to copy.

Throws: Exception

void  strCat ( char * dest, const char * src )
throw ( Exception )

strCat

[static]

Concatenate a string to another's end.

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

Throws: Exception

char *  strDup ( const char * str )
throw ( Exception )

strDup

[static]

Duplicate a string by allocating space with new[]. The returned string must be freed with delete[].

Parameters:
strthe string to duplicate.

Throws: Exception

bool  strEq ( const char * str1, const char * str2, unsigned int len = 0 )
throw ( Exception )

strEq

[static]

Determine wether two string are equal.

Parameters:
str1one of the strings.
str2the other string.
lencheck the first most len characters. if 0, check the whole string

Returns: true if the two strings are equal, false othersize.

Throws: Exception

long int  strToL ( const char * str, int base = 10 )
throw ( Exception )

strToL

[static]

Convert a string to long.

Parameters:
strthe string to convert.
basenumeric base of number in str.

Returns: the value of str as a long int

Throws: Exception

double  strToD ( const char * str )
throw ( Exception )

strToD

[static]

Convert a string to double.

Parameters:
strthe string to convert.

Returns: the value of str as a double

Throws: Exception

char *  fileAddDate ( const char * str )
throw ( Exception )

fileAddDate

[static]

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

Parameters:
strthe 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

Throws: Exception

char *  base64Encode ( const char * str )
throw ( Exception )

base64Encode

[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:
strthe string to convert.

Returns: the supplied string in base64 encoding.

Throws: Exception

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

conv

[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:
bitsPerSamplethe number of bits per sample in the input
pcmBufferthe input buffer
lenPcmBufferthe number of samples total in pcmBuffer (e.g. if 2 channel input, this is twice the number of sound samples)
outBufferthe output buffer, must be big enough
isBigEndiantrue if the input is big endian, false otherwise

void  conv ( short int * shortBuffer, unsigned int lenShortBuffer, float ** floatBuffers, unsigned int channels )
throw ( Exception )

conv

[static]

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

Parameters:
shortBufferthe input buffer
lenShortBuffertotal length of the input buffer
floatBuffersan array of float buffers, each (lenShortBuffer / channels) long
channelsnumber of channels to separate the input to

void  conv8 ( unsigned char * pcmBuffer, unsigned int lenPcmBuffer, short int * leftBuffer, short int * rightBuffer, unsigned int channels )
throw ( Exception )

conv8

[static]

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

Parameters:
pcmBufferbuffer holding 8 bit PCM audio values, channels are interleaved
lenPcmBufferlength of pcmBuffer
leftBufferput the left channel here (must be big enough)
rightBufferput the right channel here (not touched if mono, must be big enough)
channelsnumber of channels (1 = mono, 2 = stereo)

void  conv16 ( unsigned char * pcmBuffer, unsigned int lenPcmBuffer, short int * leftBuffer, short int * rightBuffer, unsigned int channels, bool isBigEndian )
throw ( Exception )

conv16

[static]

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

Parameters:
pcmBufferbuffer holding 16 bit PCM audio values, channels are interleaved
lenPcmBufferlength of pcmBuffer
leftBufferput the left channel here (must be big enough)
rightBufferput the right channel here (not touched if mono, must be big enough)
channelsnumber of channels (1 = mono, 2 = stereo)
isBigEndiantrue if input is big endian, false otherwise