X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=inline;f=source%2Fvalue.cpp;fp=source%2Fvalue.cpp;h=8cb1af0bab89862c3999a60fbd65c375243627fb;hb=5453824394771ca21de32088a2842486b63e6f6d;hp=0000000000000000000000000000000000000000;hpb=7876adf8729437f1c917642c5dd5faf6f2e1fb31;p=libs%2Fdatafile.git diff --git a/source/value.cpp b/source/value.cpp new file mode 100644 index 0000000..8cb1af0 --- /dev/null +++ b/source/value.cpp @@ -0,0 +1,65 @@ +/* +This file is part of libmspparser +Copyright © 2006 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ +#include +#include +#include "value.h" + +namespace Msp { +namespace Parser { + +/*template<> +unsigned Value::get() const +{ + if(type!=INTEGER) + throw TypeError("Value is not an integer"); + errno=0; + unsigned long result=strtoul(data); + if(errno==ERANGE + return result; +} + +template<> +unsigned Value::get() const +{ + if(type!=INTEGER) + throw TypeError("Value is not an integer"); + return strtoul(data); +} + +template<> +unsigned Value::get() const +{ + if(type!=INTEGER) + throw TypeError("Value is not an integer"); + return strtoul(data); +} + +template<> +float Value::get() const +{ + if(type!=FLOAT && type!=INTEGER) + throw TypeError("Value is not a float"); + return strtod(data); +}*/ + +template<> +std::string Value::get() const +{ + if(type!=STRING) + throw TypeError("Value is not a string"); + return data; +} + +template<> +const std::string &Value::get() const +{ + if(type!=STRING) + throw TypeError("Value is not a string"); + return data; +} + +} // namespace Msp +} // namespace Parser