20 #ifndef Minisat_Options_h
21 #define Minisat_Options_h
38 extern void 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 void 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");
253 operator int64_t (
void)
const {
return value; }
254 operator int64_t& (void) {
return value; }
257 virtual bool parse(
const char* str){
258 const char* span = str;
264 int64_t tmp = strtoll(span, &end, 10);
269 fprintf(stderr,
"ERROR! value <%s> is too large for option \"%s\".\n", span,
name);
272 fprintf(stderr,
"ERROR! value <%s> is too small for option \"%s\".\n", span,
name);
280 virtual void help (
bool verbose =
false){
283 fprintf(stderr,
"imin");
287 fprintf(stderr,
" .. ");
289 fprintf(stderr,
"imax");
291 fprintf(stderr,
"%4" PRIi64 ,
range.
end);
293 fprintf(stderr,
"] (default: %" PRIi64
")\n",
value);
296 fprintf(stderr,
"\n");
313 operator const char* (void)
const {
return value; }
314 operator const char*& (void) {
return value; }
317 virtual bool parse(
const char* str){
318 const char* span = str;
327 virtual void help (
bool verbose =
false){
331 fprintf(stderr,
"\n");
346 BoolOption(
const char* c,
const char* n,
const char* d,
bool v)
349 operator bool (
void)
const {
return value; }
350 operator bool& (void) {
return value; }
353 virtual bool parse(
const char* str){
354 const char* span = str;
356 if (
match(span,
"-")){
357 bool b = !
match(span,
"no-");
359 if (strcmp(span,
name) == 0){
367 virtual void help (
bool verbose =
false){
369 fprintf(stderr,
" -%s, -no-%s",
name,
name);
371 for (uint32_t i = 0; i < 32 - strlen(
name)*2; i++)
372 fprintf(stderr,
" ");
374 fprintf(stderr,
" ");
375 fprintf(stderr,
"(default: %s)\n",
value ?
"on" :
"off");
378 fprintf(stderr,
"\n");
virtual bool parse(const char *str)
virtual void help(bool verbose=false)
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)
Int64Option & operator=(int64_t x)
Int64Range(int64_t b, int64_t e)
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)
friend void parseOptions(int &argc, char **argv, bool strict)
DoubleOption & operator=(double x)
void printUsageAndExit(int argc, char **argv, bool verbose=false)
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
Int64Option(const char *c, const char *n, const char *d, int64_t def=int64_t(), Int64Range r=Int64Range(INT64_MIN, INT64_MAX))
void parseOptions(int &argc, char **argv, bool strict=false)
BoolOption & operator=(bool b)
virtual bool parse(const char *str)
virtual bool parse(const char *str)
BoolOption(const char *c, const char *n, const char *d, bool v)
friend void printUsageAndExit(int argc, char **argv, bool verbose)
IntOption & operator=(int32_t x)
bool operator()(const Option *x, const Option *y)