X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ftype.h;fp=source%2Ftype.h;h=5a87a10222a84794341d9a167c94786ae022927f;hb=a582163d380833b1370ba067a1fd0ad5c2984723;hp=0000000000000000000000000000000000000000;hpb=cbd0ddd6ee033e46646bfb85d19232c816ea1eda;p=libs%2Fdatafile.git diff --git a/source/type.h b/source/type.h new file mode 100644 index 0000000..5a87a10 --- /dev/null +++ b/source/type.h @@ -0,0 +1,104 @@ +/* $Id$ + +This file is part of libmspdatafile +Copyright © 2010 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + +#ifndef MSP_DATAFILE_TYPE_H_ +#define MSP_DATAFILE_TYPE_H_ + +#include + +namespace Msp { +namespace DataFile { + +struct Symbol +{ + std::string name; + + Symbol(const std::string &n): name(n) { } + + template operator T() const { return lexical_cast(name); } +}; + +struct IntType +{ + static const char signature = 'i'; + typedef long long int Store; +}; + +struct FloatType +{ + static const char signature = 'f'; + typedef double Store; +}; + +struct BoolType +{ + static const char signature = 'b'; + typedef bool Store; +}; + +struct StringType +{ + static const char signature = 's'; + typedef std::string Store; +}; + +struct SymbolType +{ + // For backward compatibility + static const char signature = 'e'; + typedef Symbol Store; +}; + +template +struct TypeInfo: SymbolType { }; + +template<> +struct TypeInfo: IntType { }; + +template<> +struct TypeInfo: IntType { }; + +template<> +struct TypeInfo: IntType { }; + +template<> +struct TypeInfo: IntType { }; + +template<> +struct TypeInfo: IntType { }; + +template<> +struct TypeInfo: IntType { }; + +template<> +struct TypeInfo: IntType { }; + +template<> +struct TypeInfo: IntType { }; + +template<> +struct TypeInfo: FloatType { }; + +template<> +struct TypeInfo: FloatType { }; + +template<> +struct TypeInfo: BoolType { }; + +template<> +struct TypeInfo: StringType { }; + +template +struct TypeInfo: TypeInfo { }; + +template +struct TypeInfo: TypeInfo { }; + +} // namespace DataFile +} // namespace Msp + +#endif