#include <WOscUtil.h>
Public Types | |
enum | Constants { OSC_INT_SIZE = 4, OSC_FLOAT_SIZE = 4 } |
Static Public Member Functions | |
static int | GetSizeFourByteAligned (const char *string) |
static int | GetSizeFourByteAligned (const int length) |
static void | PadStringWithZeros (char *destString, const char *sourceString) |
static void | PadBufferWithZeros (char *destBuffer, const char *sourceBuffer, int destLen, int srcLen) |
template<class TYPE > | |
static TYPE | BufferTo (const char *buffer) |
template<class TYPE > | |
static void | FillBufferWith (char *buffer, const TYPE &arg) |
Weiss OSC library utilities. Mostly buffer-to-type and type-to-buffer conversions, big/little-endianess issues and 4-byte-boundary utilities.
Definition at line 51 of file WOscUtil.h.
enum WOscUtil::Constants |
Constants used in WOscUtil OSC-argument sizes.
OSC_INT_SIZE |
OSC-argument integer size. |
OSC_FLOAT_SIZE |
OSC-argument float size (Changed from 8 to 4, pointed out by Damian Stewart) . |
Definition at line 86 of file WOscUtil.h.
00086 { 00087 OSC_INT_SIZE = 4, /**< OSC-argument integer size. */ 00088 OSC_FLOAT_SIZE = 4, /**< OSC-argument float size (Changed from 8 to 4, 00089 * pointed out by Damian Stewart) . */ 00090 };
int WOscUtil::GetSizeFourByteAligned | ( | const int | length | ) | [static] |
Rounds up the given integer to the next multiple of 4. Similar to getSizeFourByteAligned(const char* string).
length | Integer which sould be rounded up to the next multiple of 4. |
Definition at line 77 of file WOscUtil.cpp.
int WOscUtil::GetSizeFourByteAligned | ( | const char * | string | ) | [static] |
Get length of string and round up to the next multiple of 4. Gets the size of the string passed as parameter and rounds it up to the next multiple of four.
string | String which size should be rounded. |
Definition at line 57 of file WOscUtil.cpp.
Referenced by WOscString::operator+=(), WOscString::operator=(), PadStringWithZeros(), WOscBlob::WOscBlob(), and WOscString::WOscString().
void WOscUtil::PadBufferWithZeros | ( | char * | destBuffer, | |
const char * | sourceBuffer, | |||
int | destLen, | |||
int | srcLen | |||
) | [static] |
Copies the source buffer to the destination buffer and pads the difference with zeros. The destination buffer must be large enough, i.e. destLen >= srcLen.
Works for every buffer, assumed destLen >= srcLen. If destLen is smaller than srcLen only srcLen data is copied and nothing padded.
destBuffer | Destination string buffer (length must be the rounded-up length of the source string), which receives the padded string. | |
sourceBuffer | Source buffer. | |
destLen | Size of the destination-buffer. | |
srcLen | Size of the source-buffer. |
Definition at line 138 of file WOscUtil.cpp.
void WOscUtil::PadStringWithZeros | ( | char * | destString, | |
const char * | sourceString | |||
) | [static] |
Copies the source string to the destination string and pads it with zeros to the next multiple of four, the destination buffer must be large enough.
destString | Destination string buffer (length must be the rounded-up length of the source string), which receives the padded string. | |
sourceString | The string which should be padded. |
Definition at line 102 of file WOscUtil.cpp.
References GetSizeFourByteAligned().
Referenced by WOscString::operator=(), and WOscString::WOscString().
00103 { 00104 int length = (int)strlen(sourceString) + 1; 00105 int osclength = GetSizeFourByteAligned(sourceString); 00106 00107 strcpy(destString, sourceString); 00108 00109 for ( int i = length; i < osclength; i++ ) 00110 destString[i] = '\0'; 00111 }