libStatGen Software 1
SetParameter Class Reference
Inheritance diagram for SetParameter:
Collaboration diagram for SetParameter:

Public Member Functions

 SetParameter (char c, const char *desc, int &v, OptionList *opt)
 
virtual void Status ()
 
- Public Member Functions inherited from Parameter
 Parameter (char c, const char *desc, void *v)
 
virtual bool Read (int argc, char **argv, int argn)
 
virtual void Status ()=0
 
virtual void addParamsToString (String &params)
 
void SetWarningBuffer (String &buffer)
 
void warning (const char *format,...)
 

Protected Member Functions

virtual void Translate (const char *value)
 
- Protected Member Functions inherited from Parameter
virtual void Translate (const char *value)=0
 
virtual bool TranslateExtras (const char *value, const char *extras)
 

Protected Attributes

String key
 
OptionListoptions
 
- Protected Attributes inherited from Parameter
char ch
 
char * description
 
void * var
 
Stringwarnings
 
bool myNoPhoneHome
 
String myVersion
 

Additional Inherited Members

- Static Public Member Functions inherited from Parameter
static void SetNameLen (int len)
 
static void SetStatusLen (int len)
 
- Static Protected Member Functions inherited from Parameter
static bool CheckInteger (const char *value)
 
static bool CheckDouble (const char *value)
 
- Static Protected Attributes inherited from Parameter
static const char PARAM_STR_SEP = ','
 
static int nameCol = 30
 
static int statusCol = 15
 

Detailed Description

Definition at line 223 of file Parameters.h.

Constructor & Destructor Documentation

◆ SetParameter()

SetParameter::SetParameter ( char  c,
const char *  desc,
int &  v,
OptionList opt 
)

Definition at line 238 of file Parameters.cpp.

239 : Parameter(c, desc, &v)
240{
241 options = opt;
242
243 for (OptionList * l = options; l->ch != 0; l++)
244 {
245 key += l->ch;
246 key += '|';
247 }
248 key.SetLength(key.Length() - 1);
249}

Member Function Documentation

◆ Status()

void SetParameter::Status ( )
virtual

Implements Parameter.

Definition at line 251 of file Parameters.cpp.

252{
253 bool first = 0;
254 int temp = * (int *) var;
255
256 for (OptionList * l = options; l->ch != 0; l++)
257 if ((l->code & temp) || (l->code == *(int *) var))
258 {
259 if (!first)
260 fprintf(stderr, "%*s : %*s (-%c{%s})\n", nameCol, description,
261 statusCol, l->description, ch, (const char *) key);
262 else
263 fprintf(stderr, "%*s & %*s\n", nameCol, "",
264 statusCol, l->description);
265 first = true;
266 temp &= ~l->code;
267 }
268}

◆ Translate()

void SetParameter::Translate ( const char *  value)
protectedvirtual

Implements Parameter.

Definition at line 270 of file Parameters.cpp.

271{
272 *(int*)var = 0;
273
274 for (const char * chr = value; *chr != 0; chr++)
275 {
276 int valid = false;
277
278 for (OptionList * l = options; l->ch != 0; l++)
279 if (tolower(l->ch) == tolower(*chr))
280 {
281 *((int*) var) |= l->code;
282 valid = true;
283 }
284
285 if (!valid)
286 warning("Command line parameter -%c%s: the option '%c' has no meaning\n",
287 ch, value, *chr);
288 }
289}

Member Data Documentation

◆ key

String SetParameter::key
protected

Definition at line 231 of file Parameters.h.

◆ options

OptionList* SetParameter::options
protected

Definition at line 232 of file Parameters.h.


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