summaryrefslogtreecommitdiffstats
path: root/ingen
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-11-21 08:44:24 +0000
committerDavid Robillard <d@drobilla.net>2012-11-21 08:44:24 +0000
commit75bec507b3815f8a101de265bd353cfdb289bc6d (patch)
tree9226a74b1144dd404fb4eae3066642f425a77f0c /ingen
parent480c0e362aec524d992ed7adaccf3c13b71e6f93 (diff)
downloadingen-75bec507b3815f8a101de265bd353cfdb289bc6d.tar.gz
ingen-75bec507b3815f8a101de265bd353cfdb289bc6d.tar.bz2
ingen-75bec507b3815f8a101de265bd353cfdb289bc6d.zip
Configuration file support.
Change "jack-client" option to "jack-name". Print more informative info log messages. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4841 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'ingen')
-rw-r--r--ingen/Configuration.hpp37
1 files changed, 30 insertions, 7 deletions
diff --git a/ingen/Configuration.hpp b/ingen/Configuration.hpp
index bc04ecba..0ede7059 100644
--- a/ingen/Configuration.hpp
+++ b/ingen/Configuration.hpp
@@ -112,10 +112,20 @@ public:
} _val;
};
- Configuration& add(const std::string& name,
+ /** Add a configuration option.
+ *
+ * @param key URI local name, in camelCase
+ * @param name Long option name (without leading "--")
+ * @param letter Short option name (without leading "-")
+ * @param desc Description
+ * @param type Type
+ * @param value Default value
+ */
+ Configuration& add(const std::string& key,
+ const std::string& name,
char letter,
const std::string& desc,
- OptionType type,
+ const OptionType type,
const Value& value);
void print_usage(const std::string& program, std::ostream& os);
@@ -126,6 +136,18 @@ public:
void parse(int argc, char** argv) throw (CommandLineError);
+ /** Load a specific file. */
+ bool load(const std::string& path);
+
+ /** 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.
+ */
+ std::list<std::string> load_default(const std::string& app,
+ const std::string& file);
+
void print(std::ostream& os, const std::string mime_type="text/plain") const;
const Value& option(const std::string& long_name) const;
@@ -138,14 +160,13 @@ private:
public:
Option(const std::string& n, char l, const std::string& d,
const OptionType type, const Value& def)
- : name(n), letter(l), desc(d), type(type), default_value(def), value(def)
+ : name(n), letter(l), desc(d), type(type), value(def)
{}
std::string name;
char letter;
std::string desc;
OptionType type;
- Value default_value;
Value value;
};
@@ -155,9 +176,10 @@ private:
}
};
- typedef std::map<std::string, Option> Options;
- typedef std::map<char, std::string> ShortNames;
- typedef std::list<std::string> Files;
+ typedef std::map<std::string, Option> Options;
+ typedef std::map<char, std::string> ShortNames;
+ typedef std::map<std::string, std::string> Keys;
+ typedef std::list<std::string> Files;
int set_value_from_string(Configuration::Option& option, const std::string& value)
throw (Configuration::CommandLineError);
@@ -165,6 +187,7 @@ private:
const std::string _shortdesc;
const std::string _desc;
Options _options;
+ Keys _keys;
ShortNames _short_names;
Files _files;
size_t _max_name_length;