Skip to content

Commit

Permalink
Remove GncOptionDB::set_selectable and convert set_option to a template.
Browse files Browse the repository at this point in the history
  • Loading branch information
jralls committed Jul 11, 2021
1 parent 935ce6d commit 9cdcaf0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
11 changes: 0 additions & 11 deletions libgnucash/app-utils/gnc-optiondb.cpp
Expand Up @@ -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)
{
Expand Down
21 changes: 19 additions & 2 deletions libgnucash/app-utils/gnc-optiondb.hpp
Expand Up @@ -26,6 +26,7 @@

#include "gnc-option.hpp"
#include <functional>
#include <exception>
#include <boost/optional.hpp>
extern "C"
{
Expand Down Expand Up @@ -62,8 +63,24 @@ class GncOptionDB
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:
Expand Down

0 comments on commit 9cdcaf0

Please sign in to comment.