Remove GncOptionDB::set_selectable and convert set_option to a template.

pull/1191/head
John Ralls 7 years ago
parent 935ce6db99
commit 9cdcaf0da8

@ -174,17 +174,6 @@ GncOptionDB::lookup_string_option(const char* section, const char* name)
return db_opt->get_value<std::string>();
}
bool
GncOptionDB::set_option(const char* section, const char* name, SCM value)
{
return false;
}
void
GncOptionDB::set_selectable(const char* section, const char* name)
{
}
void
GncOptionDB::make_internal(const char* section, const char* name)
{

@ -26,6 +26,7 @@
#include "gnc-option.hpp"
#include <functional>
#include <exception>
#include <boost/optional.hpp>
extern "C"
{
@ -62,8 +63,24 @@ public:
SCM lookup_option(const char* section, const char* name);
std::string lookup_string_option(const char* section,
const char* name);
bool set_option(const char* section, const char* name, SCM value);
void set_selectable(const char* section, const char* name);
template <typename ValueType>
bool set_option(const char* section, const char* name, ValueType value)
{
try
{
auto option{find_option(section, name)};
if (!option)
return false;
option->set_value<ValueType>(value);
return true;
}
catch(const std::invalid_argument& err)
{
printf("Set Failed: %s\n", err.what());
return false;
}
}
// void set_selectable(const char* section, const char* name);
void make_internal(const char* section, const char* name);
void commit();
private:

Loading…
Cancel
Save