X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ftype.h;h=0e371e632a9bb4b66aee10520e5aab300726675e;hb=c80b23de8b70776e37f37e4b8fc2003c553448d6;hp=72d148a0e16631b2440747fd2c20a1556597b728;hpb=818ead7b6ccef1e4d2435cc959bc07f910fcde46;p=libs%2Fdatafile.git diff --git a/source/type.h b/source/type.h index 72d148a..0e371e6 100644 --- a/source/type.h +++ b/source/type.h @@ -1,6 +1,8 @@ #ifndef MSP_DATAFILE_TYPE_H_ #define MSP_DATAFILE_TYPE_H_ +#include +#include #include namespace Msp { @@ -10,8 +12,10 @@ struct Symbol { std::string name; + Symbol() = default; + template - Symbol(const T &n): name(lexical_cast(n)) { } + Symbol(const T &n): name(lexical_cast(n)) { } template operator T() const { return lexical_cast(name); } }; @@ -19,11 +23,7 @@ struct Symbol struct IntType { static const char signature = 'i'; -#ifdef MSVC - typedef __int64 Store; -#else - typedef long long int Store; -#endif + typedef std::int64_t Store; typedef Store Load; }; @@ -55,20 +55,26 @@ struct SymbolType typedef Symbol Store; }; -template -struct HasLoadType +const char valid_signatures[] = { - struct Yes { char c[2]; }; - struct No { char c; }; - - template - static Yes f(typename U::LoadType *); - template - static No f(...); + IntType::signature, + FloatType::signature, + BoolType::signature, + StringType::signature, + SymbolType::signature, + 0 +}; - enum { value = (sizeof(f(0))==sizeof(Yes)) }; +struct CheckLoadType: Sfinae +{ + template + static Yes f(typename T::LoadType *); + using Sfinae::f; }; +template +struct HasLoadType: Sfinae::Evaluate { }; + template::value> struct TypeInfo; @@ -90,19 +96,11 @@ struct TypeInfo: IntType { }; template<> struct TypeInfo: IntType { }; -#ifdef MSVC -template<> -struct TypeInfo<__int64, false>: IntType { }; - -template<> -struct TypeInfo: IntType { }; -#else template<> struct TypeInfo: IntType { }; template<> struct TypeInfo: IntType { }; -#endif template<> struct TypeInfo: FloatType { }; @@ -116,6 +114,12 @@ struct TypeInfo: BoolType { }; template<> struct TypeInfo: StringType { }; +template<> +struct TypeInfo: StringType { }; + +template<> +struct TypeInfo: StringType { }; + template struct TypeInfo: TypeInfo { };