abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Minisat::DoubleOption Class Reference

#include <Options.h>

Inherits Minisat::Option.

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)
 

Static Public Member Functions

static vec< Option * > & getOptionList ()
 
static const char *& getUsageString ()
 
static const char *& getHelpPrefixString ()
 

Data Fields

const char * name
 
const char * description
 
const char * category
 
const char * type_name
 

Protected Attributes

DoubleRange range
 
double value
 

Detailed Description

Definition at line 121 of file Options.h.

Constructor & Destructor Documentation

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

Definition at line 128 of file Options.h.

129  : Option(n, d, c, "<double>"), range(r), value(def) {
130  // FIXME: set LC_NUMERIC to "C" to make sure that strtof/strtod parses decimal point correctly.
131  }
Option(const char *name_, const char *desc_, const char *cate_, const char *type_)
Definition: Options.h:67
DoubleRange range
Definition: Options.h:124

Member Function Documentation

static const char*& Minisat::Option::getHelpPrefixString ( )
inlinestaticinherited

Definition at line 58 of file Options.h.

58 { static const char* help_prefix_str = ""; return help_prefix_str; }
static vec<Option*>& Minisat::Option::getOptionList ( )
inlinestaticinherited

Definition at line 56 of file Options.h.

56 { static vec<Option*> options; return options; }
static const char*& Minisat::Option::getUsageString ( )
inlinestaticinherited

Definition at line 57 of file Options.h.

57 { static const char* usage_str; return usage_str; }
virtual void Minisat::DoubleOption::help ( bool  verbose = false)
inlinevirtual

Implements Minisat::Option.

Definition at line 161 of file Options.h.

161  {
162  fprintf(stderr, " -%-12s = %-8s %c%4.2g .. %4.2g%c (default: %g)\n",
163  name, type_name,
164  range.begin_inclusive ? '[' : '(',
165  range.begin,
166  range.end,
167  range.end_inclusive ? ']' : ')',
168  value);
169  if (verbose){
170  fprintf(stderr, "\n %s\n", description);
171  fprintf(stderr, "\n");
172  }
173  }
const char * name
Definition: Options.h:51
DoubleRange range
Definition: Options.h:124
const char * type_name
Definition: Options.h:54
const char * description
Definition: Options.h:52
Minisat::DoubleOption::operator double ( void  ) const
inline

Definition at line 133 of file Options.h.

133 { return value; }
Minisat::DoubleOption::operator double & ( void  )
inline

Definition at line 134 of file Options.h.

134 { return value; }
DoubleOption& Minisat::DoubleOption::operator= ( double  x)
inline

Definition at line 135 of file Options.h.

135 { value = x; return *this; }
virtual bool Minisat::DoubleOption::parse ( const char *  str)
inlinevirtual

Implements Minisat::Option.

Definition at line 137 of file Options.h.

137  {
138  const char* span = str;
139 
140  if (!match(span, "-") || !match(span, name) || !match(span, "="))
141  return false;
142 
143  char* end;
144  double tmp = strtod(span, &end);
145 
146  if (end == NULL)
147  return false;
148  else if (tmp >= range.end && (!range.end_inclusive || tmp != range.end)){
149  fprintf(stderr, "ERROR! value <%s> is too large for option \"%s\".\n", span, name);
150  exit(1);
151  }else if (tmp <= range.begin && (!range.begin_inclusive || tmp != range.begin)){
152  fprintf(stderr, "ERROR! value <%s> is too small for option \"%s\".\n", span, name);
153  exit(1); }
154 
155  value = tmp;
156  // fprintf(stderr, "READ VALUE: %g\n", value);
157 
158  return true;
159  }
VOID_HACK exit()
const char * name
Definition: Options.h:51
static bool match(B &in, const char *str)
Definition: ParseUtils.h:99
DoubleRange range
Definition: Options.h:124

Field Documentation

const char* Minisat::Option::category
inherited

Definition at line 53 of file Options.h.

const char* Minisat::Option::description
inherited

Definition at line 52 of file Options.h.

const char* Minisat::Option::name
inherited

Definition at line 51 of file Options.h.

DoubleRange Minisat::DoubleOption::range
protected

Definition at line 124 of file Options.h.

const char* Minisat::Option::type_name
inherited

Definition at line 54 of file Options.h.

double Minisat::DoubleOption::value
protected

Definition at line 125 of file Options.h.


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