]> git.tdb.fi Git - libs/datafile.git/blobdiff - source/type.h
Remove the loaded flag from PackSource files
[libs/datafile.git] / source / type.h
index 72d148a0e16631b2440747fd2c20a1556597b728..f40657eb14a07003a295cb979ae4813523183d17 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef MSP_DATAFILE_TYPE_H_
 #define MSP_DATAFILE_TYPE_H_
 
+#include <msp/core/inttypes.h>
 #include <msp/strings/lexicalcast.h>
 
 namespace Msp {
@@ -10,8 +11,10 @@ struct Symbol
 {
        std::string name;
 
+       Symbol() { }
+
        template<typename T>
-       Symbol(const T &n): name(lexical_cast(n)) { }
+       Symbol(const T &n): name(lexical_cast<std::string>(n)) { }
 
        template<typename T> operator T() const { return lexical_cast<T>(name); }
 };
@@ -19,11 +22,7 @@ struct Symbol
 struct IntType
 {
        static const char signature = 'i';
-#ifdef MSVC
-       typedef __int64 Store;
-#else
-       typedef long long int Store;
-#endif
+       typedef Int64 Store;
        typedef Store Load;
 };
 
@@ -55,6 +54,16 @@ struct SymbolType
        typedef Symbol Store;
 };
 
+const char valid_signatures[] =
+{
+       IntType::signature,
+       FloatType::signature,
+       BoolType::signature,
+       StringType::signature,
+       SymbolType::signature,
+       0
+};
+
 template<typename T>
 struct HasLoadType
 {
@@ -90,13 +99,13 @@ struct TypeInfo<long int, false>: IntType { };
 template<>
 struct TypeInfo<unsigned long int, false>: IntType { };
 
-#ifdef MSVC
+#if defined(_MSC_VER)
 template<>
 struct TypeInfo<__int64, false>: IntType { };
 
 template<>
 struct TypeInfo<unsigned __int64, false>: IntType { };
-#else
+#elif defined(__GNUC__)
 template<>
 struct TypeInfo<long long int, false>: IntType { };
 
@@ -116,6 +125,12 @@ struct TypeInfo<bool, false>: BoolType { };
 template<>
 struct TypeInfo<std::string, false>: StringType { };
 
+template<>
+struct TypeInfo<char *, false>: StringType { };
+
+template<>
+struct TypeInfo<const char *, false>: StringType { };
+
 template<typename T>
 struct TypeInfo<const T, false>: TypeInfo<T> { };