GCC Code Coverage Report


Directory: ./
File: src/ConfigNodeIter.cpp
Date: 2025-11-27 16:44:16
Exec Total Coverage
Lines: 22 41 53.7%
Functions: 5 12 41.7%
Branches: 4 9 44.4%

Line Branch Exec Source
1 /***************************************
2 Auteur : Pierre Aubert
3 Mail : pierre.aubert@lapp.in2p3.fr
4 Licence : CeCILL-C
5 ****************************************/
6
7
8 #include "ConfigNodeIter.h"
9
10 ///Default constructor of ConfigNodeIter
11 /** @param current : pointer to the current ConfigNode
12 * @param out : std::ostream to be used for the error messages
13 */
14 3 ConfigNodeIter::ConfigNodeIter(const ConfigNode * current, std::ostream * out, bool isWriteMode)
15 3 :p_current((ConfigNode *)current), p_out(out), p_isWriteMode(isWriteMode)
16 {
17 3 initialisationConfigNodeIter();
18 3 }
19
20 ///Copy constructor of ConfigNodeIter
21 /** @param other : class to copy
22 */
23 ConfigNodeIter::ConfigNodeIter(const ConfigNodeIter & other){
24 copyConfigNodeIter(other);
25 }
26
27 ///Destructor of ConfigNodeIter
28 3 ConfigNodeIter::~ConfigNodeIter(){
29
30 3 }
31
32 ///Definition of equal operator of ConfigNodeIter
33 /** @param other : class to copy
34 * @return copied class
35 */
36 ConfigNodeIter & ConfigNodeIter::operator = (const ConfigNodeIter & other){
37 copyConfigNodeIter(other);
38 return *this;
39 }
40
41 ///Get the current ConfigNode
42 /** @return current ConfigNode
43 */
44 ConfigNode * ConfigNodeIter::operator -> (){
45 return p_current;
46 }
47
48 ///Get the pointer of the output stream
49 /** @return pointer of the output stream
50 */
51 std::ostream * ConfigNodeIter::getOut(){
52 return p_out;
53 }
54
55 ///Move to the parent of the current node
56 5 void ConfigNodeIter::up(){
57 5 const ConfigNode * parent = p_current->getParent();
58
1/2
✓ Branch 0 (3→4) taken 5 times.
✗ Branch 1 (3→5) not taken.
5 if(parent != NULL){
59 5 p_current = (ConfigNode *)parent;
60 }
61 5 }
62
63 ///Move to the child of the current node
64 /** @param childName : name of the child
65 * @return true if the child does exist, false otherwise
66 */
67 9 bool ConfigNodeIter::down(const PString & childName){
68 9 const ConfigNode * child = p_current->getChild(childName);
69
2/2
✓ Branch 0 (3→4) taken 6 times.
✓ Branch 1 (3→5) taken 3 times.
9 if(child != NULL){
70 6 p_current = (ConfigNode *)child;
71 6 return true;
72 }else{
73
1/2
✓ Branch 0 (5→6) taken 3 times.
✗ Branch 1 (5→8) not taken.
3 if(p_isWriteMode){
74 3 ConfigNode * child = p_current->addChild(childName);
75 3 p_current = child;
76 3 return true;
77 }else{
78 *p_out << "ConfigNodeIter::down : no child '"<<childName<<"' defined in ConfigNode " << p_current->getLocation() << std::endl;
79 return false;
80 }
81 }
82 }
83
84 ///Say if the iterator is in write mode
85 /** @return true if the iterator is in write mode
86 */
87 bool ConfigNodeIter::isWriteMode() const{
88 return p_isWriteMode;
89 }
90
91 ///Copy function of ConfigNodeIter
92 /** @param other : class to copy
93 */
94 void ConfigNodeIter::copyConfigNodeIter(const ConfigNodeIter & other){
95 p_current = other.p_current;
96 p_out = other.p_out;
97 p_isWriteMode = other.p_isWriteMode;
98 }
99
100 ///Initialisation function of the class ConfigNodeIter
101 3 void ConfigNodeIter::initialisationConfigNodeIter(){
102
103 3 }
104
105
106
107
108
109