#include <WOscBlob.h>
Public Types | |
enum | Constants { BLOB_SIZE_SIZE = 4 } |
Public Member Functions | |
WOscBlob (const char *binaryData) | |
WOscBlob (const char *binaryData, int dataLen) | |
WOscBlob (WOscBlob *b) | |
WOscBlob (WOscBlob &b) | |
virtual | ~WOscBlob () |
WOscBlob & | operator= (WOscBlob &rhs) |
int | GetDataLen () const |
const char * | GetData () const |
int | GetBufferLen () const |
void | GetBuffer (char *buffer, int bufferLen) const |
const char * | GetBuffer () const |
Encapsulates an OSC-blob for transmission of binary data. Used to transport proprietary data over the OSC-protocol. Inherit your own class from this object, for instance a firmware-packet class, which could transport binary data fo firmware updates.
Definition at line 61 of file WOscBlob.h.
enum WOscBlob::Constants |
Definition at line 78 of file WOscBlob.h.
00078 { 00079 BLOB_SIZE_SIZE = 4, /**< Size of blob's size. */ 00080 };
WOscBlob::WOscBlob | ( | const char * | binaryData | ) |
Constructor for WOscBlobs from a binary buffer containing an WOscBlob in its binary representation ( [blobsize][blobdata] ).
binaryData | Pointer to the buffer containing the raw data. |
Definition at line 56 of file WOscBlob.cpp.
References BLOB_SIZE_SIZE, WOscUtil::GetSizeFourByteAligned(), and WOscBlob().
Referenced by WOscBlob().
00057 { 00058 // get blob size 00059 m_dataLen = WOscUtil::BufferTo<int>(binaryData); 00060 m_bufferLen = WOscUtil::GetSizeFourByteAligned( m_dataLen ) + BLOB_SIZE_SIZE; 00061 m_buffer = new char[m_bufferLen] ; 00062 00063 // write data to buffer 00064 memcpy(m_buffer, binaryData, m_bufferLen); 00065 }
WOscBlob::WOscBlob | ( | const char * | binaryData, | |
int | dataLen | |||
) |
Constructs a WOscBlob-object from a binary buffer. The buffer is internally rounded up to a multiple of 4. If querying fo buffer size, the padded size is returned. To get the actual data length, use the GetDataLen() function.
binaryData | Buffer with data of length "dataLen". | |
dataLen | Length of data supplied with "binaryData". |
None. |
+-------------------+----//---------------------+ | size of blob data | blob data + padding zeros | +-------------------+---------------------------+ |----- 4 bytes -----|-- size rounded up bytes --|
Definition at line 107 of file WOscBlob.cpp.
References BLOB_SIZE_SIZE, WOscUtil::GetSizeFourByteAligned(), and WOscBlob().
00108 { 00109 m_dataLen = dataLen; 00110 00111 /* round up and allocate */ 00112 m_bufferLen = WOscUtil::GetSizeFourByteAligned(dataLen) + BLOB_SIZE_SIZE; 00113 m_buffer = new char[m_bufferLen]; 00114 00115 /* write size to buffer */ 00116 WOscUtil::FillBufferWith(m_buffer, dataLen); 00117 00118 /* write data to buffer */ 00119 memcpy(m_buffer + BLOB_SIZE_SIZE, binaryData, m_dataLen); 00120 00121 /* zeropad buffer */ 00122 for ( int i = m_dataLen + BLOB_SIZE_SIZE; i < m_bufferLen; i++ ) 00123 m_buffer[i] = 0; 00124 }
WOscBlob::WOscBlob | ( | WOscBlob * | b | ) |
Pointer-copy-constructor. Copies the content of the referenced blob into this one.
b | Reference to another blob. |
None. |
Definition at line 160 of file WOscBlob.cpp.
References WOscBlob().
WOscBlob::WOscBlob | ( | WOscBlob & | b | ) |
Copy-constructor. Copies the content of the referenced blob into this one.
b | Reference to another blob. |
None. |
Definition at line 177 of file WOscBlob.cpp.
References WOscBlob().
WOscBlob::~WOscBlob | ( | ) | [virtual] |
Deletes the WOscBlob-object. The internal buffer gets deleted.
None. |
Definition at line 191 of file WOscBlob.cpp.
const char * WOscBlob::GetBuffer | ( | ) | const |
Returns a pointer to an internal buffer containing the current binary representation of this blob. Please see remarks for safety issues.
None. |
Definition at line 271 of file WOscBlob.cpp.
void WOscBlob::GetBuffer | ( | char * | buffer, | |
int | bufferLen | |||
) | const |
Fills the buffer with the raw bytestream of this blob. The user must supply the buffer of apropriate size.
buffer | Caller supplied destination buffer. | |
bufferLen | Length of the supplied buffer. |
WOscException | When caller supplied buffer too small. |
Definition at line 246 of file WOscBlob.cpp.
References ERR_BUFFER_TO_SMALL.
00247 { 00248 if ( bufferLen < m_bufferLen ) 00249 throw WOscException(ERR_BUFFER_TO_SMALL, __FILE__, __LINE__); 00250 memcpy(buffer, m_buffer, m_bufferLen); 00251 }
int WOscBlob::GetBufferLen | ( | ) | const |
Returns the buffer-length of the formatted buffer. This length includes zero-padding and size of the blob size.
Definition at line 220 of file WOscBlob.cpp.
Referenced by WOscMessage::WOscMessage().
const char * WOscBlob::GetData | ( | ) | const |
Returns a pointer to the blob data. Get the length of the buffer with WOscBlob::GetDataLength() .
Definition at line 73 of file WOscBlob.cpp.
References BLOB_SIZE_SIZE.
00074 { 00075 return m_buffer + BLOB_SIZE_SIZE; 00076 }
int WOscBlob::GetDataLen | ( | ) | const |
Returns the length of the data without zero-padding.
Definition at line 205 of file WOscBlob.cpp.
Assignment operator. Copies the content of the referenced blob into this one.
rhs | Reference to another blob (right hand side of operator). |
None. |
Definition at line 137 of file WOscBlob.cpp.