PhoenixPresentation  2.0.0
Set of cmake function to automate presentation generation
main.cpp
Go to the documentation of this file.
1 
2 /***************************************
3  Auteur : Pierre Aubert
4  Mail : pierre.aubert@lapp.in2p3.fr
5  Licence : CeCILL-C
6 ****************************************/
7 
8 #include "phoenix_assert.h"
9 #include "phoenix_check.h"
10 #include "phoenix_get_string.h"
11 
14  phoenix_assert(phoenix_convertBoolType("true") == true);
17  phoenix_assert(phoenix_convertBoolType("TRUE") == true);
19  phoenix_assert(phoenix_convertBoolType("false") == false);
20  phoenix_assert(phoenix_convertBoolType("FALSE") == false);
22  phoenix_assert(phoenix_convertBoolType("Other stuff") == false);
23 }
24 
27  DicoValue value;
28  value.setValue("true");
29  value.setKey("value");
30  phoenix_assert(value.hasKey());
31  DicoValue dico;
32  dico.getMapChild()["value"] = value;
33 
34  DicoValue valueStrInt;
35  valueStrInt.setValue("42");
36  valueStrInt.setKey("valueInt");
37  dico.getMapChild()["valueInt"] = valueStrInt;
38 
39  phoenix_assert(dico.hasMap());
40  phoenix_assert(!dico.hasVec());
41  phoenix_assert(!dico.hasKey());
42 
43  int valueInt(0);
44  phoenix_assert(phoenix_load_value_from_dico(valueInt, dico, "valueInt"));
45  phoenix_assert(phoenix_check("Load valueInt", valueInt, 42));
46  phoenix_assert(!phoenix_load_value_from_dico(valueInt, dico, "unexistValueInt"));
47 
48  phoenix_assert(phoenix_load_value_from_config<bool>(dico, "value", false) == true);
49  phoenix_assert(phoenix_load_value_from_config<bool>(dico, "no_value", false) == false);
50 
51  bool valueBool(false);
52  phoenix_assert(phoenix_load_value_from_dico<bool>(valueBool, dico, "value") == true);
53  phoenix_assert(phoenix_load_value_from_dico<bool>(valueBool, dico, "no_value") == false);
54 
55  bool valueBoolToSave(true), valueBoolToSaveFalse(true);
56  phoenix_assert(phoenix_save_value_to_dico<bool>(dico, valueBoolToSave, "valueBool") == true);
57  phoenix_assert(phoenix_save_value_to_dico<bool>(dico, valueBoolToSaveFalse, "valueBoolFalse") == true);
58 
59  phoenix_assert(phoenix_load_value_from_dico<bool>(valueBool, dico, "valueBool") == true);
60  phoenix_assert(phoenix_load_value_from_dico<bool>(valueBool, dico, "valueBoolFalse") == true);
61 
62  phoenix_assert(phoenix_load_value_from_config<std::string>(dico, "value", "false") == "true");
63  phoenix_assert(phoenix_load_value_from_config<std::string>(dico, "no_value", "false") == "false");
64 
65  phoenix_assert(phoenix_get_string(dico, "value", "false") == "true");
66  phoenix_assert(phoenix_get_string(dico, "no_value", "false") == "false");
67 
68  phoenix_assert(phoenix_get_string(dico, "value", "false", "otherValue") == "true");
69  phoenix_assert(phoenix_get_string(dico, "no_value", "false", "otherValue") == "false");
70  phoenix_assert(phoenix_get_string(dico, "no_value", "", "otherValue") == "otherValue");
71 
72  DicoValue dicoVec;
73  dicoVec.getVecChild().push_back(value);
74  value.setKey("vecvalue");
75 
76  DicoValue dicoWithVec;
77  dicoWithVec.getMapChild()["vecvalue"] = dicoVec;
78  PVecString vecStr = phoenix_get_vecstring(dicoWithVec, "vecvalue");
79  phoenix_assert(vecStr.size() == 1lu);
80  phoenix_assert(phoenix_get_vecstring(dicoWithVec, "no_vecvalue").size() == 0lu);
81 }
82 
83 int main(int argc, char** argv){
86  return 0;
87 }
88 
89 
std::vector< PString > PVecString
Definition: PString.h:96
int main(int argc, char **argv)
Definition: main.cpp:228
void checkLoadFromConfig()
Check load from config.
Definition: main.cpp:26
void convertBoolType()
CHeck the phoenix_convertBoolType.
Definition: main.cpp:13
Dictionnary of values.
Definition: DicoValue.h:17
void setKey(const PString &key)
Sets the key of the DicoValue.
Definition: DicoValue.cpp:148
bool hasKey() const
Say if the DicoValue has a key.
Definition: DicoValue.cpp:91
const std::vector< DicoValue > & getVecChild() const
Gets the vecChild of the DicoValue.
Definition: DicoValue.cpp:204
void setValue(const PString &value)
Sets the value of the DicoValue.
Definition: DicoValue.cpp:141
bool hasMap() const
Say if the DicoValue has a map of children.
Definition: DicoValue.cpp:96
const std::map< PString, DicoValue > & getMapChild() const
Gets the mapChild of the DicoValue.
Definition: DicoValue.cpp:218
bool hasVec() const
Say if the DicoValue has a vector of children.
Definition: DicoValue.cpp:101
#define phoenix_assert(isOk)
bool phoenix_check(const std::string &testName, const std::string &val, const std::string &reference)
Check two string.
PString phoenix_get_string(const DicoValue &dico, const PString &varName, const PString &defaultValue)
Get the string from a dictionnary.
bool phoenix_load_value_from_dico< bool >(bool &value, const DicoValue &dico, const PString &varName)
Get bool value from a dictionnary (specialization for bool)
bool phoenix_convertBoolType(const PString &strConfig)
Convert the configuration of the cleaning type into a bool.
bool phoenix_save_value_to_dico< bool >(DicoValue &dico, const bool &value, const PString &varName)
Save the value to a dictionnary (specialization for bool)
bool phoenix_load_value_from_config< bool >(const DicoValue &dico, const PString &varName, bool defaultValue)
Get bool value from a dictionnary (specialization for bool)
void phoenix_get_vecstring(PVecString &vecValue, const DicoValue &dico, const PString &varName)
Load a vector of string from a dictionnary.
bool phoenix_load_value_from_dico(T &value, const DicoValue &dico, const PString &varName)
Get the value from a dictionnary.