Real Time Open Sound Control librtosc: include/rtosc/savefile.h File Reference

Real Time Open Sound Control librtosc

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. More...
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. More...
std::string | rtosc::save_to_file (const struct Ports &ports, void *runtime, const char *appname, rtosc_version appver)
| Return a savefile containing all values that differ from the default values. More...
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. More...

## 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

  messages | The OSC messages, whitespace-separated
  ports | The static ports structure
  runtime | The runtime object
  dispatcher | Object 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

  ports | The static ports structure
  runtime | The 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_content | The file as a C string
  ports | The static ports structure
  runtime | The runtime object
  appname | Name of the application calling this function; must match the file's application name
  appver | Version of the application calling this function
  dispatcher | Modifier 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
| ) |  |

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

Parameters

  ports | The static ports structure
  runtime | The runtime object
  appname | Name of the application calling this function
  appver | Version of the application calling this function

Returns
  The resulting savefile as an std::sting