GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/options/base_handlers.h Lines: 0 10 0.0 %
Date: 2021-05-22 Branches: 0 48 0.0 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Morgan Deters, Tim King, Mathias Preiner
4
 *
5
 * This file is part of the cvc5 project.
6
 *
7
 * Copyright (c) 2009-2021 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
 * [[ Add one-line brief description here ]]
14
 *
15
 * [[ Add lengthier description here ]]
16
 * \todo document this file
17
 */
18
19
#include "cvc5_private.h"
20
21
#ifndef CVC5__BASE_HANDLERS_H
22
#define CVC5__BASE_HANDLERS_H
23
24
#include <iostream>
25
#include <string>
26
#include <sstream>
27
28
#include "options/option_exception.h"
29
30
namespace cvc5 {
31
namespace options {
32
33
template <template <class U> class Cmp>
34
class comparator {
35
  long d_lbound;
36
  double d_dbound;
37
  bool d_hasLbound;
38
39
 public:
40
  comparator(int i) : d_lbound(i), d_dbound(0.0), d_hasLbound(true) {}
41
  comparator(long l) : d_lbound(l), d_dbound(0.0), d_hasLbound(true) {}
42
  comparator(double d) : d_lbound(0), d_dbound(d), d_hasLbound(false) {}
43
  template <class T>
44
  void operator()(std::string option, const T& value) {
45
    if((d_hasLbound && !(Cmp<T>()(value, T(d_lbound)))) ||
46
       (!d_hasLbound && !(Cmp<T>()(value, T(d_dbound))))) {
47
      std::stringstream ss;
48
      ss << option << ": " << value << " is not a legal setting";
49
      throw OptionException(ss.str());
50
    }
51
  }
52
};/* class comparator */
53
54
struct greater : public comparator<std::greater> {
55
  greater(int i) : comparator<std::greater>(i) {}
56
  greater(long l) : comparator<std::greater>(l) {}
57
  greater(double d) : comparator<std::greater>(d) {}
58
};/* struct greater */
59
60
struct greater_equal : public comparator<std::greater_equal> {
61
  greater_equal(int i) : comparator<std::greater_equal>(i) {}
62
  greater_equal(long l) : comparator<std::greater_equal>(l) {}
63
  greater_equal(double d) : comparator<std::greater_equal>(d) {}
64
};/* struct greater_equal */
65
66
struct less : public comparator<std::less> {
67
  less(int i) : comparator<std::less>(i) {}
68
  less(long l) : comparator<std::less>(l) {}
69
  less(double d) : comparator<std::less>(d) {}
70
};/* struct less */
71
72
struct less_equal : public comparator<std::less_equal> {
73
  less_equal(int i) : comparator<std::less_equal>(i) {}
74
  less_equal(long l) : comparator<std::less_equal>(l) {}
75
  less_equal(double d) : comparator<std::less_equal>(d) {}
76
};/* struct less_equal */
77
78
struct not_equal : public comparator<std::not_equal_to> {
79
  not_equal(int i) : comparator<std::not_equal_to>(i) {}
80
  not_equal(long l) : comparator<std::not_equal_to>(l) {}
81
  not_equal(double d) : comparator<std::not_equal_to>(d) {}
82
};/* struct not_equal_to */
83
84
}  // namespace options
85
}  // namespace cvc5
86
87
#endif /* CVC5__BASE_HANDLERS_H */