3 This file is part of libmspdatafile
4 Copyright © 2006-2008, 2010 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
8 #ifndef MSP_DATAFILE_VALUE_H_
9 #define MSP_DATAFILE_VALUE_H_
12 #include <msp/core/meta.h>
13 #include <msp/core/variant.h>
29 sig(TypeInfo<T>::signature),
30 data(static_cast<typename TypeInfo<T>::Store>(d))
33 Value(Symbol d): sig(TypeInfo<Symbol>::signature), data(d) { }
36 typename RemoveReference<T>::Type get() const
37 { return get_<typename TypeInfo<T>::Store>(); }
39 char get_signature() const { return sig; }
45 typedef std::vector<Value> ValueArray __attribute__((deprecated));
48 inline T Value::get_() const
50 if(sig!=TypeInfo<T>::signature)
51 throw TypeError("Type mismatch");
53 return data.value<typename TypeInfo<T>::Store>();
57 inline FloatType::Store Value::get_<FloatType::Store>() const
59 if(sig==IntType::signature)
60 return data.value<IntType::Store>();
61 else if(sig!=FloatType::signature)
62 throw TypeError("Type mismatch");
64 return data.value<FloatType::Store>();
67 } // namespace DataFile