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 #ifndef SWIG
34 
41  struct CASADI_EXPORT Options {
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  // Get all entries
61  std::vector<std::string> all() const;
62 
63  // Get type of an entry
64  std::string type(const std::string& name) const;
65 
66  // Get description for an entry
67  std::string info(const std::string& name) const;
68 
69  // Print all entries
70  void disp(std::ostream& stream) const;
71 
75  static double word_distance(const std::string &a, const std::string &b);
76 
80  std::vector<std::string> suggestions(const std::string& word, casadi_int amount=5) const;
81 
85  void best_matches(const std::string& word,
86  std::vector<std::pair<double, std::string> >& best) const;
87 
89  static bool has_dot(const Dict& opts);
90 
92  static bool has_null(const Dict& opts);
93 
95  static bool is_sane(const Dict& opts);
96 
98  static Dict sanitize(const Dict& opts);
99 
101  void check(const Dict& opts) const;
102 
106  void print_all(std::ostream &stream) const;
107 
111  void print_one(const std::string &name, std::ostream &stream) const;
112  };
113 
114 #endif // SWIG
116 } // namespace casadi
117 
118 
119 #endif // CASADI_OPTIONS_HPP
The casadi namespace.
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.