1 #ifndef MSP_DATAFILE_TYPE_H_
2 #define MSP_DATAFILE_TYPE_H_
4 #include <msp/core/inttypes.h>
5 #include <msp/strings/lexicalcast.h>
15 Symbol(const T &n): name(lexical_cast(n)) { }
17 template<typename T> operator T() const { return lexical_cast<T>(name); }
22 static const char signature = 'i';
29 static const char signature = 'f';
36 static const char signature = 'b';
43 static const char signature = 's';
44 typedef std::string Store;
50 // For backward compatibility
51 static const char signature = 'e';
58 struct Yes { char c[2]; };
59 struct No { char c; };
62 static Yes f(typename U::LoadType *);
66 enum { value = (sizeof(f<T>(0))==sizeof(Yes)) };
69 template<typename T, bool lt = HasLoadType<T>::value>
73 struct TypeInfo<short int, false>: IntType { };
76 struct TypeInfo<unsigned short int, false>: IntType { };
79 struct TypeInfo<int, false>: IntType { };
82 struct TypeInfo<unsigned int, false>: IntType { };
85 struct TypeInfo<long int, false>: IntType { };
88 struct TypeInfo<unsigned long int, false>: IntType { };
92 struct TypeInfo<__int64, false>: IntType { };
95 struct TypeInfo<unsigned __int64, false>: IntType { };
96 #elif defined(__GNUC__)
98 struct TypeInfo<long long int, false>: IntType { };
101 struct TypeInfo<unsigned long long int, false>: IntType { };
105 struct TypeInfo<float, false>: FloatType { };
108 struct TypeInfo<double, false>: FloatType { };
111 struct TypeInfo<bool, false>: BoolType { };
114 struct TypeInfo<std::string, false>: StringType { };
117 struct TypeInfo<const T, false>: TypeInfo<T> { };
120 struct TypeInfo<T &, false>: TypeInfo<T> { };
123 struct TypeInfo<T, true>: TypeInfo<typename T::LoadType>
124 { typedef typename T::LoadType Load; };
127 struct TypeInfo<T, false>: SymbolType
130 } // namespace DataFile