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

Functions for reading and loading rtosc savefiles. More...

#include <string>
#include <rtosc/rtosc.h>
#include <rtosc/rtosc-version.h>

Go to the source code of this file.

Classes

class  rtosc::savefile_dispatcher_t
 Class to modify and dispatch messages loaded from savefiles. More...
 

Functions

std::string rtosc::get_changed_values (const struct Ports &ports, void *runtime)
 Return a string list of all changed values.
 
int rtosc::dispatch_printed_messages (const char *messages, const struct Ports &ports, void *runtime, savefile_dispatcher_t *dispatcher=NULL)
 Scan OSC messages from human readable format and dispatch them.
 
std::string rtosc::save_to_file (const struct Ports &ports, void *runtime, const char *appname, rtosc_version appver, std::string file_str="")
 Return a savefile containing all values that differ from the default values.
 
int rtosc::load_from_file (const char *file_content, const struct Ports &ports, void *runtime, const char *appname, rtosc_version appver, savefile_dispatcher_t *dispatcher=NULL)
 Read save file and dispatch contained parameters.
 

Detailed Description

Functions for reading and loading rtosc savefiles.

Test:
default-value.cpp

Function Documentation

◆ dispatch_printed_messages()

int rtosc::dispatch_printed_messages ( const char *  messages,
const struct Ports ports,
void *  runtime,
savefile_dispatcher_t dispatcher = NULL 
)

Scan OSC messages from human readable format and dispatch them.

Parameters
messagesThe OSC messages, whitespace-separated
portsThe static ports structure
runtimeThe runtime object
dispatcherObject to modify messages prior to dispatching, or NULL. You can overwrite its virtual functions, and you should specify any of the version structs if needed. All other members shall not be initialized.
Returns
The number of messages read, or, if there was a read error, or the dispatcher did refuse to dispatch, the number of bytes read until the read error occured minus one

◆ get_changed_values()

std::string rtosc::get_changed_values ( const struct Ports ports,
void *  runtime 
)

Return a string list of all changed values.

Return a human readable list of the value that changed corresponding to the rDefault macro

Parameters
portsThe static ports structure
runtimeThe runtime object
Note
This function is not realtime save (It uses std::string), which is usually OK, since this function is being run inside a non-RT thread. If you need this to be realtime save, add a template parameter for a functor that replaces the std::string handling.
Returns
The list of ports and their changed values, linewise

◆ load_from_file()

int rtosc::load_from_file ( const char *  file_content,
const struct Ports ports,
void *  runtime,
const char *  appname,
rtosc_version  appver,
savefile_dispatcher_t dispatcher = NULL 
)

Read save file and dispatch contained parameters.

Parameters
file_contentThe file as a C string
portsThe static ports structure
runtimeThe runtime object
appnameName of the application calling this function; must match the file's application name
appverVersion of the application calling this function
dispatcherModifier for the messages; NULL if no modifiers are needed
Returns
The number of messages read, or, if there was a read error, the negated number of bytes read until the read error occured minus one

◆ save_to_file()

std::string rtosc::save_to_file ( const struct Ports ports,
void *  runtime,
const char *  appname,
rtosc_version  appver,
std::string  file_str = "" 
)

Return a savefile containing all values that differ from the default values.

Parameters
portsThe static ports structure
runtimeThe runtime object
appnameName of the application calling this function
appverVersion of the application calling this function
fileStrIf given, the new savefile will be appended to this passed savefile
Returns
The resulting savefile as an std::sting