GCC Code Coverage Report


Directory: ./
File: tmp_project/PhoenixTypeStream/src/phoenix_composeType.h
Date: 2025-03-14 12:18:05
Exec Total Coverage
Lines: 21 21 100.0%
Branches: 19 19 100.0%

Line Branch Exec Source
1 /***************************************
2 Auteur : Pierre Aubert
3 Mail : pierre.aubert@lapp.in2p3.fr
4 Licence : CeCILL-C
5 ****************************************/
6
7 #ifndef __PHOENIX_COMPOSETYPE_H__
8 #define __PHOENIX_COMPOSETYPE_H__
9
10 #include <string>
11 #include <vector>
12 #include <map>
13
14 #include "type_stream_get_type.h"
15
16 template <typename R, typename... T>
17 std::string phoenix_getTypeToStr(R (*func)(T...));
18
19 ///@brief Generic DataStream class
20 template<typename T>
21 struct TypeStream{
22 ///Convert the generic type into a string
23 /** @return corresponding string
24 */
25 103 static std::string getTypeToStr(){
26 103 return phoenix_getTypeName<T>();
27 }
28 };
29
30 ///@brief Generic std::vector type abstraction
31 template<typename T>
32 struct TypeStream<std::vector<T> >{
33 ///Convert the std::vector< T > type into a string
34 /** @return corresponding string
35 */
36 2 static std::string getTypeToStr(){
37
2/2
✓ Branch 2 taken 2 times.
✓ Branch 5 taken 2 times.
2 return "std::vector<" + TypeStream<T>::getTypeToStr() + " >";
38 }
39 };
40
41 ///@brief Generic std::list type abstraction
42 template<typename T>
43 struct TypeStream<std::list<T> >{
44 ///Convert the std::list< T > type into a string
45 /** @return corresponding string
46 */
47 2 static std::string getTypeToStr(){
48
2/2
✓ Branch 2 taken 2 times.
✓ Branch 5 taken 2 times.
2 return "std::list<" + TypeStream<T>::getTypeToStr() + " >";
49 }
50 };
51
52 ///@brief Generic std::map type abstraction
53 template<typename T, typename U>
54 struct TypeStream<std::map<T, U> >{
55 ///Convert the std::map< T > type into a string
56 /** @return corresponding string
57 */
58 2 static std::string getTypeToStr(){
59
5/5
✓ Branch 2 taken 2 times.
✓ Branch 5 taken 2 times.
✓ Branch 8 taken 2 times.
✓ Branch 11 taken 2 times.
✓ Branch 14 taken 2 times.
2 return "std::map<" + TypeStream<T>::getTypeToStr() + ", " + TypeStream<U>::getTypeToStr() + " >";
60 }
61 };
62
63 ///@brief Generic std::pair type abstraction
64 template<typename T, typename U>
65 struct TypeStream<std::pair<T, U> >{
66 ///Convert the std::pair< T, U > type into a string
67 /** @return corresponding string
68 */
69 2 static std::string getTypeToStr(){
70
5/5
✓ Branch 2 taken 2 times.
✓ Branch 5 taken 2 times.
✓ Branch 8 taken 2 times.
✓ Branch 11 taken 2 times.
✓ Branch 14 taken 2 times.
2 return "std::pair<" + TypeStream<T>::getTypeToStr() + ", " + TypeStream<U>::getTypeToStr() + " >";
71 }
72 };
73
74 template<typename T>
75 std::string phoenix_getTypeToStr();
76 template<typename T>
77 std::string phoenix_getTypeToStr(const T & data);
78
79 ///@brief Serialise a call type into a std::string
80 template <int First, int Last>
81 struct ConvertTupleTypeToString{
82 ///Create the corresponding string to a tuple
83 /** @param tupleCall : called tuple of function parameters
84 * @return corresponding string
85 */
86 template <typename T>
87 20 static std::string getTypeToStr(const T & tupleCall){
88 if(First < Last){
89 20 auto value = std::get<First>(tupleCall);
90
1/1
✓ Branch 1 taken 10 times.
20 std::string type = phoenix_getTypeToStr(value);
91 if(First + 1 < Last){
92
1/1
✓ Branch 1 taken 4 times.
8 type += ", ";
93 }
94
2/2
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
20 type += ConvertTupleTypeToString<First+1, Last>::getTypeToStr(tupleCall);
95 20 return type;
96 20 }
97 return "";
98 }
99 };
100
101 ///@brief Serialise a call type into a std::string
102 template <int N>
103 struct ConvertTupleTypeToString<N, N>{
104 ///End function which creates the corresponding vectortrue of PComposeType to a function call
105 /** @param[out] vecType : vector of PComposeType of the function call
106 * @param tupleCall : called tuple of function parameters
107 * @return true on success, false otherwise
108 */
109 template <typename T>
110
1/1
✓ Branch 2 taken 7 times.
14 static std::string getTypeToStr(const T & tupleCall){return "";}
111 };
112
113 ///@brief Generic std::tuple type abstraction
114 template<typename... T>
115 struct TypeStream<std::tuple<T... > >{
116 ///Convert the std::tuple< T > type into a string
117 /** @return corresponding string
118 */
119 7 static std::string getTypeToStr(){
120 6 std::tuple<T...> args = std::tuple<T...>();
121 7 return "std::tuple<" + ConvertTupleTypeToString<0, std::tuple_size<std::tuple<T... > >{} >::getTypeToStr(args) + " >";
122 }
123 };
124
125
126 #include "phoenix_composeType_impl.h"
127
128 #endif
129