X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ftype.h;h=fdd040d81adccd82b53b9e9509b48b4348b70ed8;hb=08ca2d33416e549bd3d071a164ed2a98765dda4b;hp=701a5dc9786533f930e6c49778988f6816f83189;hpb=10c7c4157f02e3abbb7a0505bfc2985b67e04043;p=libs%2Fdatafile.git diff --git a/source/type.h b/source/type.h index 701a5dc..fdd040d 100644 --- a/source/type.h +++ b/source/type.h @@ -2,6 +2,7 @@ #define MSP_DATAFILE_TYPE_H_ #include +#include #include namespace Msp { @@ -11,8 +12,10 @@ struct Symbol { std::string name; + Symbol() { } + 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); } }; @@ -52,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; @@ -113,6 +122,12 @@ struct TypeInfo: BoolType { }; template<> struct TypeInfo: StringType { }; +template<> +struct TypeInfo: StringType { }; + +template<> +struct TypeInfo: StringType { }; + template struct TypeInfo: TypeInfo { };