Ingen  0.5.1
Classes | Public Types | Public Member Functions | List of all members
Ingen::Configuration Class Reference

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)
 
Configurationadd (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 Atomoption (const std::string &long_name) const
 
bool set (const std::string &long_name, const Atom &value)
 

Detailed Description

Ingen configuration (command line options and/or configuration file).

Member Enumeration Documentation

§ Scope

The scope of a configuration option.

This controls when and where an option will be saved or restored.

Enumerator
GLOBAL 

Applies to any Ingen instance.

SESSION 

Applies to this Ingen instance only.

GUI 

Persistent GUI settings saved at exit.

Member Function Documentation

§ add()

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.

Parameters
keyURI local name, in camelCase
nameLong option name (without leading "--")
letterShort option name (without leading "-")
descDescription
scopeScope of option
typeType
valueDefault value

§ parse()

void Ingen::Configuration::parse ( int  argc,
char **  argv 
)
throw (OptionError
)

Parse command line arguments.

§ load()

bool Ingen::Configuration::load ( const std::string &  path)

Load a specific file.

§ save()

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.

Parameters
uri_mapURI map.
appApplication name.
filenameIf 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).
scopesBitwise OR of Scope values. Only options which match the given scopes will be saved.
Returns
The absolute path of the saved configuration file.

§ load_default()

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.


The documentation for this class was generated from the following files: