PhoenixTypeStream
1.4.0
Unified C++ type-to-string conversion framework
Toggle main menu visibility
Loading...
Searching...
No Matches
phoenix_composeType.h
Go to the documentation of this file.
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
20
template
<
typename
T>
21
struct
TypeStream
{
23
25
static
std::string
getTypeToStr
(){
26
return
phoenix_getTypeName<T>();
27
}
28
};
29
31
template
<
typename
T>
32
struct
TypeStream
<std::vector<T> >{
34
36
static
std::string
getTypeToStr
(){
37
return
"std::vector<"
+
TypeStream<T>::getTypeToStr
() +
" >"
;
38
}
39
};
40
42
template
<
typename
T>
43
struct
TypeStream
<std::list<T> >{
45
47
static
std::string
getTypeToStr
(){
48
return
"std::list<"
+
TypeStream<T>::getTypeToStr
() +
" >"
;
49
}
50
};
51
53
template
<
typename
T,
typename
U>
54
struct
TypeStream
<std::map<T, U> >{
56
58
static
std::string
getTypeToStr
(){
59
return
"std::map<"
+
TypeStream<T>::getTypeToStr
() +
", "
+
TypeStream<U>::getTypeToStr
() +
" >"
;
60
}
61
};
62
64
template
<
typename
T,
typename
U>
65
struct
TypeStream
<std::pair<T, U> >{
67
69
static
std::string
getTypeToStr
(){
70
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
80
template
<
int
First,
int
Last>
81
struct
ConvertTupleTypeToString
{
83
86
template
<
typename
T>
87
static
std::string
getTypeToStr
(
const
T & tupleCall){
88
if
(First < Last){
89
auto
value = std::get<First>(tupleCall);
90
std::string type =
phoenix_getTypeToStr
(value);
91
if
(First + 1 < Last){
92
type +=
", "
;
93
}
94
type +=
ConvertTupleTypeToString<First+1, Last>::getTypeToStr
(tupleCall);
95
return
type;
96
}
97
return
""
;
98
}
99
};
100
102
template
<
int
N>
103
struct
ConvertTupleTypeToString
<N, N>{
105
109
template
<
typename
T>
110
static
std::string
getTypeToStr
(
const
T & tupleCall){
return
""
;}
111
};
112
114
template
<
typename
... T>
115
struct
TypeStream
<std::tuple<T... > >{
117
119
static
std::string
getTypeToStr
(){
120
std::tuple<T...> args = std::tuple<T...>();
121
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
phoenix_getTypeToStr
std::string phoenix_getTypeToStr()
Get the corresponding type of a string.
Definition
phoenix_composeType_impl.h:16
phoenix_composeType_impl.h
ConvertTupleTypeToString< N, N >::getTypeToStr
static std::string getTypeToStr(const T &tupleCall)
End function which creates the corresponding vectortrue of PComposeType to a function call.
Definition
phoenix_composeType.h:110
ConvertTupleTypeToString
Serialise a call type into a std::string.
Definition
phoenix_composeType.h:81
ConvertTupleTypeToString::getTypeToStr
static std::string getTypeToStr(const T &tupleCall)
Create the corresponding string to a tuple.
Definition
phoenix_composeType.h:87
TypeStream< std::list< T > >::getTypeToStr
static std::string getTypeToStr()
Convert the std::list< T > type into a string.
Definition
phoenix_composeType.h:47
TypeStream< std::map< T, U > >::getTypeToStr
static std::string getTypeToStr()
Convert the std::map< T > type into a string.
Definition
phoenix_composeType.h:58
TypeStream< std::pair< T, U > >::getTypeToStr
static std::string getTypeToStr()
Convert the std::pair< T, U > type into a string.
Definition
phoenix_composeType.h:69
TypeStream< std::tuple< T... > >::getTypeToStr
static std::string getTypeToStr()
Convert the std::tuple< T > type into a string.
Definition
phoenix_composeType.h:119
TypeStream< std::vector< T > >::getTypeToStr
static std::string getTypeToStr()
Convert the std::vector< T > type into a string.
Definition
phoenix_composeType.h:36
TypeStream
Generic DataStream class.
Definition
phoenix_composeType.h:21
TypeStream::getTypeToStr
static std::string getTypeToStr()
Convert the generic type into a string.
Definition
phoenix_composeType.h:25
src
phoenix_composeType.h
Generated by
1.17.0