]> git.tdb.fi Git - libs/datafile.git/blob - source/value.cpp
Add files
[libs/datafile.git] / source / value.cpp
1 /*
2 This file is part of libmspparser
3 Copyright © 2006 Mikko Rasa, Mikkosoft Productions
4 Distributed under the LGPL
5 */
6 #include <msp/error.h>
7 #include <msp/strconv.h>
8 #include "value.h"
9
10 namespace Msp {
11 namespace Parser {
12
13 /*template<>
14 unsigned Value::get<unsigned long>() const
15 {
16         if(type!=INTEGER)
17                 throw TypeError("Value is not an integer");
18         errno=0;
19         unsigned long result=strtoul(data);
20         if(errno==ERANGE
21         return result;
22 }
23
24 template<>
25 unsigned Value::get<unsigned>() const
26 {
27         if(type!=INTEGER)
28                 throw TypeError("Value is not an integer");
29         return strtoul(data);
30 }
31
32 template<>
33 unsigned Value::get<unsigned short>() const
34 {
35         if(type!=INTEGER)
36                 throw TypeError("Value is not an integer");
37         return strtoul(data);
38 }
39
40 template<>
41 float Value::get<float>() const
42 {
43         if(type!=FLOAT && type!=INTEGER)
44                 throw TypeError("Value is not a float");
45         return strtod(data);
46 }*/
47
48 template<>
49 std::string Value::get<std::string>() const
50 {
51         if(type!=STRING)
52                 throw TypeError("Value is not a string");
53         return data;
54 }
55
56 template<>
57 const std::string &Value::get<const std::string&>() const
58 {
59         if(type!=STRING)
60                 throw TypeError("Value is not a string");
61         return data;
62 }
63
64 } // namespace Msp
65 } // namespace Parser