LifeV
StringDataList Class Reference

#include <StringData.hpp>

+ Collaboration diagram for StringDataList:

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< StringDataM_list
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ StringDataList() [1/2]

StringDataList ( )
inline

Definition at line 138 of file StringData.hpp.

◆ StringDataList() [2/2]

StringDataList ( std::string  title)

Definition at line 54 of file StringData.cpp.

+ Here is the caller graph for this function:

◆ ~StringDataList()

virtual ~StringDataList ( )
inlinevirtual

Definition at line 141 of file StringData.hpp.

Member Function Documentation

◆ add()

void add ( std::string  str,
Int  val,
std::string  help 
)

Definition at line 62 of file StringData.cpp.

◆ showMe()

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.

◆ value()

Int value ( const std::string &  str) const

Definition at line 82 of file StringData.cpp.

Field Documentation

◆ M_title

std::string M_title
private

Definition at line 157 of file StringData.hpp.

◆ M_list

std::vector<StringData> M_list
private

Definition at line 158 of file StringData.hpp.


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