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

#include <Options.h>

Inheritance diagram for Gluco::IntOption:
Collaboration diagram for Gluco::IntOption:

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)
 
- Public Member Functions inherited from Gluco::Option
 Option (const char *name_, const char *desc_, const char *cate_, const char *type_)
 
virtual ~Option ()
 

Protected Attributes

IntRange range
 
int32_t 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 185 of file Options.h.

Constructor & Destructor Documentation

◆ IntOption()

Gluco::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 192 of file Options.h.

193 : Option(n, d, c, "<int32>"), range(r), value(def) {}
int32_t value
Definition Options.h:189
IntRange range
Definition Options.h:188
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::IntOption::help ( bool verbose = false)
inlinevirtual

Implements Gluco::Option.

Definition at line 222 of file Options.h.

222 {
223 fprintf(stderr, " -%-12s = %-8s [", name, type_name);
224 if (range.begin == INT32_MIN)
225 fprintf(stderr, "imin");
226 else
227 fprintf(stderr, "%4d", range.begin);
228
229 fprintf(stderr, " .. ");
230 if (range.end == INT32_MAX)
231 fprintf(stderr, "imax");
232 else
233 fprintf(stderr, "%4d", range.end);
234
235 fprintf(stderr, "] (default: %d)\n", value);
236 if (verbose){
237 fprintf(stderr, "\n %s\n", description);
238 fprintf(stderr, "\n");
239 }
240 }
#define INT32_MAX
Definition pstdint.h:415
#define INT32_MIN
Definition pstdint.h:418
const char * name
Definition Options.h:55
const char * description
Definition Options.h:56
const char * type_name
Definition Options.h:58

◆ operator int32_t()

Gluco::IntOption::operator int32_t ( void ) const
inline

Definition at line 195 of file Options.h.

195{ return value; }

◆ operator int32_t &()

Gluco::IntOption::operator int32_t & ( void )
inline

Definition at line 196 of file Options.h.

196{ return value; }

◆ operator=()

IntOption & Gluco::IntOption::operator= ( int32_t x)
inline

Definition at line 197 of file Options.h.

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

◆ parse()

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

Implements Gluco::Option.

Definition at line 199 of file Options.h.

199 {
200 const char* span = str;
201
202 if (!match(span, "-") || !match(span, name) || !match(span, "="))
203 return false;
204
205 char* end;
206 int32_t tmp = strtol(span, &end, 10);
207
208 if (end == NULL)
209 return false;
210 else if (tmp > range.end){
211 fprintf(stderr, "ERROR! value <%s> is too large for option \"%s\".\n", span, name);
212 exit(1);
213 }else if (tmp < range.begin){
214 fprintf(stderr, "ERROR! value <%s> is too small for option \"%s\".\n", span, name);
215 exit(1); }
216
217 value = tmp;
218
219 return true;
220 }
VOID_HACK exit()
Here is the call graph for this function:

Member Data Documentation

◆ range

IntRange Gluco::IntOption::range
protected

Definition at line 188 of file Options.h.

◆ value

int32_t Gluco::IntOption::value
protected

Definition at line 189 of file Options.h.


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