]> git.tdb.fi Git - libs/datafile.git/blobdiff - source/value.h
Use lexical_cast instead of istringstream in Value::get
[libs/datafile.git] / source / value.h
index fda83e494db884a228036fafdf3f6ba5c3ec9439..ace18945cbc2ea39eb4bc395cc116c0016b8e7e0 100644 (file)
@@ -9,7 +9,7 @@ Distributed under the LGPL
 
 #include <vector>
 #include <msp/strings/lexicalcast.h>
-#include "error.h"
+#include "except.h"
 
 namespace Msp {
 namespace DataFile {
@@ -69,14 +69,7 @@ inline T Value::get() const
        if(!check_type<TypeResolver<T>::type>(type))
                throw TypeError("Type mismatch");
 
-       std::istringstream ss(data);
-       T result;
-       ss>>result;
-       if(ss.fail())
-               //XXX
-               throw Exception("Invalid value");
-
-       return result;
+       return lexical_cast<T>(data);
 }
 
 template<>