LifeV
|
#include <StringData.hpp>
Constructor | |
StringDataList () | |
StringDataList (std::string title) | |
virtual | ~StringDataList () |
Public methods | |
void | add (std::string str, Int val, std::string help) |
void | showMe (std::ostream &c=std::cout, bool val=false) const |
State printing function (val=true:the values are shown) More... | |
Int | value (const std::string &str) const |
Private data members | |
std::string | M_title |
std::vector< StringData > | M_list |
To build a list of data string.
Example:
You want to propose to the user three solvers: cg, gmres, cgs inside the code these solvers are identified by the values 1, 2, 3
You first create the list:
StringDataList solver_list("My solvers"); solver_list.add("cg",1,"preconditioned conjugate gradient method"); solver_list.add("gmres",2,"preconditioned gmres method"); solver_list.add("cgs",2,"preconditioned cg squared method");
Next, you read (for example) a GetPot data file, where the user gives you a string string_string. To get the value corresponding the string provided by the user:
solver = aztec_solver_list.value(user_string);
if the "user_string" belongs to the list, then solver has the corresponding value, else, the list of possible choices (with help) is given and the code stop with an error.
Definition at line 133 of file StringData.hpp.
|
inline |
Definition at line 138 of file StringData.hpp.
StringDataList | ( | std::string | title | ) |
|
inlinevirtual |
Definition at line 141 of file StringData.hpp.
void add | ( | std::string | str, |
Int | val, | ||
std::string | help | ||
) |
Definition at line 62 of file StringData.cpp.
void showMe | ( | std::ostream & | c = std::cout , |
bool | val = false |
||
) | const |
State printing function (val=true:the values are shown)
Definition at line 67 of file StringData.cpp.
Int value | ( | const std::string & | str | ) | const |
Definition at line 82 of file StringData.cpp.
|
private |
Definition at line 157 of file StringData.hpp.
|
private |
Definition at line 158 of file StringData.hpp.