20 #ifndef Minisat_Options_h
21 #define Minisat_Options_h
38 extern int parseOptions (
int& argc,
char** argv,
bool strict =
false);
57 static const char*&
getUsageString() {
static const char* usage_str;
return usage_str; }
58 static const char*&
getHelpPrefixString() {
static const char* help_prefix_str =
"";
return help_prefix_str; }
82 virtual bool parse (
const char* str) = 0;
83 virtual void help (
bool verbose =
false) = 0;
85 friend int parseOptions (
int& argc,
char** argv,
bool strict);
133 operator double (
void)
const {
return value; }
134 operator double& (void) {
return value; }
137 virtual bool parse(
const char* str){
138 const char* span = str;
144 double tmp = strtod(span, &end);
149 fprintf(stderr,
"ERROR! value <%s> is too large for option \"%s\".\n", span,
name);
152 fprintf(stderr,
"ERROR! value <%s> is too small for option \"%s\".\n", span,
name);
161 virtual void help (
bool verbose =
false){
162 fprintf(stderr,
" -%-12s = %-8s %c%4.2g .. %4.2g%c (default: %g)\n",
171 fprintf(stderr,
"\n");
191 operator int32_t (
void)
const {
return value; }
192 operator int32_t& (void) {
return value; }
195 virtual bool parse(
const char* str){
196 const char* span = str;
202 int32_t tmp = strtol(span, &end, 10);
207 fprintf(stderr,
"ERROR! value <%s> is too large for option \"%s\".\n", span,
name);
210 fprintf(stderr,
"ERROR! value <%s> is too small for option \"%s\".\n", span,
name);
218 virtual void help (
bool verbose =
false){
221 fprintf(stderr,
"imin");
225 fprintf(stderr,
" .. ");
227 fprintf(stderr,
"imax");
231 fprintf(stderr,
"] (default: %d)\n",
value);
234 fprintf(stderr,
"\n");
311 StringOption(
const char* c,
const char* n,
const char* d,
const char* def = NULL)
314 operator const char* (void)
const {
return value; }
315 operator const char*& (void) {
return value; }
318 virtual bool parse(
const char* str){
319 const char* span = str;
328 virtual void help (
bool verbose =
false){
332 fprintf(stderr,
"\n");
347 BoolOption(
const char* c,
const char* n,
const char* d,
bool v)
351 operator bool& (void) {
return value; }
354 virtual bool parse(
const char* str){
355 const char* span = str;
357 if (
match(span,
"-")){
358 bool b = !
match(span,
"no-");
368 virtual void help (
bool verbose =
false){
370 fprintf(stderr,
" -%s, -no-%s",
name,
name);
372 for (uint32_t i = 0; i < 32 -
strlen(
name)*2; i++)
373 fprintf(stderr,
" ");
375 fprintf(stderr,
" ");
376 fprintf(stderr,
"(default: %s)\n",
value ?
"on" :
"off");
379 fprintf(stderr,
"\n");
virtual bool parse(const char *str)
virtual void help(bool verbose=false)
virtual void help(bool verbose=false)
virtual bool parse(const char *str)=0
void setHelpPrefixStr(const char *str)
IntOption(const char *c, const char *n, const char *d, int32_t def=int32_t(), IntRange r=IntRange(INT32_MIN, INT32_MAX))
friend void setUsageHelp(const char *str)
friend int printUsageAndExit(int argc, char **argv, bool verbose)
Int64Range(int64_t b, int64_t e)
int parseOptions(int &argc, char **argv, bool strict=false)
virtual void help(bool verbose=false)
static const char *& getHelpPrefixString()
StringOption & operator=(const char *x)
virtual void help(bool verbose=false)
virtual bool parse(const char *str)
StringOption(const char *c, const char *n, const char *d, const char *def=NULL)
static vec< Option * > & getOptionList()
virtual bool parse(const char *str)
static const char *& getUsageString()
Option(const char *name_, const char *desc_, const char *cate_, const char *type_)
friend void setHelpPrefixStr(const char *str)
static bool match(B &in, const char *str)
DoubleRange(double b, bool binc, double e, bool einc)
void setUsageHelp(const char *str)
DoubleOption & operator=(double x)
DoubleOption(const char *c, const char *n, const char *d, double def=double(), DoubleRange r=DoubleRange(-HUGE_VAL, false, HUGE_VAL, false))
virtual void help(bool verbose=false)=0
int printUsageAndExit(int argc, char **argv, bool verbose=false)
BoolOption & operator=(bool b)
virtual bool parse(const char *str)
BoolOption(const char *c, const char *n, const char *d, bool v)
friend int parseOptions(int &argc, char **argv, bool strict)
IntOption & operator=(int32_t x)
bool operator()(const Option *x, const Option *y)