ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
Gluco::DoubleOption Class Reference

#include <Options.h>

Inheritance diagram for Gluco::DoubleOption:
Collaboration diagram for Gluco::DoubleOption:

Public Member Functions

 DoubleOption (const char *c, const char *n, const char *d, double def=double(), DoubleRange r=DoubleRange(-HUGE_VAL, false, HUGE_VAL, false))
 
 operator double (void) const
 
 operator double & (void)
 
DoubleOptionoperator= (double x)
 
virtual bool parse (const char *str)
 
virtual void help (bool verbose=false)
 
- Public Member Functions inherited from Gluco::Option
 Option (const char *name_, const char *desc_, const char *cate_, const char *type_)
 
virtual ~Option ()
 

Protected Attributes

DoubleRange range
 
double value
 

Additional Inherited Members

- Static Public Member Functions inherited from Gluco::Option
static vec< Option * > & getOptionList ()
 
static const char *& getUsageString ()
 
static const char *& getHelpPrefixString ()
 
- Public Attributes inherited from Gluco::Option
const char * name
 
const char * description
 
const char * category
 
const char * type_name
 

Detailed Description

Definition at line 125 of file Options.h.

Constructor & Destructor Documentation

◆ DoubleOption()

Gluco::DoubleOption::DoubleOption ( const char * c,
const char * n,
const char * d,
double def = double(),
DoubleRange r = DoubleRange(-HUGE_VALfalseHUGE_VALfalse) )
inline

Definition at line 132 of file Options.h.

133 : Option(n, d, c, "<double>"), range(r), value(def) {
134 // FIXME: set LC_NUMERIC to "C" to make sure that strtof/strtod parses decimal point correctly.
135 }
DoubleRange range
Definition Options.h:128
Option(const char *name_, const char *desc_, const char *cate_, const char *type_)
Definition Options.h:71
Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ help()

virtual void Gluco::DoubleOption::help ( bool verbose = false)
inlinevirtual

Implements Gluco::Option.

Definition at line 165 of file Options.h.

165 {
166 fprintf(stderr, " -%-12s = %-8s %c%4.2g .. %4.2g%c (default: %g)\n",
167 name, type_name,
168 range.begin_inclusive ? '[' : '(',
169 range.begin,
170 range.end,
171 range.end_inclusive ? ']' : ')',
172 value);
173 if (verbose){
174 fprintf(stderr, "\n %s\n", description);
175 fprintf(stderr, "\n");
176 }
177 }
const char * name
Definition Options.h:55
const char * description
Definition Options.h:56
const char * type_name
Definition Options.h:58

◆ operator double()

Gluco::DoubleOption::operator double ( void ) const
inline

Definition at line 137 of file Options.h.

137{ return value; }

◆ operator double &()

Gluco::DoubleOption::operator double & ( void )
inline

Definition at line 138 of file Options.h.

138{ return value; }

◆ operator=()

DoubleOption & Gluco::DoubleOption::operator= ( double x)
inline

Definition at line 139 of file Options.h.

139{ value = x; return *this; }
Here is the call graph for this function:

◆ parse()

virtual bool Gluco::DoubleOption::parse ( const char * str)
inlinevirtual

Implements Gluco::Option.

Definition at line 141 of file Options.h.

141 {
142 const char* span = str;
143
144 if (!match(span, "-") || !match(span, name) || !match(span, "="))
145 return false;
146
147 char* end;
148 double tmp = strtod(span, &end);
149
150 if (end == NULL)
151 return false;
152 else if (tmp >= range.end && (!range.end_inclusive || tmp != range.end)){
153 fprintf(stderr, "ERROR! value <%s> is too large for option \"%s\".\n", span, name);
154 exit(1);
155 }else if (tmp <= range.begin && (!range.begin_inclusive || tmp != range.begin)){
156 fprintf(stderr, "ERROR! value <%s> is too small for option \"%s\".\n", span, name);
157 exit(1); }
158
159 value = tmp;
160 // fprintf(stderr, "READ VALUE: %g\n", value);
161
162 return true;
163 }
VOID_HACK exit()
Here is the call graph for this function:

Member Data Documentation

◆ range

DoubleRange Gluco::DoubleOption::range
protected

Definition at line 128 of file Options.h.

◆ value

double Gluco::DoubleOption::value
protected

Definition at line 129 of file Options.h.


The documentation for this class was generated from the following file: