GCC Code Coverage Report


Directory: ./
File: tmp_project/PhoenixDataStream/src/data_stream_message.cpp
Date: 2025-03-14 12:18:05
Exec Total Coverage
Lines: 35 35 100.0%
Branches: 7 11 63.6%

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 "data_stream_message.h"
9
10
11 ///Read the bool in the message
12 /** @param[out] ds : message to be read
13 * @param[out] data : data to be set
14 * @return true on success, false otherwise
15 */
16 7 bool DataStream<DataStreamIter, DataStreamMode::READ, bool>::data_stream(DataStreamIter & ds, bool & data){
17 7 char* srcByte = (char*)&data;
18 7 memcpy(srcByte, ds, sizeof(bool));
19 7 ds += sizeof(bool);
20 7 return true;
21 }
22
23 ///Read the bool in the message
24 /** @param[out] ds : message to be read
25 * @param[out] data : data to be set
26 * @param nbElement : number of element of the data
27 * @return true on success, false otherwise
28 */
29 98 bool DataStream<DataStreamIter, DataStreamMode::READ, bool>::data_stream(DataStreamIter & ds, bool * data, size_t nbElement){
30 98 char* srcByte = (char*)data;
31 98 memcpy(srcByte, ds, sizeof(bool)*nbElement);
32 98 ds += sizeof(bool)*nbElement;
33 98 return true;
34 }
35
36 ///Save the bool in the message
37 /** @param[out] ds : message to be written
38 * @param data : data to be saved in the message
39 * @return true on success, false otherwise
40 */
41 12 bool DataStream<DataStreamIter, DataStreamMode::WRITE, bool>::data_stream(DataStreamIter & ds, bool & data){
42 12 const char* srcByte = (const char*)&data;
43 12 memcpy(ds, srcByte, sizeof(bool));
44 12 ds += sizeof(bool);
45 12 return true;
46 }
47
48 ///Save the bool in the message
49 /** @param[out] ds : message to be written
50 * @param data : data to be saved in the message
51 * @param nbElement : number of element of the data
52 * @return true on success, false otherwise
53 */
54 98 bool DataStream<DataStreamIter, DataStreamMode::WRITE, bool>::data_stream(DataStreamIter & ds, bool * data, size_t nbElement){
55 98 const char* srcByte = (const char*)data;
56 98 memcpy(ds, srcByte, sizeof(bool)*nbElement);
57 98 ds += sizeof(bool)*nbElement;
58 98 return true;
59 }
60
61
62
63
64
65 ///Load a std::string from a message
66 /** @param[out] ds : message iterator which contains std::string
67 * @param data : std::string to be loaded
68 * @return true on success, false otherwise
69 */
70 3 bool DataStream<DataStreamIter, DataStreamMode::READ, std::string>::data_stream(DataStreamIter & ds, std::string & data){
71 3 size_t nbElement(0lu);
72
1/1
✓ Branch 1 taken 3 times.
3 bool b = DataStream<DataStreamIter, DataStreamMode::READ, size_t>::data_stream(ds, nbElement);
73
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
3 if(nbElement == 0lu || !b){return b;}
74
1/1
✓ Branch 1 taken 3 times.
3 data.resize(nbElement);
75 3 memcpy((DataStreamIter)data.data(), ds, nbElement);
76 3 ds += nbElement;
77 3 return b;
78 }
79
80
81 ///Save a std::string into a message
82 /** @param[out] ds : message iterator to be written
83 * @param data : std::string to be saved
84 * @return true on success, false otherwise
85 */
86 3 bool DataStream<DataStreamIter, DataStreamMode::WRITE, std::string>::data_stream(DataStreamIter & ds, std::string & data){
87 3 size_t nbElement(data.size());
88
1/1
✓ Branch 1 taken 3 times.
3 bool b = DataStream<DataStreamIter, DataStreamMode::WRITE, size_t>::data_stream(ds, nbElement);
89
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
3 if(nbElement == 0lu || !b){return b;}
90 3 memcpy(ds, (const DataStreamIter)data.data(), nbElement);
91 3 ds += nbElement;
92 3 return b;
93 }
94
95
96