18 #ifndef __PARAMETERS_H__ 19 #define __PARAMETERS_H__ 21 #include "StringMap.h" 22 #include "PhoneHome.h" 33 static const char PARAM_STR_SEP =
',';
41 virtual void Translate(
const char * value) = 0;
42 virtual bool TranslateExtras(
const char * value,
const char * extras);
44 static bool CheckInteger(
const char * value);
45 static bool CheckDouble(
const char * value);
53 Parameter(
char c,
const char * desc,
void * v);
57 delete [] description;
60 virtual bool Read(
int argc,
char ** argv,
int argn);
61 virtual void Status() = 0;
62 virtual void addParamsToString(
String& params)
68 params += PARAM_STR_SEP;
70 params += description;
75 static void SetNameLen(
int len)
79 static void SetStatusLen(
int len)
84 void SetWarningBuffer(
String & buffer)
88 void warning(
const char * format, ...);
100 virtual void Status();
103 virtual void Translate(
const char * value);
104 virtual bool TranslateExtras(
const char * value,
const char * extras);
114 virtual void Status() { }
125 virtual void Status();
128 virtual void Translate(
const char * value);
138 virtual void Status() { }
146 virtual void Status();
150 this->precision = precision;
156 virtual void Translate(
const char * value);
157 virtual bool TranslateExtras(
const char * value,
const char * extras);
169 virtual void Status() { }
178 required = !allowBlank;
181 virtual void Status();
186 virtual void Translate(
const char * value);
187 virtual bool TranslateExtras(
const char * value,
const char * extras);
197 virtual void Status() { }
207 #define BEGIN_OPTION_LIST(name) ; OptionList name[] = { 208 #define END_OPTION_LIST(none) , {0, none, 0} }; 215 virtual void Status();
220 virtual void Translate(
const char * value);
228 virtual void Status();
233 virtual void Translate(
const char * value);
238 const char * description;
245 #define LP_BOOL_PARAMETER 1 246 #define LP_INT_PARAMETER 2 247 #define LP_DOUBLE_PARAMETER 3 248 #define LP_STRING_PARAMETER 4 249 #define LP_LEGACY_PARAMETERS 99 250 #define LP_PHONEHOME_VERSION 98 252 #define BEGIN_LONG_PARAMETERS(array) LongParameterList array[] = {\ 253 { NULL, NULL, false, 0, 0}, 254 #define LONG_PARAMETER_GROUP(label) { label, NULL, false, 0, 0}, 255 #define LONG_PARAMETER(label,boolptr) { label, boolptr, false, 1, 0}, 256 #define EXCLUSIVE_PARAMETER(label,boolptr) { label, boolptr, true, 1, 0}, 257 #define LONG_INTPARAMETER(label,intptr) { label, intptr, false, 2, 0}, 258 #define LONG_SMARTINTPARAMETER(label,intptr) { label, intptr, true, 2, 0}, 259 #define LONG_DOUBLEPARAMETER(label,doubleptr) { label, doubleptr, false, 3, 0}, 260 #define LONG_STRINGPARAMETER(label,stringptr) { label, stringptr, false, 4, 0}, 261 #define LONG_PHONEHOME(version) { "PhoneHome", NULL, false, 0, 0}, { version, NULL, false, LP_PHONEHOME_VERSION, 0}, {"phoneHomeThinning", &PhoneHome::allThinning, false, LP_INT_PARAMETER, 0}, 262 #define BEGIN_LEGACY_PARAMETERS() { "$$$", NULL, false, 99, 0}, 263 #define END_LONG_PARAMETERS() { NULL, NULL, false, 0, 0}}; 270 virtual void Status();
271 virtual void addParamsToString(
String& params);
275 this->precision = precision;
288 virtual void Translate(
const char * value);
289 virtual bool TranslateExtras(
const char * value,
const char * extras);
291 void ExplainAmbiguity(
const char * value);
303 void MakeString(
int argc,
char ** argv,
int start = 1);
304 void HandlePhoneHome(
int argc,
char ** argv,
int start);
322 virtual void Read(
int argc,
char ** argv,
int start = 1);
326 virtual int ReadWithTrailer(
int argc,
char ** argv,
int start = 1);
329 virtual void Status();
336 void Enforce(
bool & var,
bool value,
const char * reason, ...);
337 void Enforce(
int & var,
int value,
const char * reason, ...);
338 void Enforce(
double & var,
double value,
const char * reason, ...);
339 void Enforce(
String & var,
const char * value,
const char * reason, ...);
357 void add(
const char * label,
void * val,
bool excl,
358 int paramType,
bool touch = 0);
360 inline void addGroup(
const char * label)
361 { add(label, NULL,
false, 0, 0); }
363 inline void addBool(
const char * label,
void * boolptr)
364 { add(label, boolptr,
false, LP_BOOL_PARAMETER, 0); }
366 inline void addExclusiveBool(
const char * label,
void * boolptr)
367 { add(label, boolptr,
true, LP_BOOL_PARAMETER, 0); }
369 inline void addInt(
const char * label,
void * intptr)
370 { add(label, intptr,
false, LP_INT_PARAMETER, 0); }
372 inline void addSmartInt(
const char * label,
void * intptr)
373 { add(label, intptr,
true, LP_INT_PARAMETER, 0); }
375 inline void addDouble(
const char * label,
void * doubleptr)
376 { add(label, doubleptr,
false, LP_DOUBLE_PARAMETER, 0); }
378 inline void addString(
const char * label,
void * stringptr)
379 { add(label, stringptr,
false, LP_STRING_PARAMETER, 0); }
381 inline void addPhoneHome(
const char* version)
383 add(
"PhoneHome", NULL,
false, 0, 0);
384 add(version, NULL,
false, LP_PHONEHOME_VERSION, 0);
385 add(
"phoneHomeThinning", &PhoneHome::allThinning,
false, LP_INT_PARAMETER, 0);
388 inline void startLegacyParams()
389 { add(
"$$$", NULL,
false, 99, 0); }
393 static const int MAX_PARAM_ARRAY_SIZE = 100;