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