| 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 | 1 | bool DataStream<DataStreamIter, DataStreamMode::READ, bool>::data_stream(DataStreamIter & ds, bool & data){ | |
| 17 | 1 | char* srcByte = (char*)&data; | |
| 18 | 1 | memcpy(srcByte, ds, sizeof(bool)); | |
| 19 | 1 | ds += sizeof(bool); | |
| 20 | 1 | 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 | 1 | bool DataStream<DataStreamIter, DataStreamMode::WRITE, bool>::data_stream(DataStreamIter & ds, bool & data){ | |
| 42 | 1 | const char* srcByte = (const char*)&data; | |
| 43 | 1 | memcpy(ds, srcByte, sizeof(bool)); | |
| 44 | 1 | ds += sizeof(bool); | |
| 45 | 1 | 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 | 2 | bool DataStream<DataStreamIter, DataStreamMode::READ, std::string>::data_stream(DataStreamIter & ds, std::string & data){ | |
| 71 | 2 | size_t nbElement(0lu); | |
| 72 |
1/1✓ Branch 0 (2→3) taken 2 times.
|
2 | bool b = DataStream<DataStreamIter, DataStreamMode::READ, size_t>::data_stream(ds, nbElement); |
| 73 |
2/4✓ Branch 0 (3→4) taken 2 times.
✗ Branch 1 (3→5) not taken.
✗ Branch 2 (4→5) not taken.
✓ Branch 3 (4→6) taken 2 times.
|
2 | if(nbElement == 0lu || !b){return b;} |
| 74 |
1/1✓ Branch 0 (6→7) taken 2 times.
|
2 | data.resize(nbElement); |
| 75 | 2 | memcpy((DataStreamIter)data.data(), ds, nbElement); | |
| 76 | 2 | ds += nbElement; | |
| 77 | 2 | 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 | 2 | bool DataStream<DataStreamIter, DataStreamMode::WRITE, std::string>::data_stream(DataStreamIter & ds, std::string & data){ | |
| 87 | 2 | size_t nbElement(data.size()); | |
| 88 |
1/1✓ Branch 0 (3→4) taken 2 times.
|
2 | bool b = DataStream<DataStreamIter, DataStreamMode::WRITE, size_t>::data_stream(ds, nbElement); |
| 89 |
2/4✓ Branch 0 (4→5) taken 2 times.
✗ Branch 1 (4→6) not taken.
✗ Branch 2 (5→6) not taken.
✓ Branch 3 (5→7) taken 2 times.
|
2 | if(nbElement == 0lu || !b){return b;} |
| 90 | 2 | memcpy(ds, (const DataStreamIter)data.data(), nbElement); | |
| 91 | 2 | ds += nbElement; | |
| 92 | 2 | return b; | |
| 93 | } | ||
| 94 | |||
| 95 | |||
| 96 |