| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /*************************************** | ||
| 2 | Auteur : Pierre Aubert | ||
| 3 | Mail : pierre.aubert@lapp.in2p3.fr | ||
| 4 | Licence : CeCILL-C | ||
| 5 | ****************************************/ | ||
| 6 | |||
| 7 | #ifndef __DICOVALUE_H__ | ||
| 8 | #define __DICOVALUE_H__ | ||
| 9 | |||
| 10 | #include <vector> | ||
| 11 | #include <map> | ||
| 12 | #include "PPath.h" | ||
| 13 | |||
| 14 | #include "PFileParser.h" | ||
| 15 | |||
| 16 | ///@brief Dictionnary of values | ||
| 17 | class DicoValue{ | ||
| 18 | public: | ||
| 19 | DicoValue(); | ||
| 20 | DicoValue(const DicoValue & other); | ||
| 21 | virtual ~DicoValue(); | ||
| 22 | DicoValue & operator = (const DicoValue & other); | ||
| 23 | |||
| 24 | bool load(const PPath & fileName); | ||
| 25 |
8/8✓ Branch 0 (32→33) taken 1 times.
✓ Branch 2 (33→34) taken 1 times.
✓ Branch 4 (7→8) taken 3 times.
✓ Branch 6 (8→9) taken 3 times.
✓ Branch 8 (9→10) taken 3 times.
✓ Branch 10 (2→3) taken 7 times.
✓ Branch 12 (3→4) taken 7 times.
✓ Branch 14 (4→5) taken 7 times.
|
22 | bool save(const PPath & fileName, const PString & valueDecorator = "", PString baseIndentation = "\t", PString baseNewLine = "\n") const; |
| 26 | |||
| 27 | bool fromString(const PString & content); | ||
| 28 | PString toString(const PString & valueDecorator = "", PString baseIndentation = "\t", PString baseNewLine = "\n") const; | ||
| 29 | void print() const; | ||
| 30 | |||
| 31 | template<typename T> | ||
| 32 | T getValue() const; | ||
| 33 | |||
| 34 | bool hasKey() const; | ||
| 35 | bool hasMap() const; | ||
| 36 | bool hasVec() const; | ||
| 37 | bool isKeyExist(const PString & key) const; | ||
| 38 | const DicoValue * getMap(const PString & key) const; | ||
| 39 | const DicoValue * getMap(const PVecString & vecKey) const; | ||
| 40 | DicoValue * getMap(const PString & key); | ||
| 41 | const DicoValue * getElementInVecWhere(const PString & key, const PString & value) const; | ||
| 42 | |||
| 43 | void setValue(const PString & value); | ||
| 44 | void setKey(const PString & key); | ||
| 45 | void setVecChild(const std::vector<DicoValue> & vecChild); | ||
| 46 | void setMapChild(const std::map<PString, DicoValue> & mapChild); | ||
| 47 | const PString & getValue() const; | ||
| 48 | PString & getValue(); | ||
| 49 | PString getString() const; | ||
| 50 | const PString & getKey() const; | ||
| 51 | PString & getKey(); | ||
| 52 | const std::vector<DicoValue> & getVecChild() const; | ||
| 53 | std::vector<DicoValue> & getVecChild(); | ||
| 54 | const std::map<PString, DicoValue> & getMapChild() const; | ||
| 55 | std::map<PString, DicoValue> & getMapChild(); | ||
| 56 | |||
| 57 | protected: | ||
| 58 | void copyDicoValue(const DicoValue & other); | ||
| 59 | private: | ||
| 60 | bool loadParser(PFileParser & parser); | ||
| 61 | bool parseDicoValue(PFileParser & parser, bool & isRunning); | ||
| 62 | bool parseListOrMap(PFileParser & parser, bool & isRunning); | ||
| 63 | bool parseList(PFileParser & parser, bool & isRunning); | ||
| 64 | bool parseString(PString & parsedString, PFileParser & parser); | ||
| 65 | bool errorAt(PFileParser & parser, bool & isRunning, const PString & errorMsg); | ||
| 66 | |||
| 67 | PString saveRecurse(const PString & indentation, const PString & valueDecorator, PString baseIndentation, PString baseNewLine, bool isInList = false) const; | ||
| 68 | |||
| 69 | ///Value of the current entry | ||
| 70 | PString p_value; | ||
| 71 | ///Key of the current entry | ||
| 72 | PString p_key; | ||
| 73 | ///Vector of sub DicoValue | ||
| 74 | std::vector<DicoValue> p_vecChild; | ||
| 75 | ///Map of sub DicoValue | ||
| 76 | std::map<PString, DicoValue> p_mapChild; | ||
| 77 | }; | ||
| 78 | |||
| 79 | ///Vector of DicoValue | ||
| 80 | typedef std::vector<DicoValue> VecDicoValue; | ||
| 81 | ///Vector of DicoValue | ||
| 82 | typedef std::map<PString, DicoValue> MapDicoValue; | ||
| 83 | |||
| 84 | #include "DicoValue_impl.h" | ||
| 85 | |||
| 86 | #endif | ||
| 87 | |||
| 88 |