From bfcf29451787d10c747ad79cb3fd177ac86e9cf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Sat, 9 Sep 2017 17:09:17 +0200 Subject: Add the persistent_by_default configuration option fix #3293 --- src/config/config.cpp | 8 ++++++++ src/config/config.hpp | 1 + 2 files changed, 9 insertions(+) (limited to 'src/config') diff --git a/src/config/config.cpp b/src/config/config.cpp index 0f3d639..412b170 100644 --- a/src/config/config.cpp +++ b/src/config/config.cpp @@ -23,6 +23,14 @@ std::string Config::get(const std::string& option, const std::string& def) return it->second; } +bool Config::get_bool(const std::string& option, const bool def) +{ + auto res = Config::get(option, ""); + if (res.empty()) + return def; + return res == "true"; +} + int Config::get_int(const std::string& option, const int& def) { std::string res = Config::get(option, ""); diff --git a/src/config/config.hpp b/src/config/config.hpp index 2ba38cc..c5ef15d 100644 --- a/src/config/config.hpp +++ b/src/config/config.hpp @@ -44,6 +44,7 @@ public: * the second argument as the default. */ static int get_int(const std::string&, const int&); + static bool get_bool(const std::string&, const bool); /** * Set a value for the given option. And write all the config * in the file from which it was read if save is true. -- cgit v1.2.3