Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Options.h
Go to the documentation of this file.
1 /***************************************************************************************[Options.h]
2 Copyright (c) 2008-2010, Niklas Sorensson
3 
4 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
5 associated documentation files (the "Software"), to deal in the Software without restriction,
6 including without limitation the rights to use, copy, modify, merge, publish, distribute,
7 sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
8 furnished to do so, subject to the following conditions:
9 
10 The above copyright notice and this permission notice shall be included in all copies or
11 substantial portions of the Software.
12 
13 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
14 NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
16 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
17 OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18 **************************************************************************************************/
19 
20 #pragma once
21 
22 #include <stdlib.h>
23 #include <stdio.h>
24 #include <math.h>
25 #include <string.h>
26 
30 
31 #pragma GCC visibility push(default)
32 namespace Minisat {
33 namespace Internal {
34 
35 //==================================================================================================
36 // Range classes with specialization for floating types:
37 
38 
39 struct IntRange {
40  int begin;
41  int end;
42  IntRange(int b, int e) : begin(b), end(e) {}
43 };
44 
45 struct DoubleRange {
46  double begin;
47  double end;
50  DoubleRange(double b, bool binc, double e, bool einc) : begin(b), end(e), begin_inclusive(binc), end_inclusive(einc) {}
51 };
52 
53 
54 //==================================================================================================
55 // Double options:
56 
57 
59 {
60  protected:
62  double value;
63 
64  public:
65  DoubleOption(const char* d, double def = double(), DoubleRange r = DoubleRange(-HUGE_VAL, false, HUGE_VAL, false))
66  : range(r), value(def) {
67  }
68 
69  operator double (void) const { return value; }
70  operator double& (void) { return value; }
71  DoubleOption& operator=(double x) { value = x; return *this; }
72 };
73 
74 
75 //==================================================================================================
76 // Int options:
77 
78 
79 class IntOption
80 {
81  protected:
83  int32_t value;
84 
85  public:
86  IntOption(const char* d, int32_t def = int32_t(), IntRange r = IntRange(INT32_MIN, INT32_MAX))
87  : range(r), value(def) {}
88 
89  operator int32_t (void) const { return value; }
90  operator int32_t& (void) { return value; }
91  IntOption& operator= (int32_t x) { value = x; return *this; }
92 };
93 
94 
95 
96 //==================================================================================================
97 // Bool option:
98 
99 
101 {
102  bool value;
103 
104  public:
105  BoolOption(const char* d, bool v)
106  : value(v) {}
107 
108  operator bool (void) const { return value; }
109  operator bool& (void) { return value; }
110  BoolOption& operator=(bool b) { value = b; return *this; }
111 };
112 
113 //=================================================================================================
114 } // namespace Internal
115 } // namespace Minisat
116 #pragma GCC visibility pop
Vec.h
Minisat::Internal::BoolOption
Definition: Options.h:100
Minisat::Internal::BoolOption::BoolOption
BoolOption(const char *d, bool v)
Definition: Options.h:105
Minisat::Internal::DoubleRange::begin
double begin
Definition: Options.h:46
Minisat::Internal::IntOption::operator=
IntOption & operator=(int32_t x)
Definition: Options.h:91
Minisat::Internal::DoubleRange::end_inclusive
bool end_inclusive
Definition: Options.h:49
INT32_MAX
#define INT32_MAX
Definition: IntTypes.h:48
INT32_MIN
#define INT32_MIN
Definition: IntTypes.h:45
Minisat::Internal::IntRange
Definition: Options.h:39
Minisat::Internal::IntOption::value
int32_t value
Definition: Options.h:83
Minisat::Internal::DoubleOption::DoubleOption
DoubleOption(const char *d, double def=double(), DoubleRange r=DoubleRange(-HUGE_VAL, false, HUGE_VAL, false))
Definition: Options.h:65
Minisat::Internal::IntOption::IntOption
IntOption(const char *d, int32_t def=int32_t(), IntRange r=IntRange(INT32_MIN, INT32_MAX))
Definition: Options.h:86
IntTypes.h
ParseUtils.h
r
int r[]
Definition: hierarchical-ranking.cpp:13
Minisat::Internal::DoubleOption::operator=
DoubleOption & operator=(double x)
Definition: Options.h:71
Minisat::Internal::DoubleRange::end
double end
Definition: Options.h:47
Minisat
Definition: Minisat.h:55
Minisat::Internal::DoubleOption::range
DoubleRange range
Definition: Options.h:61
Minisat::Internal::DoubleRange::DoubleRange
DoubleRange(double b, bool binc, double e, bool einc)
Definition: Options.h:50
Minisat::Internal::IntRange::begin
int begin
Definition: Options.h:40
Minisat::Internal::BoolOption::value
bool value
Definition: Options.h:102
Minisat::Internal::IntRange::IntRange
IntRange(int b, int e)
Definition: Options.h:42
Minisat::Internal::DoubleRange::begin_inclusive
bool begin_inclusive
Definition: Options.h:48
Minisat::Internal::IntOption
Definition: Options.h:79
Minisat::Internal::BoolOption::operator=
BoolOption & operator=(bool b)
Definition: Options.h:110
Minisat::Internal::IntRange::end
int end
Definition: Options.h:41
Minisat::Internal::DoubleOption
Definition: Options.h:58
Minisat::Internal::DoubleRange
Definition: Options.h:45
Minisat::Internal::DoubleOption::value
double value
Definition: Options.h:62
Minisat::Internal::IntOption::range
IntRange range
Definition: Options.h:82