1 /* 2 * This file is part of CasADi. 3 * 4 * CasADi -- A symbolic framework for dynamic optimization. 5 * Copyright (C) 2010-2014 Joel Andersson, Joris Gillis, Moritz Diehl, 6 * K.U. 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 { 32 /// \cond INTERNAL 33 #ifndef SWIG 34 35 /** \brief Options metadata for a class 36 \author Joel Andersson, Joris Gillis 37 \date 2010-2016 38 */ 39 struct CASADI_EXPORT Options { 40 // Base classes, whose options are also valid for the derived class 41 std::vector<const Options*> bases; 42 43 // Information for a particular options entry 44 struct Entry { 45 TypeID type; 46 std::string description; 47 48 // Print entry 49 void disp(const std::string& name, std::ostream &stream) const; 50 }; 51 52 // Lookup for options 53 std::map<std::string, Entry> entries; 54 55 // Locate an entry 56 const Options::Entry* find(const std::string& name) const; 57 58 // Get all entries 59 std::vector<std::string> all() const; 60 61 // Get type of an entry 62 std::string type(const std::string& name) const; 63 64 // Get description for an entry 65 std::string info(const std::string& name) const; 66 67 // Print all entries 68 void disp(std::ostream& stream) const; 69 70 /** \brief A distance metric between two words */ 71 static double word_distance(const std::string &a, const std::string &b); 72 73 /** \brief Get the best suggestions for a misspelled word */ 74 std::vector<std::string> suggestions(const std::string& word, casadi_int amount=5) const; 75 76 /** \brief Find best matches */ 77 void best_matches(const std::string& word, 78 std::vector<std::pair<double, std::string> >& best) const; 79 80 /// Does the dictionary contain a dot 81 static bool has_dot(const Dict& opts); 82 83 /// Does the dictionary has null objects 84 static bool has_null(const Dict& opts); 85 86 /// Is the dictionary sane 87 static bool is_sane(const Dict& opts); 88 89 /// Sanitize a options dictionary 90 static Dict sanitize(const Dict& opts); 91 92 /// Check if options exist 93 void check(const Dict& opts) const; 94 95 /** \brief Print list of options */ 96 void print_all(std::ostream &stream) const; 97 98 /** \brief Print all information there is to know about a certain option */ 99 void print_one(const std::string &name, std::ostream &stream) const; 100 }; 101 102 #endif // SWIG 103 /// \endcond 104 } // namespace casadi 105 106 107 #endif // CASADI_OPTIONS_HPP 108