summaryrefslogtreecommitdiff
path: root/src/settings.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/settings.cpp')
-rw-r--r--src/settings.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/settings.cpp b/src/settings.cpp
index b4083264e..61f35e911 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -362,6 +362,18 @@ const SettingsEntry &Settings::getEntry(const std::string &name) const
}
+const SettingsEntry &Settings::getEntryDefault(const std::string &name) const
+{
+ MutexAutoLock lock(m_mutex);
+
+ SettingEntries::const_iterator n;
+ if ((n = m_defaults.find(name)) == m_defaults.end()) {
+ throw SettingNotFoundException("Setting [" + name + "] not found.");
+ }
+ return n->second;
+}
+
+
Settings *Settings::getGroup(const std::string &name) const
{
const SettingsEntry &entry = getEntry(name);
@@ -380,6 +392,15 @@ const std::string &Settings::get(const std::string &name) const
}
+const std::string &Settings::getDefault(const std::string &name) const
+{
+ const SettingsEntry &entry = getEntryDefault(name);
+ if (entry.is_group)
+ throw SettingNotFoundException("Setting [" + name + "] is a group.");
+ return entry.value;
+}
+
+
bool Settings::getBool(const std::string &name) const
{
return is_yes(get(name));
@@ -568,6 +589,17 @@ bool Settings::getEntryNoEx(const std::string &name, SettingsEntry &val) const
}
+bool Settings::getEntryDefaultNoEx(const std::string &name, SettingsEntry &val) const
+{
+ try {
+ val = getEntryDefault(name);
+ return true;
+ } catch (SettingNotFoundException &e) {
+ return false;
+ }
+}
+
+
bool Settings::getGroupNoEx(const std::string &name, Settings *&val) const
{
try {
@@ -590,6 +622,17 @@ bool Settings::getNoEx(const std::string &name, std::string &val) const
}
+bool Settings::getDefaultNoEx(const std::string &name, std::string &val) const
+{
+ try {
+ val = getDefault(name);
+ return true;
+ } catch (SettingNotFoundException &e) {
+ return false;
+ }
+}
+
+
bool Settings::getFlag(const std::string &name) const
{
try {