|
|
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:
u | the 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:
str | a 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:
dest | place for the copy. Storage size must be at least Util::strLen(src) + 1 long. |
str | the string to copy. |
Throws: Exception
void
strCat ( char * dest,
const char * src )
throw ( Exception ) | strCat |
[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. |
str | the 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:
str | the 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:
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.
Throws: Exception
long int
strToL ( const char * str,
int base = 10 )
throw ( Exception ) | strToL |
[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
Throws: Exception
double
strToD ( const char * str )
throw ( Exception ) | strToD |
[static]
Convert a string to double.
Parameters:
str | the 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:
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
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:
str | the 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:
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 |
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:
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 |
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:
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) |
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:
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 |