A simple OSC Data composer and parser. A OSC data starts with an address string followed by a format string. This is followed by the data. You need to call the read and write methods in the sequence defined by the format string. There is no validation for this, so you need to be careful and test your code properly. To compose a message call:
More...
#include <OSCData.h>
|
| | OSCData ()=default |
| | Data for receiving:
|
| |
| | OSCData (uint8_t *data, uint32_t maxlen) |
| | Data for sending.
|
| |
| bool | addCallback (const char *address, bool(*callback)(OSCData &data, void *ref), OSCCompare compare=OSCCompare::Matches) |
| | register a parsing callback for a specific address matching string
|
| |
| void | clear () |
| | clears all data
|
| |
| uint8_t * | data () |
| |
| const char * | getAddress () |
| | provides the address: after calling parse
|
| |
| const char * | getFormat () |
| | provides the format string: after calling parse
|
| |
| void | logMsg (uint8_t *data, int len) |
| |
| OSCBinaryData & | messageData () |
| |
| bool | parse (uint8_t *data, size_t len) |
| | parse the data to start for reading
|
| |
| const OSCBinaryData | readData () |
| | reads the next attribute as binary data blob.
|
| |
| double | readDouble () |
| | reads the next attribute as double
|
| |
| float | readFloat () |
| | reads the next attributes as float
|
| |
| int32_t | readInt32 () |
| | reads the next attribute as int32
|
| |
| int64_t | readInt64 () |
| | reads the next attribute as long
|
| |
| const char * | readString () |
| | reads the next string
|
| |
| uint64_t | readTime () |
| | reads the next attribute as uint64_t
|
| |
| void | setAddress (const char *address) |
| | Defines the address string (e.g. /test)
|
| |
| void | setFormat (const char *format) |
| | Defines the format string (e.g. ,iif)
|
| |
| void | setLogActive (bool active) |
| | Log the beginning of the received messages.
|
| |
| void | setReference (void *ref) |
| | store a reference object (for callback)
|
| |
| int | size () |
| | returns the number of bytes written (or parsed)
|
| |
| bool | write (const char *str) |
| | write a string (s)
|
| |
| bool | write (const uint8_t *dataArg, int len) |
| | write a binary blob (b)
|
| |
| bool | write (double fp64) |
| | write a 64bit double number (d)
|
| |
| bool | write (int32_t number) |
| | write an int32_t number (i)
|
| |
| bool | write (int64_t number) |
| | write an int64_t number
|
| |
| bool | write (OSCBinaryData &data) |
| | write a binary blob (b)
|
| |
| bool | write (uint64_t number) |
| | write a timetag (t) data type
|
| |
|
| static int | oscFormatSize (const char *str) |
| | storage size (multiple of 4) for format string (w/o the leading ,)
|
| |
| static int | oscFormatSize (int len) |
| | storage size (multiple of 4) for format string (w/o the leading ,)
|
| |
| static int | oscSize (const char *str) |
| | storage size (multiple of 4) for string
|
| |
| static int | oscSize (int len) |
| | storage size (multiple of 4)
|
| |
| static int | oscSize (OSCBinaryData data) |
| | storage size (multiple of 4) for binary blob data
|
| |
A simple OSC Data composer and parser. A OSC data starts with an address string followed by a format string. This is followed by the data. You need to call the read and write methods in the sequence defined by the format string. There is no validation for this, so you need to be careful and test your code properly. To compose a message call:
To parse a message call:
- parse() to parse the message
- getAddress() to get the address
- getFormat() to get the format string
- readXxxx() to read the data ... I recommend to register for each address and process the reads in the callback
OSC V1.0 Specification: https://opensoundcontrol.stanford.edu/spec-1_0.html
- Author
- Phil Schatzmann
- Copyright
- GPLv3
◆ OSCData() [1/2]
◆ OSCData() [2/2]
| OSCData |
( |
uint8_t * |
data, |
|
|
uint32_t |
maxlen |
|
) |
| |
|
inline |
◆ addCallback()
register a parsing callback for a specific address matching string
replace existing callback
◆ clear()
◆ compare()
| bool compare |
( |
OSCCompare |
compare, |
|
|
const char * |
strRef, |
|
|
const char * |
strCompare |
|
) |
| |
|
inlineprotected |
◆ data()
provides access to the original binary message (defined in the constructor or via parse())
◆ getAddress()
| const char * getAddress |
( |
| ) |
|
|
inline |
provides the address: after calling parse
◆ getEnd()
◆ getFormat()
| const char * getFormat |
( |
| ) |
|
|
inline |
provides the format string: after calling parse
◆ logMsg()
| void logMsg |
( |
uint8_t * |
data, |
|
|
int |
len |
|
) |
| |
|
inline |
◆ messageData()
provides access to the original binary message (defined in the constructor or via parse())
◆ oscFormatSize() [1/2]
| static int oscFormatSize |
( |
const char * |
str | ) |
|
|
inlinestatic |
storage size (multiple of 4) for format string (w/o the leading ,)
◆ oscFormatSize() [2/2]
| static int oscFormatSize |
( |
int |
len | ) |
|
|
inlinestatic |
storage size (multiple of 4) for format string (w/o the leading ,)
◆ oscSize() [1/3]
| static int oscSize |
( |
const char * |
str | ) |
|
|
inlinestatic |
storage size (multiple of 4) for string
◆ oscSize() [2/3]
| static int oscSize |
( |
int |
len | ) |
|
|
inlinestatic |
storage size (multiple of 4)
◆ oscSize() [3/3]
storage size (multiple of 4) for binary blob data
◆ parse()
| bool parse |
( |
uint8_t * |
data, |
|
|
size_t |
len |
|
) |
| |
|
inline |
parse the data to start for reading
call callback if there are any
◆ readData()
reads the next attribute as binary data blob.
◆ readDouble()
reads the next attribute as double
◆ readFloat()
reads the next attributes as float
◆ readInt32()
reads the next attribute as int32
◆ readInt64()
reads the next attribute as long
◆ readString()
| const char * readString |
( |
| ) |
|
|
inline |
◆ readTime()
reads the next attribute as uint64_t
◆ setAddress()
| void setAddress |
( |
const char * |
address | ) |
|
|
inline |
Defines the address string (e.g. /test)
◆ setFormat()
| void setFormat |
( |
const char * |
format | ) |
|
|
inline |
Defines the format string (e.g. ,iif)
◆ setLogActive()
| void setLogActive |
( |
bool |
active | ) |
|
|
inline |
Log the beginning of the received messages.
◆ setReference()
| void setReference |
( |
void * |
ref | ) |
|
|
inline |
store a reference object (for callback)
◆ size()
returns the number of bytes written (or parsed)
◆ write() [1/7]
| bool write |
( |
const char * |
str | ) |
|
|
inline |
◆ write() [2/7]
| bool write |
( |
const uint8_t * |
dataArg, |
|
|
int |
len |
|
) |
| |
|
inline |
◆ write() [3/7]
| bool write |
( |
double |
fp64 | ) |
|
|
inline |
write a 64bit double number (d)
◆ write() [4/7]
| bool write |
( |
int32_t |
number | ) |
|
|
inline |
write an int32_t number (i)
◆ write() [5/7]
| bool write |
( |
int64_t |
number | ) |
|
|
inline |
◆ write() [6/7]
◆ write() [7/7]
| bool write |
( |
uint64_t |
number | ) |
|
|
inline |
write a timetag (t) data type
◆ binary_content
◆ callbacks
◆ is_log_active
| bool is_log_active = false |
|
protected |
◆ read_data
| uint8_t* read_data = nullptr |
|
protected |
◆ read_format_start
| uint8_t* read_format_start = nullptr |
|
protected |
◆ reference
| void* reference = nullptr |
|
protected |
◆ write_pos
The documentation for this class was generated from the following file: