26 #include "options.hpp" 
   34     for (
auto&& b : 
bases) {
 
   36       if (entry) 
return entry;
 
   49     stream << 
"> \"" << name << 
"\"          [" 
   54     stream << 
"     \"" << this->
description << 
"\""<< std::endl;
 
   59     for (
auto&& b : 
bases) {
 
   65       e.second.disp(e.first, stream);
 
   72     casadi_int na = a.size();
 
   73     casadi_int nb = b.size();
 
   74     if (na == 0) 
return static_cast<double>(nb);
 
   75     if (nb == 0) 
return static_cast<double>(na);
 
   77     std::vector<casadi_int> v0(nb+1, 0);
 
   78     std::vector<casadi_int> v1(nb+1, 0);
 
   80     for (casadi_int i=0;i<nb+1;++i)
 
   86     for (casadi_int i=0;i<na;i++) {
 
   88       for (casadi_int j=0; j<nb; j++) {
 
   89         s = std::tolower(a[i], loc);
 
   90         t = std::tolower(b[j], loc);
 
   95         v1[j+1] = std::min(std::min(v1[j] + 1, v0[j+1] + 1), v0[j] + cost);
 
   98       for (casadi_int j=0; j<nb+1; j++)
 
  102     return static_cast<double>(v1[nb]);
 
  107     const double inf = std::numeric_limits<double>::infinity();
 
  108     std::vector<std::pair<double, std::string>> best(amount, {
inf, 
""});
 
  114     stable_sort(best.begin(), best.end());
 
  117     std::vector<std::string> ret;
 
  119     for (
auto&& e : best) {
 
  121         ret.push_back(e.second);
 
  128                              std::vector<std::pair<double, std::string> >& best)
 const {
 
  130     for (
auto&& b : 
bases) {
 
  131       b->best_matches(word, best);
 
  135     auto worst = max_element(best.begin(), best.end());
 
  143       if (d < worst->first) {
 
  145         worst->second = e.first;
 
  146         worst = max_element(best.begin(), best.end());
 
  152     for (
auto&& op : opts) {
 
  153       if (op.first.find(
'.') != std::string::npos || op.first.find(
"__") != std::string::npos) {
 
  157       if (op.second.is_dict() && 
has_dot(op.second)) 
return true;
 
  163     for (
auto&& op : opts) {
 
  164       if (op.second.is_null()) 
return true;
 
  178       for (
auto&& op : opts) {
 
  179         if (!op.second.is_null()) ret[op.first] = op.second;
 
  194       for (
auto&& op : opts) {
 
  196         std::string::size_type dotpos = op.first.find(
'.'), dotpos_end;
 
  197         if (dotpos==std::string::npos) {
 
  198           dotpos = op.first.find(
"__");
 
  199           if (dotpos!=std::string::npos) dotpos_end = dotpos+2;
 
  201           dotpos_end = dotpos+1;
 
  205         if (!sname.empty() && (dotpos==std::string::npos
 
  206                                || op.first.compare(0, dotpos, sname)!=0)) {
 
  219         if (dotpos != std::string::npos) {
 
  220           sname = op.first.substr(0, dotpos);
 
  221           std::string target_name = op.first.substr(dotpos_end);
 
  222           sopts[target_name] = value;
 
  229       if (!sname.empty()) {
 
  242     for (
auto&& op : opts) {
 
  246       if (entry==
nullptr) {
 
  247         std::stringstream ss;
 
  248         ss << 
"Unknown option: " << op.first << std::endl;
 
  250         ss << 
"Did you mean one of the following?" << std::endl;
 
  254         ss << 
"Use print_options() to get a full list of options." << std::endl;
 
  255         casadi_error(ss.str());
 
  259       casadi_assert(op.second.can_cast_to(entry->
type),
 
  260                             "Illegal type for " + op.first + 
": " +
 
  261                             op.second.get_description() +
 
  262                             " cannot be cast to " +
 
  269     stream << 
"\"Option name\" [type] = value" << std::endl;
 
  276     if (entry!=
nullptr) {
 
  277       entry->
disp(name, stream);
 
  279       stream << 
"  \"" << name << 
"\" does not exist.";
 
  284     std::vector<std::string> ret;
 
  285     for (
auto&& e : 
entries) ret.push_back(e.first);
 
  291     casadi_assert(entry!=
nullptr, 
"Option \"" + name + 
"\" does not exist");
 
  297     casadi_assert(entry!=
nullptr, 
"Option \"" + name + 
"\" does not exist");
 
Generic data type, can hold different types such as bool, casadi_int, std::string etc.
 
static std::string get_type_description(TypeID type)
Get a description of a type.
 
bool is_dict() const
Check if a particular type.
 
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.
 
void update_dict(Dict &target, const Dict &source, bool recurse)
Update the target dictionary in place with source elements.
 
void disp(const std::string &name, std::ostream &stream) const
 
std::string type(const std::string &name) const
 
std::vector< const Options * > bases
 
static bool is_sane(const Dict &opts)
Is the dictionary sane.
 
std::vector< std::string > all() const
 
void print_all(std::ostream &stream) const
Print list of options.
 
std::string info(const std::string &name) const
 
void disp(std::ostream &stream) const
 
static bool has_null(const Dict &opts)
Does the dictionary has null objects.
 
static double word_distance(const std::string &a, const std::string &b)
A distance metric between two words.
 
static Dict sanitize(const Dict &opts, bool top_level=true)
Sanitize a options dictionary.
 
static bool has_dot(const Dict &opts)
Does the dictionary contain a dot.
 
std::map< std::string, Entry > entries
 
const Options::Entry * find(const std::string &name) const
 
std::vector< std::string > suggestions(const std::string &word, casadi_int amount=5) const
Get the best suggestions for a misspelled word.
 
void check(const Dict &opts) const
Check if options exist.
 
void print_one(const std::string &name, std::ostream &stream) const
Print all information there is to know about a certain option.
 
void best_matches(const std::string &word, std::vector< std::pair< double, std::string > > &best) const
Find best matches.