]> git.tdb.fi Git - libs/datafile.git/blobdiff - source/value.h
Switch template parameters of load_sub around to allow automatic deduction
[libs/datafile.git] / source / value.h
index be6a7a483f7768849f845051dbe563e9cea97ac9..f809c8fe4d3001cfba4660f45b9e9556a15d3ab8 100644 (file)
@@ -1,17 +1,19 @@
-/*
-This file is part of libmspparser
+/* $Id$
+
+This file is part of libmspdatafile
 Copyright © 2006  Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
-#ifndef MSP_PARSER_VALUE_H_
-#define MSP_PARSER_VALUE_H_
+#ifndef MSP_DATAFILE_VALUE_H_
+#define MSP_DATAFILE_VALUE_H_
 
 #include <sstream>
 #include <string>
 #include <vector>
+#include "error.h"
 
 namespace Msp {
-namespace Parser {
+namespace DataFile {
 
 class Value
 {
@@ -34,7 +36,7 @@ private:
 };
 typedef std::vector<Value> ValueArray;
 
-template<typename T> struct TypeResolver { };
+template<typename T> struct TypeResolver { static const Value::Type type=Value::ENUM; };
 
 template<> struct TypeResolver<short>          { static const Value::Type type=Value::INTEGER; };
 template<> struct TypeResolver<unsigned short> { static const Value::Type type=Value::INTEGER; };
@@ -64,7 +66,8 @@ inline T Value::get() const
        T result;
        ss>>result;
        if(ss.fail())
-               throw ValueError("Invalid value");
+               //XXX
+               throw Exception("Invalid value");
 
        return result;
 }
@@ -85,7 +88,7 @@ inline const std::string &Value::get<const std::string&>() const
        return data;
 }
 
-} // namespace Parser
+} // namespace DataFile
 } // namespace Msp
 
 #endif