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

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