Real Time Open Sound Control librtosc
Loading...
Searching...
No Matches
Classes | Functions
pretty-format.h File Reference

Header for pretty printer and scanner. More...

#include <rtosc/rtosc.h>

Go to the source code of this file.

Classes

struct  rtosc_print_options
 

Functions

size_t rtosc_print_arg_val (const rtosc_arg_val_t *arg, char *buffer, size_t buffersize, const rtosc_print_options *opt, int *cols_used)
 Pretty-print rtosct_arg_val_t structure into buffer.
 
size_t rtosc_print_arg_vals (const rtosc_arg_val_t *args, size_t n, char *buffer, size_t bs, const rtosc_print_options *opt, int cols_used)
 Pretty-print rtosct_arg_val_t array into buffer.
 
size_t rtosc_print_message (const char *address, const rtosc_arg_val_t *args, size_t n, char *buffer, size_t bs, const rtosc_print_options *opt, int cols_used)
 Pretty-print OSC message into string buffer.
 
const char * rtosc_skip_next_printed_arg (const char *src, int *skipped, char *type, const char *llhssrc, int follow_ellipsis, int inside_bundle)
 Skip characters from a string until one argument value would have been scanned.
 
int rtosc_count_printed_arg_vals (const char *src)
 Count arguments that would be scanned and do a complete syntax check.
 
int rtosc_count_printed_arg_vals_of_msg (const char *msg)
 Count arguments of a message that would be scanned and do a complete syntax check.
 
size_t rtosc_scan_arg_val (const char *src, rtosc_arg_val_t *arg, size_t n, char *buffer_for_strings, size_t *bufsize, size_t args_before, int follow_ellipsis)
 Scan one argument value from a string.
 
size_t rtosc_scan_arg_vals (const char *src, rtosc_arg_val_t *args, size_t n, char *buffer_for_strings, size_t bufsize)
 Scan a fixed number of argument values from a string.
 
size_t rtosc_scan_message (const char *src, char *address, size_t adrsize, rtosc_arg_val_t *args, size_t n, char *buffer_for_strings, size_t bufsize)
 Scan an OSC message from a string.
 

Detailed Description

Header for pretty printer and scanner.

Test
pretty-format.c

Function Documentation

◆ rtosc_count_printed_arg_vals()

int rtosc_count_printed_arg_vals ( const char * src)

Count arguments that would be scanned and do a complete syntax check.

This function should be run before rtosc_scan_arg_vals() in order to know the number of argument values. Also, rtosc_scan_arg_vals() does no complete syntax check.

Parameters
srcThe string to scan from
Returns
The number of arguments that can be scanned (>0), or if the nth arg (range 1...) can not be scanned, -n. Array arguments and array start each count as one argument. This function never returns 0

◆ rtosc_count_printed_arg_vals_of_msg()

int rtosc_count_printed_arg_vals_of_msg ( const char * msg)

Count arguments of a message that would be scanned and do a complete syntax check.

Parameters
msgThe message to scan from
Returns
-1 if the address could not be scanned, INT_MIN if the whole string is whitespace, otherwise
See also
rtosc_count_printed_arg_vals

◆ rtosc_print_arg_val()

size_t rtosc_print_arg_val ( const rtosc_arg_val_t * arg,
char * buffer,
size_t buffersize,
const rtosc_print_options * opt,
int * cols_used )

Pretty-print rtosct_arg_val_t structure into buffer.

Ranges are not being compressed (use rtosc_print_arg_vals instead).

Parameters
argPointer to the structure that shall be printed
bufferThe buffer to write to
buffersizeThe maximum size to write to, includin a trailing 0 byte
optPrinter options, NULL for default options
cols_usedHow many columns have been used for writing in this line (will be updated by this function)
Returns
The number of bytes written, excluding the null byte

◆ rtosc_print_arg_vals()

size_t rtosc_print_arg_vals ( const rtosc_arg_val_t * args,
size_t n,
char * buffer,
size_t bs,
const rtosc_print_options * opt,
int cols_used )

Pretty-print rtosct_arg_val_t array into buffer.

Ranges are being compressed if opt->compress_ranges is true.

See also
rtosc_print_message
Warning
in case of possible line breaks (almost always), buffer[-1] must be accessible and be whitespace (since it can be converted to a newline)

◆ rtosc_print_message()

size_t rtosc_print_message ( const char * address,
const rtosc_arg_val_t * args,
size_t n,
char * buffer,
size_t bs,
const rtosc_print_options * opt,
int cols_used )

Pretty-print OSC message into string buffer.

Ranges are being compressed if opt->compress_ranges is true. A newline will be appended.

Parameters
addressOSC pattern to send message to
argsThe array to print
nNumber of args from the array that should be printed
bufferThe buffer to write to
bsThe maximum size to write to, includin a trailing 0 byte
optPrinter options, NULL for default options
cols_usedHow many columns have been used for writing in this line
Returns
The number of bytes written, excluding the null byte

◆ rtosc_scan_arg_val()

size_t rtosc_scan_arg_val ( const char * src,
rtosc_arg_val_t * arg,
size_t n,
char * buffer_for_strings,
size_t * bufsize,
size_t args_before,
int follow_ellipsis )

Scan one argument value from a string.

This function does no complete syntaxcheck. Call rtosc_count_printed_arg_vals() before.

Parameters
srcThe string
argPointer to an array where to store the argument value
nSize of the array arg. Since only one arg is being scanned, for almost all cases (except arrays), n being 1 is sufficient.
buffer_for_stringsA buffer with enough space for scanned strings and blobs
bufsizeSize of buffer_for_strings , will be shrinked to the bufferbytes left after the scan
args_beforeNumber of arguments scanned before this one
follow_ellipsisWhether an argument followed by an ellipsis is interpreted as a range start or as only the argument itself
Returns
The number of bytes scanned

◆ rtosc_scan_arg_vals()

size_t rtosc_scan_arg_vals ( const char * src,
rtosc_arg_val_t * args,
size_t n,
char * buffer_for_strings,
size_t bufsize )

Scan a fixed number of argument values from a string.

This function does no complete syntaxcheck. Call rtosc_count_printed_arg_vals() before. This will also give you the n parameter.

See also
rtosc_scan_message

◆ rtosc_scan_message()

size_t rtosc_scan_message ( const char * src,
char * address,
size_t adrsize,
rtosc_arg_val_t * args,
size_t n,
char * buffer_for_strings,
size_t bufsize )

Scan an OSC message from a string.

This function does no complete syntaxcheck. Call rtosc_count_printed_arg_vals() before. This will also give you the n parameter. Preceding and trailing whitespace will be consumed.

Parameters
srcThe string
addressA buffer where the port address will be written
adrsizeSize of buffer address
argsPointer to an array of argument values; the output will be written here
nThe amount of argument values to scan
buffer_for_stringsA buffer with enough space for scanned strings and blobs
bufsizeSize of buffer_for_strings
Returns
The number of bytes scanned

◆ rtosc_skip_next_printed_arg()

const char * rtosc_skip_next_printed_arg ( const char * src,
int * skipped,
char * type,
const char * llhssrc,
int follow_ellipsis,
int inside_bundle )

Skip characters from a string until one argument value would have been scanned.

Parameters
srcThe current position
skippedThe number of arg_vals that would be skipped when scanning, typically 1 (though not for arrays)
typeThe skipped type
llhssrcThe recent reading position before this (it will get the left of left hand sign of this argument)
follow_ellipsisWhether an argument followed by an ellipsis is interpreted as a range start or as only the argument itself
inside_bundleWhether the current position is inside a bundle
Returns
The first character after that argument value, or NULL if a parsing error occurred