PhoenixPresentation  2.0.0
Set of cmake function to automate presentation generation
phoenix_get_string.h File Reference
#include "DicoValue.h"
#include "phoenix_get_string_impl.h"
+ Include dependency graph for phoenix_get_string.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

bool phoenix_convertBoolType (const PString &strConfig)
 Convert the configuration of the cleaning type into a bool. More...
 
PString phoenix_get_string (const DicoValue &dico, const PString &varName, const PString &defaultValue)
 Get the string from a dictionnary. More...
 
PString phoenix_get_string (const DicoValue &dico, const PString &varName, const PString &defaultValue, const PString &defaultValue2)
 Get the string from a dictionnary. More...
 
PVecString phoenix_get_vecstring (const DicoValue &dico, const PString &varName)
 Load a vector of string from a dictionnary. More...
 
void phoenix_get_vecstring (PVecString &vecValue, const DicoValue &dico, const PString &varName)
 Load a vector of string from a dictionnary. More...
 
template<typename T >
phoenix_load_value_from_config (const DicoValue &dico, const PString &varName, T defaultValue)
 Get the value from a dictionnary. More...
 
template<>
bool phoenix_load_value_from_config< bool > (const DicoValue &dico, const PString &varName, bool defaultValue)
 Get bool value from a dictionnary (specialization for bool) More...
 
template<typename T >
bool phoenix_load_value_from_dico (T &value, const DicoValue &dico, const PString &varName)
 Get the value from a dictionnary. More...
 
template<>
bool phoenix_load_value_from_dico< bool > (bool &value, const DicoValue &dico, const PString &varName)
 Get bool value from a dictionnary (specialization for bool) More...
 
template<typename T >
std::vector< T > phoenix_load_vecValue_from_config (const DicoValue &dico, const PString &varName)
 Load a vector of value from a dictionnary. More...
 
template<typename T >
void phoenix_load_vecValue_from_config (std::vector< T > &vecValue, const DicoValue &dico, const PString &varName)
 Load a vector of value from a dictionnary. More...
 
template<typename T >
bool phoenix_save_value_to_dico (DicoValue &dico, const T &value, const PString &varName)
 Save the value to a dictionnary. More...
 
template<>
bool phoenix_save_value_to_dico< bool > (DicoValue &dico, const bool &value, const PString &varName)
 Save the value to a dictionnary (specialization for bool) More...
 

Function Documentation

◆ phoenix_convertBoolType()

bool phoenix_convertBoolType ( const PString strConfig)

Convert the configuration of the cleaning type into a bool.

Parameters
strConfig: configuration string
Returns
corresponding value

Definition at line 13 of file phoenix_get_string.cpp.

13  {
14  PString config(strConfig.toLower());
15  return config == "true" || strConfig == "1" || config == "yes";
16 }
Extends the std::string.
Definition: PString.h:16
PString toLower() const
Convert PString in lower case.
Definition: PString.cpp:598

References PString::toLower().

Referenced by convertBoolType(), phoenix_load_value_from_config< bool >(), and phoenix_load_value_from_dico< bool >().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ phoenix_get_string() [1/2]

PString phoenix_get_string ( const DicoValue dico,
const PString varName,
const PString defaultValue 
)

Get the string from a dictionnary.

Parameters
dico: dictionnary to be used
varName: name of the variable to be used
defaultValue: default value
Returns
loaded string or default value

Definition at line 101 of file phoenix_get_string.cpp.

101  {
102  const DicoValue * param = dico.getMap(varName);
103  if(param == NULL){
104  return defaultValue;
105  }else{
106  return param->getString();
107  }
108 }
Dictionnary of values.
Definition: DicoValue.h:17
const DicoValue * getMap(const PString &key) const
Get a DicoValue in the map of the current one.
Definition: DicoValue.cpp:116
PString getString() const
Get a string value without the first and/or last quote or double quote in there are some.
Definition: DicoValue.cpp:183

References DicoValue::getMap(), and DicoValue::getString().

Referenced by checkLoadFromConfig().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ phoenix_get_string() [2/2]

PString phoenix_get_string ( const DicoValue dico,
const PString varName,
const PString defaultValue,
const PString defaultValue2 
)

Get the string from a dictionnary.

Parameters
dico: dictionnary to be used
varName: name of the variable to be used
defaultValue: default value
defaultValue2: default value to be used if the first defaultValue is empty
Returns
loaded string or default value

Definition at line 117 of file phoenix_get_string.cpp.

117  {
118  const DicoValue * param = dico.getMap(varName);
119  if(param == NULL){
120  if(defaultValue != ""){
121  return defaultValue;
122  }else{
123  return defaultValue2;
124  }
125  }else{
126  return param->getString();
127  }
128 }

References DicoValue::getMap(), and DicoValue::getString().

+ Here is the call graph for this function:

◆ phoenix_get_vecstring() [1/2]

PVecString phoenix_get_vecstring ( const DicoValue dico,
const PString varName 
)

Load a vector of string from a dictionnary.

Parameters
dico: dictionnary to be used
varName: name of the variable to be used
Returns
loaded vector of values

Definition at line 88 of file phoenix_get_string.cpp.

88  {
89  PVecString out;
90  phoenix_get_vecstring(out, dico, varName);
91  return out;
92 }
std::vector< PString > PVecString
Definition: PString.h:96
void phoenix_get_vecstring(PVecString &vecValue, const DicoValue &dico, const PString &varName)
Load a vector of string from a dictionnary.

References phoenix_get_vecstring().

+ Here is the call graph for this function:

◆ phoenix_get_vecstring() [2/2]

void phoenix_get_vecstring ( PVecString vecValue,
const DicoValue dico,
const PString varName 
)

Load a vector of string from a dictionnary.

Parameters
[out]vecValue: loaded vector of values
dico: dictionnary to be used
varName: name of the variable to be used

Definition at line 72 of file phoenix_get_string.cpp.

72  {
73  const DicoValue * param = dico.getMap(varName);
74  if(param == NULL){
75  return;
76  }
77  const VecDicoValue & vecChildValue = param->getVecChild();
78  for(VecDicoValue::const_iterator it(vecChildValue.begin()); it != vecChildValue.end(); ++it){
79  vecValue.push_back(it->getString());
80  }
81 }
std::vector< DicoValue > VecDicoValue
Vector of DicoValue.
Definition: DicoValue.h:77
const std::vector< DicoValue > & getVecChild() const
Gets the vecChild of the DicoValue.
Definition: DicoValue.cpp:204

References DicoValue::getMap(), and DicoValue::getVecChild().

Referenced by checkLoadFromConfig(), and phoenix_get_vecstring().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ phoenix_load_value_from_config()

template<typename T >
T phoenix_load_value_from_config ( const DicoValue dico,
const PString varName,
defaultValue 
)

Get the value from a dictionnary.

Parameters
dico: dictionnary to be used
varName: name of the variable to be used
defaultValue: default value
Returns
loaded value or default value

Definition at line 20 of file phoenix_get_string_impl.h.

20  {
21  const DicoValue * param = dico.getMap(varName);
22  if(param == NULL){
23  return defaultValue;
24  }else{
25  return param->getValue<T>();
26  }
27 }
T getValue() const
Convert the value of the current DicoValue into a type.

References DicoValue::getMap(), and DicoValue::getValue().

+ Here is the call graph for this function:

◆ phoenix_load_value_from_config< bool >()

template<>
bool phoenix_load_value_from_config< bool > ( const DicoValue dico,
const PString varName,
bool  defaultValue 
)

Get bool value from a dictionnary (specialization for bool)

Parameters
dico: dictionnary to be used
varName: name of the variable to be used
defaultValue: default value
Returns
loaded value or default value

Definition at line 25 of file phoenix_get_string.cpp.

25  {
26  const DicoValue * param = dico.getMap(varName);
27  if(param == NULL){
28  return defaultValue;
29  }else{
30  return phoenix_convertBoolType(param->getString());
31  }
32 }
bool phoenix_convertBoolType(const PString &strConfig)
Convert the configuration of the cleaning type into a bool.

References DicoValue::getMap(), DicoValue::getString(), and phoenix_convertBoolType().

Referenced by checkLoadFromConfig().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ phoenix_load_value_from_dico()

template<typename T >
bool phoenix_load_value_from_dico ( T &  value,
const DicoValue dico,
const PString varName 
)

Get the value from a dictionnary.

Parameters
[out]value: value to be loaded
dico: dictionnary to be used
varName: name of the variable to be used
Returns
true if the value was loaded, false otherwise

Definition at line 36 of file phoenix_get_string_impl.h.

36  {
37  const DicoValue * param = dico.getMap(varName);
38  if(param == NULL){
39  return false;
40  }else{
41  value = param->getValue<T>();
42  return true;
43  }
44 }

References DicoValue::getMap(), and DicoValue::getValue().

Referenced by checkLoadFromConfig().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ phoenix_load_value_from_dico< bool >()

template<>
bool phoenix_load_value_from_dico< bool > ( bool &  value,
const DicoValue dico,
const PString varName 
)

Get bool value from a dictionnary (specialization for bool)

Parameters
[out]value: value to be loaded
dico: dictionnary to be used
varName: name of the variable to be used
defaultValue: default value
Returns
loaded value or default value

Definition at line 42 of file phoenix_get_string.cpp.

42  {
43  const DicoValue * param = dico.getMap(varName);
44  if(param == NULL){
45  return false;
46  }else{
47  value = phoenix_convertBoolType(param->getString());
48  return true;
49  }
50 }

References DicoValue::getMap(), DicoValue::getString(), and phoenix_convertBoolType().

Referenced by checkLoadFromConfig().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ phoenix_load_vecValue_from_config() [1/2]

template<typename T >
std::vector<T> phoenix_load_vecValue_from_config ( const DicoValue dico,
const PString varName 
)

Load a vector of value from a dictionnary.

Parameters
dico: dictionnary to be used
varName: name of the variable to be used
Returns
loaded vector of values

Definition at line 84 of file phoenix_get_string_impl.h.

84  {
85  std::vector<T> out;
86  phoenix_load_vecValue_from_config(out, dico, varName);
87  return out;
88 }
void phoenix_load_vecValue_from_config(std::vector< T > &vecValue, const DicoValue &dico, const PString &varName)
Load a vector of value from a dictionnary.

References phoenix_load_vecValue_from_config().

+ Here is the call graph for this function:

◆ phoenix_load_vecValue_from_config() [2/2]

template<typename T >
void phoenix_load_vecValue_from_config ( std::vector< T > &  vecValue,
const DicoValue dico,
const PString varName 
)

Load a vector of value from a dictionnary.

Parameters
[out]vecValue: loaded vector of values
dico: dictionnary to be used
varName: name of the variable to be used

Definition at line 67 of file phoenix_get_string_impl.h.

67  {
68  const DicoValue * param = dico.getMap(varName);
69  if(param == NULL){
70  return;
71  }
72  const VecDicoValue & vecChildValue = param->getVecChild();
73  for(VecDicoValue::const_iterator it(vecChildValue.begin()); it != vecChildValue.end(); ++it){
74  vecValue.push_back(it->getValue<T>());
75  }
76 }

References DicoValue::getMap(), and DicoValue::getVecChild().

Referenced by phoenix_load_vecValue_from_config().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ phoenix_save_value_to_dico()

template<typename T >
bool phoenix_save_value_to_dico ( DicoValue dico,
const T &  value,
const PString varName 
)

Save the value to a dictionnary.

Parameters
[out]dico: dictionnary to be updated
value: value to be saved
varName: name of the variable to be used
Returns
true if the value was saved, false otherwise (return is always true)

Definition at line 53 of file phoenix_get_string_impl.h.

53  {
54  DicoValue param;
55  param.setKey(varName);
56  param.setValue(valueToString(value));
57  dico.getMapChild()[varName] = param;
58  return true;
59 }
void setKey(const PString &key)
Sets the key of the DicoValue.
Definition: DicoValue.cpp:148
void setValue(const PString &value)
Sets the value of the DicoValue.
Definition: DicoValue.cpp:141
const std::map< PString, DicoValue > & getMapChild() const
Gets the mapChild of the DicoValue.
Definition: DicoValue.cpp:218
std::string valueToString(const T &val)
Convert a type into a string.

References DicoValue::getMapChild(), DicoValue::setKey(), DicoValue::setValue(), and valueToString().

Referenced by phoenix_save_value_to_dico< bool >().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ phoenix_save_value_to_dico< bool >()

template<>
bool phoenix_save_value_to_dico< bool > ( DicoValue dico,
const bool &  value,
const PString varName 
)

Save the value to a dictionnary (specialization for bool)

Parameters
[out]dico: dictionnary to be updated
value: value to be saved
varName: name of the variable to be used
Returns
true if the value was saved, false otherwise (return is always true)

Definition at line 59 of file phoenix_get_string.cpp.

59  {
60  std::string strValue("false");
61  if(value){
62  strValue = "true";
63  }
64  return phoenix_save_value_to_dico(dico, strValue, varName);
65 }
bool phoenix_save_value_to_dico(DicoValue &dico, const T &value, const PString &varName)
Save the value to a dictionnary.

References phoenix_save_value_to_dico().

Referenced by checkLoadFromConfig().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: