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

#include <Options.h>

Inherits Minisat::Option.

Public Member Functions

 IntOption (const char *c, const char *n, const char *d, int32_t def=int32_t(), IntRange r=IntRange(INT32_MIN, INT32_MAX))
 
 operator int32_t (void) const
 
 operator int32_t & (void)
 
IntOptionoperator= (int32_t 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

IntRange range
 
int32_t value
 

Detailed Description

Definition at line 181 of file Options.h.

Constructor & Destructor Documentation

Minisat::IntOption::IntOption ( const char *  c,
const char *  n,
const char *  d,
int32_t  def = int32_t(),
IntRange  r = IntRange(INT32_MININT32_MAX) 
)
inline

Definition at line 188 of file Options.h.

189  : Option(n, d, c, "<int32>"), range(r), value(def) {}
IntRange range
Definition: Options.h:184
Option(const char *name_, const char *desc_, const char *cate_, const char *type_)
Definition: Options.h:67

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::IntOption::help ( bool  verbose = false)
inlinevirtual

Implements Minisat::Option.

Definition at line 218 of file Options.h.

218  {
219  fprintf(stderr, " -%-12s = %-8s [", name, type_name);
220  if (range.begin == INT32_MIN)
221  fprintf(stderr, "imin");
222  else
223  fprintf(stderr, "%4d", range.begin);
224 
225  fprintf(stderr, " .. ");
226  if (range.end == INT32_MAX)
227  fprintf(stderr, "imax");
228  else
229  fprintf(stderr, "%4d", range.end);
230 
231  fprintf(stderr, "] (default: %d)\n", value);
232  if (verbose){
233  fprintf(stderr, "\n %s\n", description);
234  fprintf(stderr, "\n");
235  }
236  }
#define INT32_MAX
Definition: pstdint.h:415
const char * name
Definition: Options.h:51
IntRange range
Definition: Options.h:184
#define INT32_MIN
Definition: pstdint.h:418
const char * type_name
Definition: Options.h:54
const char * description
Definition: Options.h:52
Minisat::IntOption::operator int32_t ( void  ) const
inline

Definition at line 191 of file Options.h.

191 { return value; }
Minisat::IntOption::operator int32_t & ( void  )
inline

Definition at line 192 of file Options.h.

192 { return value; }
IntOption& Minisat::IntOption::operator= ( int32_t  x)
inline

Definition at line 193 of file Options.h.

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

Implements Minisat::Option.

Definition at line 195 of file Options.h.

195  {
196  const char* span = str;
197 
198  if (!match(span, "-") || !match(span, name) || !match(span, "="))
199  return false;
200 
201  char* end;
202  int32_t tmp = strtol(span, &end, 10);
203 
204  if (end == NULL)
205  return false;
206  else if (tmp > range.end){
207  fprintf(stderr, "ERROR! value <%s> is too large for option \"%s\".\n", span, name);
208  exit(1);
209  }else if (tmp < range.begin){
210  fprintf(stderr, "ERROR! value <%s> is too small for option \"%s\".\n", span, name);
211  exit(1); }
212 
213  value = tmp;
214 
215  return true;
216  }
VOID_HACK exit()
const char * name
Definition: Options.h:51
IntRange range
Definition: Options.h:184
static bool match(B &in, const char *str)
Definition: ParseUtils.h:99

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.

IntRange Minisat::IntOption::range
protected

Definition at line 184 of file Options.h.

const char* Minisat::Option::type_name
inherited

Definition at line 54 of file Options.h.

int32_t Minisat::IntOption::value
protected

Definition at line 185 of file Options.h.


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