]> git.tdb.fi Git - libs/datafile.git/blobdiff - source/value.h
Cosmetic changes
[libs/datafile.git] / source / value.h
index 1b12db9a22db5f40e77578199bdfd7817fff4093..bcddd6ed3aebb579256cd0a11061a76312a4a95c 100644 (file)
@@ -1,17 +1,10 @@
-/* $Id$
-
-This file is part of libmspdatafile
-Copyright © 2006-2008, 2010  Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
 #ifndef MSP_DATAFILE_VALUE_H_
 #define MSP_DATAFILE_VALUE_H_
 
 #include <vector>
+#include <msp/core/attributes.h>
 #include <msp/core/meta.h>
 #include <msp/core/variant.h>
-#include "except.h"
 #include "type.h"
 
 namespace Msp {
@@ -25,15 +18,16 @@ private:
 
 public:
        template<typename T>
-       Value(T d):
+       Value(T &&d):
                sig(TypeInfo<T>::signature),
-               data(static_cast<typename TypeInfo<T>::Store>(d))
+               data(static_cast<typename TypeInfo<T>::Store>(std::forward<T>(d)))
        { }
 
-       Value(Symbol d): sig(TypeInfo<Symbol>::signature), data(d) { }
+       Value(const Symbol &d): sig(TypeInfo<Symbol>::signature), data(d) { }
+       Value(Symbol &&d): sig(TypeInfo<Symbol>::signature), data(std::move(d)) { }
 
        template<typename T>
-       typename RemoveReference<T>::Type get() const
+       typename TypeInfo<T>::Load get() const
        { return get_<typename TypeInfo<T>::Store>(); }
 
        char get_signature() const { return sig; }
@@ -42,14 +36,9 @@ private:
        T get_() const;
 };
 
-typedef std::vector<Value> ValueArray __attribute__((deprecated));
-
 template<typename T>
 inline T Value::get_() const
 {
-       if(sig!=TypeInfo<T>::signature)
-               throw TypeError("Type mismatch");
-
        return data.value<typename TypeInfo<T>::Store>();
 }
 
@@ -58,10 +47,8 @@ inline FloatType::Store Value::get_<FloatType::Store>() const
 {
        if(sig==IntType::signature)
                return data.value<IntType::Store>();
-       else if(sig!=FloatType::signature)
-               throw TypeError("Type mismatch");
-
-       return data.value<FloatType::Store>();
+       else
+               return data.value<FloatType::Store>();
 }
 
 } // namespace DataFile