1 #ifndef MSP_DATAFILE_TYPE_H_
2 #define MSP_DATAFILE_TYPE_H_
4 #include <msp/core/inttypes.h>
5 #include <msp/core/meta.h>
6 #include <msp/strings/lexicalcast.h>
18 Symbol(const T &n): name(lexical_cast<std::string>(n)) { }
20 template<typename T> operator T() const { return lexical_cast<T>(name); }
25 static const char signature = 'i';
32 static const char signature = 'f';
39 static const char signature = 'b';
46 static const char signature = 's';
47 typedef std::string Store;
53 // For backward compatibility
54 static const char signature = 'e';
58 const char valid_signatures[] =
63 StringType::signature,
64 SymbolType::signature,
68 struct CheckLoadType: Sfinae
71 static Yes f(typename T::LoadType *);
76 struct HasLoadType: Sfinae::Evaluate<CheckLoadType, T> { };
78 template<typename T, bool lt = HasLoadType<T>::value>
82 struct TypeInfo<short int, false>: IntType { };
85 struct TypeInfo<unsigned short int, false>: IntType { };
88 struct TypeInfo<int, false>: IntType { };
91 struct TypeInfo<unsigned int, false>: IntType { };
94 struct TypeInfo<long int, false>: IntType { };
97 struct TypeInfo<unsigned long int, false>: IntType { };
101 struct TypeInfo<__int64, false>: IntType { };
104 struct TypeInfo<unsigned __int64, false>: IntType { };
105 #elif defined(__GNUC__)
107 struct TypeInfo<long long int, false>: IntType { };
110 struct TypeInfo<unsigned long long int, false>: IntType { };
114 struct TypeInfo<float, false>: FloatType { };
117 struct TypeInfo<double, false>: FloatType { };
120 struct TypeInfo<bool, false>: BoolType { };
123 struct TypeInfo<std::string, false>: StringType { };
126 struct TypeInfo<char *, false>: StringType { };
129 struct TypeInfo<const char *, false>: StringType { };
132 struct TypeInfo<const T, false>: TypeInfo<T> { };
135 struct TypeInfo<T &, false>: TypeInfo<T> { };
138 struct TypeInfo<T, true>: TypeInfo<typename T::LoadType>
139 { typedef typename T::LoadType Load; };
142 struct TypeInfo<T, false>: SymbolType
145 } // namespace DataFile