GCC Code Coverage Report


Directory: ./
File: src/FieldParser_impl.h
Date: 2026-01-15 15:40:41
Exec Total Coverage
Lines: 44 48 91.7%
Functions: 12 12 100.0%
Branches: 33 47 70.2%

Line Branch Exec Source
1 /***************************************
2 Auteur : Pierre Aubert
3 Mail : pierre.aubert@lapp.in2p3.fr
4 Licence : CeCILL-C
5 ****************************************/
6
7 #ifndef __FIELDPARSER_IMPL_H__
8 #define __FIELDPARSER_IMPL_H__
9
10 #include "FieldParser.h"
11
12 ///Add a sub FieldParser for a scalar type
13 /** @param varPtr : pointer to the variable to be updated on the parsing of the protocol buffer message
14 * @param fieldId : id of the field that contain the sub message
15 * @param fieldName : name of the field
16 */
17 template<typename T>
18 27 void FieldParser::addParseFieldValue(T* varPtr, size_t fieldId, const PString & fieldName){
19
1/1
✓ Branch 0 (2→3) taken 27 times.
27 FieldParser* parser = createSubFieldParser(fieldId, fieldName);
20
2/2
✓ Branch 0 (3→4) taken 27 times.
✓ Branch 2 (4→5) taken 27 times.
27 parser->p_field.setType(phoenix_fieldType<T>());
21
1/1
✓ Branch 0 (5→6) taken 27 times.
27 parser->p_field.setNbElement(NULL);
22
1/1
✓ Branch 0 (6→7) taken 27 times.
27 parser->p_field.setTypeSize(sizeof(T));
23
1/1
✓ Branch 0 (7→8) taken 27 times.
27 parser->p_field.setVarPtr(varPtr);
24
1/1
✓ Branch 0 (8→9) taken 27 times.
27 parser->p_field.setIsArray(false);
25
1/1
✓ Branch 0 (9→10) taken 27 times.
27 parser->p_field.setOffset(0lu);
26
1/1
✓ Branch 0 (10→11) taken 27 times.
27 parser->p_field.setIsOffsetReady(false);
27
1/1
✓ Branch 0 (11→12) taken 27 times.
27 p_vecChildren.push_back(parser);
28 27 }
29
30 ///Add a sub FieldParser for a Array type
31 /** @param tabPtr : pointer to the table to be updated on the parsing of the protocol buffer message
32 * @param nbElement : pointer to the variable which will contain the number of element of the parsed array
33 * @param fieldId : id of the field that contain the sub message
34 * @param fieldName : name of the field
35 */
36 template<typename T>
37 4 void FieldParser::addParseFieldArray(T** tabPtr, size_t * nbElement, size_t fieldId, const PString & fieldName){
38
1/1
✓ Branch 0 (2→3) taken 4 times.
4 FieldParser* parser = createSubFieldParser(fieldId, fieldName);
39
2/2
✓ Branch 0 (3→4) taken 4 times.
✓ Branch 2 (4→5) taken 4 times.
4 parser->p_field.setType(phoenix_fieldType<T>());
40
1/1
✓ Branch 0 (5→6) taken 4 times.
4 parser->p_field.setNbElement(NULL);
41
1/1
✓ Branch 0 (6→7) taken 4 times.
4 parser->p_field.setTypeSize(sizeof(T));
42
1/1
✓ Branch 0 (7→8) taken 4 times.
4 parser->p_field.setArrayPtr((void**)tabPtr);
43
1/1
✓ Branch 0 (8→9) taken 4 times.
4 parser->p_field.setNbElement(nbElement);
44
1/1
✓ Branch 0 (9→10) taken 4 times.
4 parser->p_field.setIsArray(true);
45
1/1
✓ Branch 0 (10→11) taken 4 times.
4 parser->p_field.setOffset(0lu);
46
1/1
✓ Branch 0 (11→12) taken 4 times.
4 parser->p_field.setIsOffsetReady(false);
47
1/1
✓ Branch 0 (12→13) taken 4 times.
4 p_vecChildren.push_back(parser);
48 4 }
49
50 ///Add a sub FieldParser for a Array type
51 /** @param varPtr : pointer to the variable to be updated on the parsing of the protocol buffer message
52 * @param field : description of the field to be used
53 * @return true on success, false otherwise
54 */
55 template<typename T>
56 14 bool FieldParser::addParseFieldValue(T* varPtr, const FieldConfig & field){
57
1/2
✗ Branch 0 (3→4) not taken.
✓ Branch 1 (3→5) taken 14 times.
14 if(!checkInputType<T>(field)){return false;}
58 14 addParseFieldValue(varPtr, field.getId(), field.getName());
59 14 return true;
60 }
61
62 ///Add a sub FieldParser for a enum type
63 /** @param varPtr : pointer to the variable to be updated on the parsing of the protocol buffer message
64 * @param field : FieldConfig which describes the field
65 * @param childName : name of the child of the field to be used as description
66 * @return pointer to the parser which will be used to parse the sub message
67 */
68 template<typename T>
69 7 bool FieldParser::addParseFieldValue(T* varPtr, const FieldConfig & field, const PString & childName){
70
1/1
✓ Branch 0 (2→3) taken 7 times.
7 const std::map<PString, FieldConfig> & mapChildren = field.getVecChildren();
71
1/1
✓ Branch 0 (3→4) taken 7 times.
7 std::map<PString, FieldConfig>::const_iterator itFind = mapChildren.find(childName);
72
1/2
✓ Branch 0 (6→7) taken 7 times.
✗ Branch 1 (6→10) not taken.
7 if(itFind != mapChildren.end()){
73
1/1
✓ Branch 0 (8→9) taken 7 times.
7 return addParseFieldValue(varPtr, itFind->second);
74 }else{
75 std::cerr << "FieldParser::addParseFieldValue : FieldConfig has no child named '"<<childName<<"'" << std::endl;
76 return false;
77 }
78 }
79
80 ///Add a sub FieldParser for a Array type
81 /** @param tabPtr : pointer to the table to be updated on the parsing of the protocol buffer message
82 * @param nbElement : pointer to the variable which will contain the number of element of the parsed array
83 * @param field : description of the field to be used
84 * @return true on success, false otherwise
85 */
86 template<typename T>
87 2 bool FieldParser::addParseFieldArray(T** tabPtr, size_t * nbElement, const FieldConfig & field){
88
3/6
✓ Branch 0 (3→4) taken 2 times.
✗ Branch 1 (3→6) not taken.
✗ Branch 2 (5→6) not taken.
✓ Branch 3 (5→7) taken 2 times.
✗ Branch 4 (8→9) not taken.
✓ Branch 5 (8→15) taken 2 times.
2 if(!checkInputType<T>(field) || !field.getIsArray()){std::cerr << "FieldParser::addParseFieldArray : Field '"<<field.getName()<<"' is not defined as an array of the proper type" << std::endl;return false;} //If the field is not an array we quit
89 2 addParseFieldArray(tabPtr, nbElement, field.getId(), field.getName());
90 2 return true;
91 }
92
93 ///Add a sub FieldParser for a Array type
94 /** @param tabPtr : pointer to the table to be updated on the parsing of the protocol buffer message
95 * @param nbElement : pointer to the variable which will contain the number of element of the parsed array
96 * @param field : description of the field to be used
97 * @param childName : name of the child of the field to be used as description
98 * @return true on success, false otherwise
99 */
100 template<typename T>
101 1 bool FieldParser::addParseFieldArray(T** tabPtr, size_t * nbElement, const FieldConfig & field, const PString & childName){
102
1/1
✓ Branch 0 (2→3) taken 1 times.
1 const std::map<PString, FieldConfig> & mapChildren = field.getVecChildren();
103
1/1
✓ Branch 0 (3→4) taken 1 times.
1 std::map<PString, FieldConfig>::const_iterator itFind = mapChildren.find(childName);
104
1/2
✓ Branch 0 (6→7) taken 1 times.
✗ Branch 1 (6→10) not taken.
1 if(itFind != mapChildren.end()){
105
1/1
✓ Branch 0 (8→9) taken 1 times.
1 return addParseFieldArray(tabPtr, nbElement, itFind->second);
106 }else{
107 std::cerr << "FieldParser::addParseFieldArray : FieldConfig has no child named '"<<childName<<"'" << std::endl;
108 return false;
109 }
110 }
111
112 ///Check the template type with the FieldConfig
113 /** @param field : description of the field to be used
114 * @return true on success, false otherwise
115 */
116 template<typename T>
117 16 bool FieldParser::checkInputType(const FieldConfig & field){
118 16 FieldType::FieldType type(phoenix_fieldType<T>());
119 16 return checkInputType(type, field);
120 }
121
122 #endif
123
124