Ingen
0.5.1
|
Ingen configuration (command line options and/or configuration file). More...
#include <Configuration.hpp>
Classes | |
struct | FileError |
struct | OptionError |
Public Types | |
enum | Scope { GLOBAL = 1, SESSION = 1<<1, GUI = 1<<2 } |
The scope of a configuration option. More... | |
Public Member Functions | |
Configuration (Forge &forge) | |
Configuration & | add (const std::string &key, const std::string &name, char letter, const std::string &desc, Scope scope, const LV2_URID type, const Atom &value) |
Add a configuration option. More... | |
void | print_usage (const std::string &program, std::ostream &os) |
void | parse (int argc, char **argv) throw (OptionError) |
Parse command line arguments. More... | |
bool | load (const std::string &path) |
Load a specific file. More... | |
std::string | save (URIMap &uri_map, const std::string &app, const std::string &filename, unsigned scopes) throw (FileError) |
Save configuration to a file. More... | |
std::list< std::string > | load_default (const std::string &app, const std::string &filename) |
Load files from the standard configuration directories for the app. More... | |
const Atom & | option (const std::string &long_name) const |
bool | set (const std::string &long_name, const Atom &value) |
Ingen configuration (command line options and/or configuration file).
Configuration & Ingen::Configuration::add | ( | const std::string & | key, |
const std::string & | name, | ||
char | letter, | ||
const std::string & | desc, | ||
Scope | scope, | ||
const LV2_URID | type, | ||
const Atom & | value | ||
) |
Add a configuration option.
key | URI local name, in camelCase |
name | Long option name (without leading "--") |
letter | Short option name (without leading "-") |
desc | Description |
scope | Scope of option |
type | Type |
value | Default value |
void Ingen::Configuration::parse | ( | int | argc, |
char ** | argv | ||
) | |||
throw | ( | OptionError | |
) |
Parse command line arguments.
bool Ingen::Configuration::load | ( | const std::string & | path | ) |
Load a specific file.
std::string Ingen::Configuration::save | ( | URIMap & | uri_map, |
const std::string & | app, | ||
const std::string & | filename, | ||
unsigned | scopes | ||
) | |||
throw | ( | FileError | |
) |
Save configuration to a file.
uri_map | URI map. |
app | Application name. |
filename | If absolute, the configuration will be saved to this path. Otherwise the configuration will be saved to the user configuration directory (e.g. ~/.config/ingen/filename). |
scopes | Bitwise OR of Scope values. Only options which match the given scopes will be saved. |
std::list< std::string > Ingen::Configuration::load_default | ( | const std::string & | app, |
const std::string & | filename | ||
) |
Load files from the standard configuration directories for the app.
The system configuration file(s), e.g. /etc/xdg/appname/filename, will be loaded before the user's, e.g. ~/.config/appname/filename, so the user options will override the system options.