Branch data Line data Source code
1 : : /****************************************************************************** 2 : : * Top contributors (to current version): 3 : : * Gereon Kremer, Tim King, Aina Niemetz 4 : : * 5 : : * This file is part of the cvc5 project. 6 : : * 7 : : * Copyright (c) 2009-2025 by the authors listed in the file AUTHORS 8 : : * in the top-level source directory and their institutional affiliations. 9 : : * All rights reserved. See the file COPYING in the top-level source 10 : : * directory for licensing information. 11 : : * **************************************************************************** 12 : : * 13 : : * Interface for custom handlers and predicates options. 14 : : */ 15 : : 16 : : #include "cvc5_private.h" 17 : : 18 : : #ifndef CVC5__OPTIONS__OPTIONS_HANDLER_H 19 : : #define CVC5__OPTIONS__OPTIONS_HANDLER_H 20 : : 21 : : #include <ostream> 22 : : #include <sstream> 23 : : #include <string> 24 : : 25 : : #include "options/base_options.h" 26 : : #include "options/bv_options.h" 27 : : #include "options/decision_options.h" 28 : : #include "options/language.h" 29 : : #include "options/managed_streams.h" 30 : : #include "options/option_exception.h" 31 : : #include "options/quantifiers_options.h" 32 : : 33 : : namespace cvc5::internal { 34 : : 35 : : class Options; 36 : : 37 : : namespace options { 38 : : 39 : : /** 40 : : * Class that responds to command line options being set. 41 : : * 42 : : * Most functions can throw an OptionException on failure. 43 : : */ 44 : : class OptionsHandler 45 : : { 46 : : public: 47 : : OptionsHandler(Options* options); 48 : : 49 : : template <typename T> 50 : 2332 : void checkMinimum(const std::string& flag, T value, T minimum) const 51 : : { 52 [ + + ]: 2332 : if (value < minimum) 53 : : { 54 : 958 : std::stringstream ss; 55 : 479 : ss << flag << " = " << value 56 : 479 : << " is not a legal setting, value should be at least " << minimum 57 : 479 : << "."; 58 : 479 : throw OptionException(ss.str()); 59 : : } 60 : 1853 : } 61 : : template <typename T> 62 : 1873 : void checkMaximum(const std::string& flag, T value, T maximum) const 63 : : { 64 [ + + ]: 1873 : if (value > maximum) 65 : : { 66 : 836 : std::stringstream ss; 67 : 418 : ss << flag << " = " << value 68 : 418 : << " is not a legal setting, value should be at most " << maximum 69 : 418 : << "."; 70 : 418 : throw OptionException(ss.str()); 71 : : } 72 : 1455 : } 73 : : 74 : : /******************************* base options *******************************/ 75 : : /** Apply the error output stream to the different output channels */ 76 : : void setErrStream(const std::string& flag, const ManagedErr& me); 77 : : 78 : : /** Convert option value to Language enum */ 79 : : Language stringToLanguage(const std::string& flag, const std::string& optarg); 80 : : /** Set the input language. Check that lang is not LANG_AST */ 81 : : void setInputLanguage(const std::string& flag, Language lang); 82 : : /** Apply verbosity to the different output channels */ 83 : : void setVerbosity(const std::string& flag, int value); 84 : : /** Decrease verbosity and call setVerbosity */ 85 : : void decreaseVerbosity(const std::string& flag, bool value); 86 : : /** Increase verbosity and call setVerbosity */ 87 : : void increaseVerbosity(const std::string& flag, bool value); 88 : : /** If statistics are disabled, disable statistics sub-options */ 89 : : void setStats(const std::string& flag, bool value); 90 : : /** If statistics sub-option is disabled, enable statistics */ 91 : : void setStatsDetail(const std::string& flag, bool value); 92 : : /** Enable a particular trace tag */ 93 : : void enableTraceTag(const std::string& flag, const std::string& optarg); 94 : : /** Enable a particular output tag */ 95 : : void enableOutputTag(const std::string& flag, OutputTag optarg); 96 : : /** Pass the resource weight specification to the resource manager */ 97 : : void setResourceWeight(const std::string& flag, const std::string& optarg); 98 : : 99 : : /******************************* bv options *******************************/ 100 : : 101 : : /** Check that the sat solver mode is compatible with other bv options */ 102 : : void checkBvSatSolver(const std::string& flag, BvSatSolverMode m); 103 : : 104 : : /******************************* main options *******************************/ 105 : : /** Show the solver build configuration and exit */ 106 : : void showConfiguration(const std::string& flag, bool value); 107 : : /** Show copyright information and exit */ 108 : : void showCopyright(const std::string& flag, bool value); 109 : : /** Show version information and exit */ 110 : : void showVersion(const std::string& flag, bool value); 111 : : /** Show all trace tags and exit */ 112 : : void showTraceTags(const std::string& flag, bool value); 113 : : 114 : : /***************************** parser options *******************************/ 115 : : void strictParsing(const std::string& flag, bool value); 116 : : 117 : : private: 118 : : /** Pointer to the containing Options object.*/ 119 : : Options* d_options; 120 : : }; /* class OptionHandler */ 121 : : 122 : : } // namespace options 123 : : } // namespace cvc5::internal 124 : : 125 : : #endif /* CVC5__OPTIONS__OPTIONS_HANDLER_H */