Loading...
Searching...
No Matches
ParameterList Class Reference
Collaboration diagram for ParameterList:
[legend]

## Public Member Functions

| ParameterList (int s=36)
void | Add (Parameter *p)
virtual void | Read (int argc, char **argv, int start=1)
virtual int | ReadWithTrailer (int argc, char **argv, int start=1)
virtual void | Status ()
void | Enforce (bool &var, bool value, const char *reason,...)
void | Enforce (int &var, int value, const char *reason,...)
void | Enforce (double &var, double value, const char *reason,...)
void | Enforce (String &var, const char *value, const char *reason,...)

## Public Attributes

char * | string
String | warnings
String | messages

## Protected Member Functions

void | MakeString (int argc, char **argv, int start=1)
void | HandlePhoneHome (int argc, char **argv, int start)

## Protected Attributes

Parameter ** | pl
int | count
int | size

## Detailed Description

Definition at line 296 of file Parameters.h.

## Constructor & Destructor Documentation

## ParameterList()

ParameterList::ParameterList | ( | int | s = `36` | ) |

inline

Definition at line 309 of file Parameters.h.

{
size = s;
count = 0;
pl = new Parameter * [size];
string = NULL;
}
Parameter
Definition Parameters.h:30

## ~ParameterList()

ParameterList::~ParameterList | ( |  | ) |

virtual

Definition at line 772 of file Parameters.cpp.

{
for (int i = 0; i < count; i++)
delete pl[i];
delete [] pl;
delete [] string;
};

## Member Function Documentation

## Add()

void ParameterList::Add | ( | Parameter * | p | ) |

Definition at line 594 of file Parameters.cpp.

{
if (count + 1 >= size)
error("Parameter list size should be increased");
p->SetWarningBuffer(warnings);
pl[count++] = p;
};

## Enforce() [1/4]

void ParameterList::Enforce | ( | bool & | var,
|  | bool | value,
|  | const char * | reason,
|  |  | ...
| ) |  |

Definition at line 824 of file Parameters.cpp.

{
if (var == value)
return;
var = value;
String buffer;
va_list ap;
va_start(ap, format);
buffer.vprintf(format, ap);
va_end(ap);
messages += buffer;
}
String
Definition StringBasics.h:39

## Enforce() [2/4]

void ParameterList::Enforce | ( | double & | var,
|  | double | value,
|  | const char * | reason,
|  |  | ...
| ) |  |

Definition at line 858 of file Parameters.cpp.

{
if (var == value)
return;
var = value;
String buffer;
va_list ap;
va_start(ap, format);
buffer.vprintf(format, ap);
va_end(ap);
messages += buffer;
}

## Enforce() [3/4]

void ParameterList::Enforce | ( | int & | var,
|  | int | value,
|  | const char * | reason,
|  |  | ...
| ) |  |

Definition at line 841 of file Parameters.cpp.

{
if (var == value)
return;
var = value;
String buffer;
va_list ap;
va_start(ap, format);
buffer.vprintf(format, ap);
va_end(ap);
messages += buffer;
}

## Enforce() [4/4]

void ParameterList::Enforce | ( | String & | var,
|  | const char * | value,
|  | const char * | reason,
|  |  | ...
| ) |  |

Definition at line 875 of file Parameters.cpp.

{
if (var.SlowCompare(value) == 0)
return;
var = value;
String buffer;
va_list ap;
va_start(ap, format);
buffer.vprintf(format, ap);
va_end(ap);
messages += buffer;
}

## HandlePhoneHome()

void ParameterList::HandlePhoneHome | ( | int | argc,
|  | char ** | argv,
|  | int | start
| ) |  |

protected

Definition at line 730 of file Parameters.cpp.

{
// Determine the tool name : args prior to start.
String programName = "";
for(int i = 0; i < start; i++)
{
if(i == 0)
{
programName = argv[i];
}
else
{
programName += ":";
programName += argv[i];
}
}
// Loop through and get the params
String params = "";
String version = "";
for (int i=0; i<count; i++)
{
pl[i]->addParamsToString(params);
// Check if phonehome is enabled.
if(!pl[i]->myVersion.IsEmpty() && (!pl[i]->myNoPhoneHome))
{
// Version specified & phoneHome enabled, so
// phonehome.
version = pl[i]->myVersion;
}
}
if(!version.IsEmpty())
{
PhoneHome::checkVersion(programName.c_str(),
version.c_str(),
params.c_str());
}
}

## MakeString()

void ParameterList::MakeString | ( | int | argc,
|  | char ** | argv,
|  | int | start = `1`
| ) |  |

protected

Definition at line 712 of file Parameters.cpp.

{
int len = 0;
for (int i=start; i<argc; i++)
len += strlen(argv[i]) + 1;
string = new char [len+1];
string[0] = 0;
for (int i=start; i<argc; i++)
{
strcat(string, argv[i]);
strcat(string, " ");
}
}

## Read()

void ParameterList::Read | ( | int | argc,
|  | char ** | argv,
|  | int | start = `1`
| ) |  |

virtual

Definition at line 603 of file Parameters.cpp.

{
MakeString(argc, argv, start);
for (int i=start; i < argc; i++)
{
bool success = false;
if (argv[i][0] == '-' && argv[i][1])
for (int j=0; j<count; j++)
{
success = tolower(argv[i][1]) == pl[j]->ch;
if (success)
{
if ((i+1 < argc) && pl[j]->TranslateExtras(argv[i]+2, argv[i+1]))
i++;
else if (argv[i][2] == 0 && (i+1 < argc) && (argv[i + 1][0] != '-'))
pl[j]->Translate(argv[++i]);
else
pl[j]->Translate(argv[i] + 2);
break;
}
}
if (!success)
{
String warning;
warning.printf("Command line parameter %s (#%d) ignored\n", argv[i], i);
warnings += warning;
}
}
if (warnings.Length())
{
::warning("Problems encountered parsing command line:\n\n%s",
(const char *) warnings);
warnings.Clear();
}
HandlePhoneHome(argc, argv, start);
}

## ReadWithTrailer()

int ParameterList::ReadWithTrailer | ( | int | argc,
|  | char ** | argv,
|  | int | start = `1`
| ) |  |

virtual

Definition at line 647 of file Parameters.cpp.

{
MakeString(argc, argv, start);
int last_success = start - 1;
bool split = false;
for (int i=start; i < argc; i++)
{
bool success = false;
if (argv[i][0] == '-' && argv[i][1])
for (int j=0; j<count; j++)
{
success = tolower(argv[i][1]) == pl[j]->ch;
if (success)
{
if ((i+1 < argc) && pl[j]->TranslateExtras(argv[i]+2, argv[i+1]))
split = true;
else if (argv[i][2] == 0 && (i+1 < argc) && (argv[i + 1][0] != '-'))
pl[j]->Translate(argv[i + 1]), split = true;
else
pl[j]->Translate(argv[i] + 2);
break;
}
}
if (success)
for (last_success++; last_success < i; last_success++)
warnings.printf("Command line parameter %s (#%d) ignored\n",
argv[last_success], last_success);
if (split)
{
split = false;
last_success++;
i++;
}
}
if (warnings.Length())
{
::warning("Problems encountered parsing command line:\n\n%s",
(const char *) warnings);
warnings.Clear();
}
HandlePhoneHome(argc, argv, start);
return last_success;
};

## Status()

void ParameterList::Status | ( |  | ) |

virtual

Definition at line 701 of file Parameters.cpp.

{
for (int i=0; i<count; i++)
pl[i]->Status();
fprintf(stderr, "\n");
if (messages.Length())
fprintf(stderr, "NOTES:\n%s\n", (const char *) messages);
}

## Member Data Documentation

## count

int ParameterList::count

protected

Definition at line 300 of file Parameters.h.

## messages

String ParameterList::messages

Definition at line 333 of file Parameters.h.

## pl

Parameter** ParameterList::pl

protected

Definition at line 299 of file Parameters.h.

## size

int ParameterList::size

protected

Definition at line 301 of file Parameters.h.

## string

char* ParameterList::string

Definition at line 307 of file Parameters.h.

## warnings

String ParameterList::warnings

Definition at line 332 of file Parameters.h.

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

- general/Parameters.h
- general/Parameters.cpp