options.hpp
1 /*
2  * This file is part of CasADi.
3  *
4  * CasADi -- A symbolic framework for dynamic optimization.
5  * Copyright (C) 2010-2023 Joel Andersson, Joris Gillis, Moritz Diehl,
6  * KU Leuven. All rights reserved.
7  * Copyright (C) 2011-2014 Greg Horn
8  *
9  * CasADi is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 3 of the License, or (at your option) any later version.
13  *
14  * CasADi is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with CasADi; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  *
23  */
24 
25 
26 #ifndef CASADI_OPTIONS_HPP
27 #define CASADI_OPTIONS_HPP
28 
29 #include "generic_type.hpp"
30 
31 namespace casadi {
33 
40  struct CASADI_EXPORT Options {
41 #ifndef SWIG
42  // Base classes, whose options are also valid for the derived class
43  std::vector<const Options*> bases;
44 
45  // Information for a particular options entry
46  struct Entry {
47  TypeID type;
48  std::string description;
49 
50  // Print entry
51  void disp(const std::string& name, std::ostream &stream) const;
52  };
53 
54  // Lookup for options
55  std::map<std::string, Entry> entries;
56 
57  // Locate an entry
58  const Options::Entry* find(const std::string& name) const;
59 
60 #endif // SWIG
61 
62  // Get all entries
63  std::vector<std::string> all() const;
64 
65  // Get type of an entry
66  std::string type(const std::string& name) const;
67 
68  // Get description for an entry
69  std::string info(const std::string& name) const;
70 
71 #ifndef SWIG
72  // Print all entries
73  void disp(std::ostream& stream) const;
74 #endif // SWIG
75 
79  static double word_distance(const std::string &a, const std::string &b);
80 
84  std::vector<std::string> suggestions(const std::string& word, casadi_int amount=5) const;
85 
89  void best_matches(const std::string& word,
90  std::vector<std::pair<double, std::string> >& best) const;
91 
93  static bool has_dot(const Dict& opts);
94 
96  static bool has_null(const Dict& opts);
97 
99  static bool is_sane(const Dict& opts);
100 
102  static Dict sanitize(const Dict& opts, bool top_level=true);
103 
105  void check(const Dict& opts) const;
106 
110  void print_all(std::ostream &stream) const;
111 
115  void print_one(const std::string &name, std::ostream &stream) const;
116  };
117 
119 } // namespace casadi
120 
121 
122 #endif // CASADI_OPTIONS_HPP
The casadi namespace.
Definition: archiver.hpp:32
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.