1 |
torben |
147 |
|
2 |
|
|
#include <string> |
3 |
|
|
#include <sstream> |
4 |
|
|
#include <stdlib.h> |
5 |
|
|
|
6 |
|
|
#include "Value.h" |
7 |
|
|
|
8 |
|
|
Value::Value(std::string const& value) |
9 |
|
|
{ |
10 |
|
|
value_=value; |
11 |
|
|
} |
12 |
|
|
|
13 |
|
|
#include <iostream> |
14 |
|
|
|
15 |
|
|
Value::Value(const char* c) |
16 |
|
|
{ |
17 |
|
|
value_=c; |
18 |
|
|
} |
19 |
|
|
|
20 |
|
|
Value::Value(double d) |
21 |
|
|
{ |
22 |
|
|
std::stringstream s; |
23 |
|
|
s<<d; |
24 |
|
|
value_=s.str(); |
25 |
|
|
} |
26 |
|
|
|
27 |
|
|
Value::Value(int d) |
28 |
|
|
{ |
29 |
|
|
std::stringstream s; |
30 |
|
|
s<<d; |
31 |
|
|
value_=s.str(); |
32 |
|
|
} |
33 |
|
|
|
34 |
|
|
|
35 |
|
|
Value::Value(Value const& other) |
36 |
|
|
{ |
37 |
|
|
value_=other.value_; |
38 |
|
|
} |
39 |
|
|
|
40 |
|
|
Value& Value::operator=(Value const& other) |
41 |
|
|
{ |
42 |
|
|
value_=other.value_; |
43 |
|
|
return *this; |
44 |
|
|
} |
45 |
|
|
|
46 |
|
|
Value& Value::operator=(double d) |
47 |
|
|
{ |
48 |
|
|
std::stringstream s; |
49 |
|
|
s << d; |
50 |
|
|
value_ = s.str(); |
51 |
|
|
return *this; |
52 |
|
|
} |
53 |
|
|
|
54 |
|
|
Value& Value::operator=(int i) |
55 |
|
|
{ |
56 |
|
|
std::stringstream s; |
57 |
|
|
s << i; |
58 |
|
|
value_ = s.str(); |
59 |
|
|
return *this; |
60 |
|
|
} |
61 |
|
|
|
62 |
|
|
Value& Value::operator=(std::string const& s) |
63 |
|
|
{ |
64 |
|
|
value_=s; |
65 |
|
|
return *this; |
66 |
|
|
} |
67 |
|
|
|
68 |
|
|
Value::operator std::string() const |
69 |
|
|
{ |
70 |
|
|
return value_; |
71 |
|
|
} |
72 |
|
|
|
73 |
|
|
Value::operator double() const |
74 |
|
|
{ |
75 |
|
|
return atof(value_.c_str()); |
76 |
|
|
} |
77 |
|
|
|
78 |
|
|
Value::operator int() const |
79 |
|
|
{ |
80 |
|
|
return atoi(value_.c_str()); |
81 |
|
|
} |