| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /*************************************** | ||
| 2 | Auteur : Pierre Aubert | ||
| 3 | Mail : pierre.aubert@lapp.in2p3.fr | ||
| 4 | Licence : LGPL-3.0-only | ||
| 5 | ****************************************/ | ||
| 6 | |||
| 7 | #ifndef __DATA_STREAM_SIZE_H__ | ||
| 8 | #define __DATA_STREAM_SIZE_H__ | ||
| 9 | |||
| 10 | #include "data_stream_include.h" | ||
| 11 | |||
| 12 | ///@brief How to get size of a pointer | ||
| 13 | template<typename T> | ||
| 14 | struct DataStream<size_t, DataStreamMode::WRITE, T* >{ | ||
| 15 | ///Get the size of a class T* | ||
| 16 | /** @param[out] ds : size of T* | ||
| 17 | * @param data : data to be used | ||
| 18 | * @return true on success, false otherwise | ||
| 19 | */ | ||
| 20 | 2 | static bool data_stream(size_t & ds, T* & data){ | |
| 21 | 2 | ds += sizeof(T*); | |
| 22 | 2 | return true; | |
| 23 | } | ||
| 24 | }; | ||
| 25 | |||
| 26 | ///@brief How to get size of a class | ||
| 27 | template<typename T> | ||
| 28 | struct DataStream<size_t, DataStreamMode::WRITE, std::vector<T> >{ | ||
| 29 | ///Get the size of a class std::vector T | ||
| 30 | /** @param[out] ds : size of the class std::vector T | ||
| 31 | * @param data : data to be used | ||
| 32 | * @return true on success, false otherwise | ||
| 33 | */ | ||
| 34 | 46 | static bool data_stream(size_t & ds, std::vector<T> & data){ | |
| 35 | 46 | ds += sizeof(size_t); | |
| 36 |
2/2✓ Branch 0 (16→3) taken 460 times.
✓ Branch 1 (16→17) taken 46 times.
|
1012 | for(typename std::vector<T>::iterator it(data.begin()); it != data.end(); ++it){ |
| 37 |
1/1✓ Branch 0 (5→6) taken 460 times.
|
460 | DataStream<size_t, DataStreamMode::WRITE, T>::data_stream(ds, *it); |
| 38 | } | ||
| 39 | 46 | return true; | |
| 40 | } | ||
| 41 | }; | ||
| 42 | |||
| 43 | ///@brief How to get size of a class | ||
| 44 | template<typename T> | ||
| 45 | struct DataStream<size_t, DataStreamMode::WRITE, std::list<T> >{ | ||
| 46 | ///Get the size of a class std::list T | ||
| 47 | /** @param[out] ds : size of the class std::list T | ||
| 48 | * @param data : data to be used | ||
| 49 | * @return true on success, false otherwise | ||
| 50 | */ | ||
| 51 | 46 | static bool data_stream(size_t & ds, std::list<T> & data){ | |
| 52 | 46 | ds += sizeof(size_t); | |
| 53 |
2/2✓ Branch 0 (8→3) taken 460 times.
✓ Branch 1 (8→9) taken 46 times.
|
506 | for(typename std::list<T>::iterator it(data.begin()); it != data.end(); ++it){ |
| 54 |
1/1✓ Branch 0 (4→5) taken 460 times.
|
460 | DataStream<size_t, DataStreamMode::WRITE, T>::data_stream(ds, *it); |
| 55 | } | ||
| 56 | 46 | return true; | |
| 57 | } | ||
| 58 | }; | ||
| 59 | |||
| 60 | ///@brief How to get size of a class | ||
| 61 | template<typename T, typename U> | ||
| 62 | struct DataStream<size_t, DataStreamMode::WRITE, std::map<T, U> >{ | ||
| 63 | ///Get the size of a class std::list T | ||
| 64 | /** @param[out] ds : size of the class std::map T U | ||
| 65 | * @param data : data to be used | ||
| 66 | * @return true on success, false otherwise | ||
| 67 | */ | ||
| 68 | 23 | static bool data_stream(size_t & ds, std::map<T, U> & data){ | |
| 69 | 23 | ds += sizeof(size_t); | |
| 70 |
2/2✓ Branch 0 (10→3) taken 230 times.
✓ Branch 1 (10→11) taken 23 times.
|
253 | for(typename std::map<T, U>::iterator it(data.begin()); it != data.end(); ++it){ |
| 71 |
1/1✓ Branch 0 (4→5) taken 230 times.
|
230 | DataStream<size_t, DataStreamMode::WRITE, T>::data_stream(ds, (T&)it->first); |
| 72 |
1/1✓ Branch 0 (6→7) taken 230 times.
|
230 | DataStream<size_t, DataStreamMode::WRITE, U>::data_stream(ds, it->second); |
| 73 | } | ||
| 74 | 23 | return true; | |
| 75 | } | ||
| 76 | }; | ||
| 77 | |||
| 78 | ///@brief How to get size of a class | ||
| 79 | template<typename T, typename U> | ||
| 80 | struct DataStream<size_t, DataStreamMode::WRITE, std::pair<T, U> >{ | ||
| 81 | ///Get the size of a class std::list T | ||
| 82 | /** @param[out] ds : size of the class std::map T U | ||
| 83 | * @param data : data to be used | ||
| 84 | * @return true on success, false otherwise | ||
| 85 | */ | ||
| 86 | 460 | static bool data_stream(size_t & ds, std::pair<T, U> & data){ | |
| 87 | 460 | DataStream<size_t, DataStreamMode::WRITE, T>::data_stream(ds, (T&)data.first); | |
| 88 | 460 | DataStream<size_t, DataStreamMode::WRITE, U>::data_stream(ds, data.second); | |
| 89 | 460 | return true; | |
| 90 | } | ||
| 91 | }; | ||
| 92 | |||
| 93 | ///@brief Specialisation to get the size of a bool | ||
| 94 | template<> | ||
| 95 | struct DataStream<size_t, DataStreamMode::WRITE, bool>{ | ||
| 96 | static bool data_stream(size_t & ds, bool & data); | ||
| 97 | static bool data_stream(size_t & ds, bool * data, size_t nbElement); | ||
| 98 | }; | ||
| 99 | |||
| 100 | ///@brief Specialisation to get the size of a std::string | ||
| 101 | template<> | ||
| 102 | struct DataStream<size_t, DataStreamMode::WRITE, std::string>{ | ||
| 103 | static bool data_stream(size_t & ds, std::string & data); | ||
| 104 | }; | ||
| 105 | |||
| 106 | #endif | ||
| 107 | |||
| 108 |