PhoenixFileParser  1.5.1
Set of tools to ease file parsing
Loading...
Searching...
No Matches
phoenix_get_string_impl.h File Reference
#include "convertToString.h"
#include "phoenix_get_string.h"
+ Include dependency graph for phoenix_get_string_impl.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

template<typename T>
phoenix_get_value (const ConfigNode &dico, const PString &varName, const T &defaultValue)
 Get the corresponding value.
 
template<typename T>
phoenix_load_value_from_config (const DicoValue &dico, const PString &varName, T defaultValue)
 Get the value from a dictionnary.
 
template<typename T>
bool phoenix_load_value_from_dico (T &value, const DicoValue &dico, const PString &varName)
 Get the value from a dictionnary.
 
template<typename T>
std::vector< T > phoenix_load_vecValue (const ConfigNode &dico, const PString &varName)
 Load a vector of value from a ConfigNode.
 
template<typename T>
void phoenix_load_vecValue (std::vector< T > &vecValue, const ConfigNode &dico, const PString &varName)
 Load a vector of value from a ConfigNode.
 
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.
 
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.
 
template<typename T>
bool phoenix_save_value_to_dico (DicoValue &dico, const T &value, const PString &varName)
 Save the value to a dictionnary.
 

Function Documentation

◆ phoenix_get_value()

template<typename T>
T phoenix_get_value ( const ConfigNode & dico,
const PString & varName,
const T & defaultValue )

Get the corresponding value.

Parameters
dico: ConfigNode to be used
varName: name of the variable to be used
defaultValue: default value if varName is not found
Returns
corresponding value

Definition at line 97 of file phoenix_get_string_impl.h.

97 {
98 const ConfigNode * param = dico.getChild(varName);
99 if(param == NULL){
100 return defaultValue;
101 }else{
102 return param->getString().toValue<T>();
103 }
104}
Configuration of values.
Definition ConfigNode.h:18
PString getString() const
Get string value without " or ' at the beginning of the end.
ConfigNode * getChild(const PString &name)
Get the child of the given name.

References ConfigNode::getChild(), and ConfigNode::getString().

+ Here is the call graph for this function:

◆ phoenix_load_value_from_config()

template<typename T>
T phoenix_load_value_from_config ( const DicoValue & dico,
const PString & varName,
T 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}
Dictionnary of values.
Definition DicoValue.h:17
const DicoValue * getMap(const PString &key) const
Get a DicoValue in the map of the current one.
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_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().

+ Here is the call graph for this function:

◆ phoenix_load_vecValue() [1/2]

template<typename T>
std::vector< T > phoenix_load_vecValue ( const ConfigNode & dico,
const PString & varName )

Load a vector of value from a ConfigNode.

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

Definition at line 129 of file phoenix_get_string_impl.h.

129 {
130 std::vector<T> out;
131 phoenix_load_vecValue(out, dico, varName);
132 return out;
133}
void phoenix_load_vecValue(std::vector< T > &vecValue, const ConfigNode &dico, const PString &varName)
Load a vector of value from a ConfigNode.

References phoenix_load_vecValue().

+ Here is the call graph for this function:

◆ phoenix_load_vecValue() [2/2]

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

Load a vector of value from a ConfigNode.

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

Definition at line 112 of file phoenix_get_string_impl.h.

112 {
113 const ConfigNode * param = dico.getChild(varName);
114 if(param == NULL){
115 return;
116 }
117 const VecConfigNode & vecChildValue = param->getVecChild();
118 for(VecConfigNode::const_iterator it(vecChildValue.begin()); it != vecChildValue.end(); ++it){
119 vecValue.push_back((*it)->getString().toValue<T>());
120 }
121}
std::vector< ConfigNode * > VecConfigNode
Definition ConfigNode.h:74
const std::vector< ConfigNode * > & getVecChild() const
Gets the vecChild of the ConfigNode.

References ConfigNode::getChild(), and ConfigNode::getVecChild().

Referenced by phoenix_load_vecValue().

+ 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}
std::vector< DicoValue > VecDicoValue
Vector of DicoValue.
Definition DicoValue.h:80
const std::vector< DicoValue > & getVecChild() const
Gets the vecChild of the DicoValue.

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.
void setValue(const PString &value)
Sets the value of the DicoValue.
const std::map< PString, DicoValue > & getMapChild() const
Gets the mapChild of the DicoValue.

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

Referenced by phoenix_save_value_to_dico< bool >().

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