Skip to content

Commit

Permalink
change add option to templated version
Browse files Browse the repository at this point in the history
  • Loading branch information
ggutierrez-sunbright committed Feb 10, 2024
1 parent 7691566 commit b345117
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
17 changes: 4 additions & 13 deletions include/RbtArgParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,14 @@ void add_flag(
options.add_options()(opts, dest, cxxopts::value<bool>()->default_value(default_value));
}

void add_string(
template <typename T>
void add(
cxxopts::options &options, const std::string &opts, const std::string &dest, const char *default_value = nullptr
) {
if (default_value == nullptr) {
options.add_options()(opts, dest, cxxopts::value<std::string>());
options.add_options()(opts, dest, cxxopts::value<T>());
} else {
options.add_options()(opts, dest, cxxopts::value<std::string>()->default_value(default_value));
}
}

void add_float(
cxxopts::options &options, const std::string &opts, const std::string &dest, const char *default_value = nullptr
) {
if (default_value == nullptr) {
options.add_options()(opts, dest, cxxopts::value<float>());
} else {
options.add_options()(opts, dest, cxxopts::value<float>()->default_value(default_value));
options.add_options()(opts, dest, cxxopts::value<T>()->default_value(default_value));
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/exe/rbcavity.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@
const RbtString EXEVERSION = RBT_VERSION;

cxxopts::options get_options_parser() {
using RbtArgParser::add;
using RbtArgParser::add_flag;
using RbtArgParser::add_float;
using RbtArgParser::add_string;
using std::string;

cxxopts::options options("rbcavity", "calculate docking cavities");
add_string(options, "r,receptor", "receptor param file (contains active site params)");
add_float(options, "l,list", "list receptor atoms within a distance in angstrom of any cavity", "5.0f");
add_float(options, "b,border", "set the border (in angstrom) around the cavities for the distance grid", "8.0f");
add<string>(options, "r,receptor", "receptor param file (contains active site params)");
add<float>(options, "l,list", "list receptor atoms within a distance in angstrom of any cavity", "5.0f");
add<float>(options, "b,border", "set the border (in angstrom) around the cavities for the distance grid", "8.0f");
add_flag(options, "W,was", "write docking cavities (plus distance grid) to .as file");
add_flag(options, "R,ras", "read docking cavities (plus distance grid) from .as file");
add_flag(options, "d,dump-insight", "dump InsightII/PyMOL grids for each cavity for visualisation");
Expand Down

0 comments on commit b345117

Please sign in to comment.