Skip to content

DefaultsAPI ​

cpp
#include <VAmiga.h>
cpp
class DefaultsAPI

Defined in VAmiga.h:2096

The user's defaults storage

The defaults storage manages all configuration settings that persist across multiple application launches. It provides the following functionality:

  • Loading and saving the storage data You can persist the user's defaults storage in a file, a stream, or a string stream.

  • Reading and writing key-value pairs The return value is read from the user's defaults storage for registered keys. For unknown keys, an exception is thrown.

  • Registerung fallback values The fallback value is used for registered keys with no custom value set.

    NOTE

    Setting a fallback value for an unknown key is permitted. In this case, a new key is registered together with the provided default value. The GUI utilizes this feature to register additional keys, such as keys storing shader-relevant parameters that are irrelevant to the emulation core.

Public Methods ​

ReturnNameDescription
voidloadLoads a storage file from disk.
voidloadLoads a storage file from a stream.
voidloadLoads a storage file from a string stream.
voidsaveSaves a storage file to disk.
voidsaveSaves a storage file to stream.
voidsaveSaves a storage file to a string stream.
stringgetRaw constQueries a key-value pair.
i64get constQueries a key-value pair.
i64get constQueries a key-value pair.
stringgetFallbackRaw constQueries a fallback key-value pair.
i64getFallback constQueries a fallback key-value pair.
i64getFallback constQueries a fallback key-value pair.
voidsetWrites a key-value pair into the user storage.
voidsetWrites a key-value pair into the user storage.
voidsetWrites multiple key-value pairs into the user storage.
voidsetWrites a key-value pair into the user storage.
voidsetWrites multiple key-value pairs into the user storage.
voidsetFallbackWrites a key-value pair into the fallback storage.
voidsetFallbackWrites a key-value pair into the fallback storage.
voidsetFallbackWrites multiple key-value pairs into the fallback storage.
voidsetFallbackWrites a key-value pair into the fallback storage.
voidsetFallbackWrites multiple key-value pairs into the fallback storage.
voidremoveDeletes all key-value pairs.
voidremoveDeletes a key-value pair.
voidremoveDeletes a key-value pair.
voidremoveDeletes multiple key-value pairs.
DefaultsAPI inlineCreates an API object that operates on the given defaults storage.

load ​

cpp
void load(const std::filesystem::path & path)

Defined in VAmiga.h:2115

Loads a storage file from disk.

Exceptions ​

ExceptionDescription
IOError(IOError::FILE_NOT_FOUND)
CoreError(CoreError::SYNTAX)

load ​

cpp
void load(std::ifstream & stream)

Defined in VAmiga.h:2120

Loads a storage file from a stream.

Exceptions ​

ExceptionDescription
CoreError(CoreError::SYNTAX)

load ​

cpp
void load(std::stringstream & stream)

Defined in VAmiga.h:2125

Loads a storage file from a string stream.

Exceptions ​

ExceptionDescription
CoreError(CoreError::SYNTAX)

save ​

cpp
void save(const std::filesystem::path & path)

Defined in VAmiga.h:2130

Saves a storage file to disk.

Exceptions ​

ExceptionDescription
IOError(IOError::FILE_CANT_WRITE)

save ​

cpp
void save(std::ofstream & stream)

Defined in VAmiga.h:2136

Saves a storage file to stream.

Exceptions ​

ExceptionDescription
Errorif the file cannot be written.

save ​

cpp
void save(std::stringstream & stream)

Defined in VAmiga.h:2142

Saves a storage file to a string stream.

Exceptions ​

ExceptionDescription
Errorif the file cannot be written.

getRaw ​

const

cpp
string getRaw(const string & key) const

Defined in VAmiga.h:2154

Queries a key-value pair.

Returns ​

The value as a string.

Parameters ​

ParameterTypeDescription
keyconst string &The key.

Exceptions ​

ExceptionDescription
CoreError(CoreError::INVALID_KEY)

get ​

const

cpp
i64 get(const string & key) const

Defined in VAmiga.h:2161

Queries a key-value pair.

Returns ​

The value as an integer. 0 if the value cannot not be parsed.

Parameters ​

ParameterTypeDescription
keyconst string &The key.

Exceptions ​

ExceptionDescription
CoreError(CoreError::INVALID_KEY)

get ​

const

cpp
i64 get(Opt opt, isize nr = 0) const

Defined in VAmiga.h:2169

Queries a key-value pair.

Returns ​

The value as an integer.

Parameters ​

ParameterTypeDescription
optOptA config option whose name is used as the prefix of the key.
nrisizeOptional number that is appened to the key as suffix.

Exceptions ​

ExceptionDescription
CoreError(CoreError::INVALID_KEY)

getFallbackRaw ​

const

cpp
string getFallbackRaw(const string & key) const

Defined in VAmiga.h:2176

Queries a fallback key-value pair.

Returns ​

The value as a string.

Parameters ​

ParameterTypeDescription
keyconst string &The key.

Exceptions ​

ExceptionDescription
CoreError(CoreError::INVALID_KEY)

getFallback ​

const

cpp
i64 getFallback(const string & key) const

Defined in VAmiga.h:2183

Queries a fallback key-value pair.

Returns ​

The value as an integer. 0 if the value cannot not be parsed.

Parameters ​

ParameterTypeDescription
keyconst string &The key.

Exceptions ​

ExceptionDescription
CoreError(CoreError::INVALID_KEY)

getFallback ​

const

cpp
i64 getFallback(Opt opt, isize nr = 0) const

Defined in VAmiga.h:2191

Queries a fallback key-value pair.

Returns ​

The value as an integer.

Parameters ​

ParameterTypeDescription
optOptA config option whose name is used as the key.
nrisizeOptional number that is appened to the key as suffix.

Exceptions ​

ExceptionDescription
CoreError(CoreError::INVALID_KEY)

set ​

cpp
void set(const string & key, const string & value)

Defined in VAmiga.h:2203

Writes a key-value pair into the user storage.

Parameters ​

ParameterTypeDescription
keyconst string &The key, given as a string.
valueconst string &The value, given as a string.

Exceptions ​

ExceptionDescription
CoreError(CoreError::INVALID_KEY)

set ​

cpp
void set(Opt opt, const string & value)

Defined in VAmiga.h:2210

Writes a key-value pair into the user storage.

Parameters ​

ParameterTypeDescription
optOptThe option's name forms the prefix of the keys.
valueconst string &The value, given as a string.

Exceptions ​

ExceptionDescription
CoreError(CoreError::INVALID_KEY)

set ​

cpp
void set(Opt opt, const string & value, std::vector< isize > objids)

Defined in VAmiga.h:2218

Writes multiple key-value pairs into the user storage.

Parameters ​

ParameterTypeDescription
optOptThe option's name forms the prefix of the keys.
valueconst string &The value for all pairs, given as a string.
objidsstd::vector< isize >The keys are parameterized by adding the vector values as suffixes.

Exceptions ​

ExceptionDescription
CoreError(CoreError::INVALID_KEY)

set ​

cpp
void set(Opt opt, i64 value)

Defined in VAmiga.h:2225

Writes a key-value pair into the user storage.

Parameters ​

ParameterTypeDescription
optOptThe option's name forms the prefix of the keys.
valuei64The value, given as an integer.

Exceptions ​

ExceptionDescription
CoreError(CoreError::INVALID_KEY)

set ​

cpp
void set(Opt opt, i64 value, std::vector< isize > objids)

Defined in VAmiga.h:2233

Writes multiple key-value pairs into the user storage.

Parameters ​

ParameterTypeDescription
optOptThe option's name forms the prefix of the keys.
valuei64The value for all pairs, given as an integer.
objidsstd::vector< isize >The keys are parameterized by adding the vector values as suffixes.

Exceptions ​

ExceptionDescription
CoreError(CoreError::INVALID_KEY)

setFallback ​

cpp
void setFallback(const string & key, const string & value)

Defined in VAmiga.h:2239

Writes a key-value pair into the fallback storage.

Parameters ​

ParameterTypeDescription
keyconst string &The key, given as a string.
valueconst string &The value, given as a string.

setFallback ​

cpp
void setFallback(Opt opt, const string & value)

Defined in VAmiga.h:2246

Writes a key-value pair into the fallback storage.

Parameters ​

ParameterTypeDescription
optOptThe option's name forms the prefix of the keys.
valueconst string &The value, given as an integer.

Exceptions ​

ExceptionDescription
CoreError(CoreError::INVALID_KEY)

setFallback ​

cpp
void setFallback(Opt opt, const string & value, std::vector< isize > objids)

Defined in VAmiga.h:2253

Writes multiple key-value pairs into the fallback storage.

Parameters ​

ParameterTypeDescription
optOptThe option's name forms the prefix of the keys.
valueconst string &The shared value for all pairs, given as a string.
objidsstd::vector< isize >The keys are parameterized by adding the vector values as suffixes.

setFallback ​

cpp
void setFallback(Opt opt, i64 value)

Defined in VAmiga.h:2260

Writes a key-value pair into the fallback storage.

Parameters ​

ParameterTypeDescription
optOptThe option's name forms the prefix of the keys.
valuei64The value, given as an integer.

Exceptions ​

ExceptionDescription
CoreError(CoreError::INVALID_KEY)

setFallback ​

cpp
void setFallback(Opt opt, i64 value, std::vector< isize > objids)

Defined in VAmiga.h:2267

Writes multiple key-value pairs into the fallback storage.

Parameters ​

ParameterTypeDescription
optOptThe option's name forms the prefix of the keys.
valuei64The shared value for all pairs, given as an integer.
objidsstd::vector< isize >The keys are parameterized by adding the vector values as suffixes.

remove ​

cpp
void remove()

Defined in VAmiga.h:2276

Deletes all key-value pairs.


remove ​

cpp
void remove(const string & key)

Defined in VAmiga.h:2282

Deletes a key-value pair.

Parameters ​

ParameterTypeDescription
keyconst string &The key of the key-value pair.

Exceptions ​

ExceptionDescription
CoreError(CoreError::INVALID_KEY)

remove ​

cpp
void remove(Opt opt)

Defined in VAmiga.h:2288

Deletes a key-value pair.

Parameters ​

ParameterTypeDescription
optOptThe option's name forms the key.

Exceptions ​

ExceptionDescription
CoreError(CoreError::INVALID_KEY)

remove ​

cpp
void remove(Opt opt, std::vector< isize > objids)

Defined in VAmiga.h:2295

Deletes multiple key-value pairs.

Parameters ​

ParameterTypeDescription
optOptThe option's name forms the prefix of the keys.
objidsstd::vector< isize >The keys are parameterized by adding the vector values as suffixes.

Exceptions ​

ExceptionDescription
CoreError(CoreError::INVALID_KEY)

DefaultsAPI ​

inline

cpp
inline DefaultsAPI(Defaults * defaults)

Defined in VAmiga.h:2105

Creates an API object that operates on the given defaults storage.