PhoenixTypeStream  0.1.0
Unified C++ type-to-string conversion framework
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
16template <typename R, typename... T>
17std::string phoenix_getTypeToStr(R (*func)(T...));
18
20template<typename T>
23
25 static std::string getTypeToStr(){
26 return phoenix_getTypeName<T>();
27 }
28};
29
31template<typename T>
32struct TypeStream<std::vector<T> >{
34
36 static std::string getTypeToStr(){
37 return "std::vector<" + TypeStream<T>::getTypeToStr() + " >";
38 }
39};
40
42template<typename T>
43struct TypeStream<std::list<T> >{
45
47 static std::string getTypeToStr(){
48 return "std::list<" + TypeStream<T>::getTypeToStr() + " >";
49 }
50};
51
53template<typename T, typename U>
54struct TypeStream<std::map<T, U> >{
56
58 static std::string getTypeToStr(){
59 return "std::map<" + TypeStream<T>::getTypeToStr() + ", " + TypeStream<U>::getTypeToStr() + " >";
60 }
61};
62
64template<typename T, typename U>
65struct TypeStream<std::pair<T, U> >{
67
69 static std::string getTypeToStr(){
70 return "std::pair<" + TypeStream<T>::getTypeToStr() + ", " + TypeStream<U>::getTypeToStr() + " >";
71 }
72};
73
74template<typename T>
75std::string phoenix_getTypeToStr();
76template<typename T>
77std::string phoenix_getTypeToStr(const T & data);
78
80template <int First, int Last>
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 }
95 return type;
96 }
97 return "";
98 }
99};
100
102template <int N>
105
109 template <typename T>
110 static std::string getTypeToStr(const T & tupleCall){return "";}
111};
112
114template<typename... T>
115struct 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
127
128#endif
std::string phoenix_getTypeToStr()
Get the corresponding type of a string.
static std::string getTypeToStr(const T &tupleCall)
End function which creates the corresponding vectortrue of PComposeType to a function call.
Serialise a call type into a std::string.
static std::string getTypeToStr(const T &tupleCall)
Create the corresponding string to a tuple.
static std::string getTypeToStr()
Convert the std::list< T > type into a string.
static std::string getTypeToStr()
Convert the std::map< T > type into a string.
static std::string getTypeToStr()
Convert the std::pair< T, U > type into a string.
static std::string getTypeToStr()
Convert the std::tuple< T > type into a string.
static std::string getTypeToStr()
Convert the std::vector< T > type into a string.
Generic DataStream class.
static std::string getTypeToStr()
Convert the generic type into a string.