1 |
|
|
/*************************************** |
2 |
|
|
Auteur : Pierre Aubert |
3 |
|
|
Mail : pierre.aubert@lapp.in2p3.fr |
4 |
|
|
Licence : CeCILL-C |
5 |
|
|
****************************************/ |
6 |
|
|
|
7 |
|
|
#ifndef __PARSER_YML_IMPL_H__ |
8 |
|
|
#define __PARSER_YML_IMPL_H__ |
9 |
|
|
|
10 |
|
|
#include "DicoValue.h" |
11 |
|
|
|
12 |
|
|
///Get the value from a dictionnary |
13 |
|
|
/** @param dico : dictionnary to be used |
14 |
|
|
* @param varName : name of the variable to be used |
15 |
|
|
* @param defaultValue : default value |
16 |
|
|
* @return loaded value or default value |
17 |
|
|
*/ |
18 |
|
|
template<typename T> |
19 |
|
|
T phoenix_load_value_from_config(const DicoValue & dico, const std::string & varName, T defaultValue){ |
20 |
|
|
const DicoValue * param = dico.getMap(varName); |
21 |
|
|
if(param == NULL){ |
22 |
|
|
return defaultValue; |
23 |
|
|
}else{ |
24 |
|
|
return param->getValue<T>(); |
25 |
|
|
} |
26 |
|
|
} |
27 |
|
|
|
28 |
|
|
///Load a vector of value from a dictionnary |
29 |
|
|
/** @param[out] vecValue : loaded vector of values |
30 |
|
|
* @param dico : dictionnary to be used |
31 |
|
|
* @param varName : name of the variable to be used |
32 |
|
|
*/ |
33 |
|
|
template<typename T> |
34 |
|
2 |
void phoenix_load_vecValue_from_config(std::vector<T> & vecValue, const DicoValue & dico, const std::string & varName){ |
35 |
|
2 |
const DicoValue * param = dico.getMap(varName); |
36 |
✗✓ |
2 |
if(param == NULL){ |
37 |
|
|
return; |
38 |
|
|
} |
39 |
|
2 |
const VecDicoValue & vecChildValue = param->getVecChild(); |
40 |
✓✓ |
8 |
for(VecDicoValue::const_iterator it(vecChildValue.begin()); it != vecChildValue.end(); ++it){ |
41 |
✓✓ |
6 |
vecValue.push_back(it->getValue<T>()); |
42 |
|
|
} |
43 |
|
|
} |
44 |
|
|
|
45 |
|
|
///Load a vector of value from a dictionnary |
46 |
|
|
/** @param dico : dictionnary to be used |
47 |
|
|
* @param varName : name of the variable to be used |
48 |
|
|
* @return loaded vector of values |
49 |
|
|
*/ |
50 |
|
|
template<typename T> |
51 |
|
2 |
std::vector<T> phoenix_load_vecValue_from_config(const DicoValue & dico, const std::string & varName){ |
52 |
|
2 |
std::vector<T> out; |
53 |
✓ |
2 |
phoenix_load_vecValue_from_config(out, dico, varName); |
54 |
|
2 |
return out; |
55 |
|
|
} |
56 |
|
|
|
57 |
|
|
|
58 |
|
|
#endif |