diff options
Diffstat (limited to 'lib/data.cpp')
| -rw-r--r-- | lib/data.cpp | 117 |
1 files changed, 117 insertions, 0 deletions
| diff --git a/lib/data.cpp b/lib/data.cpp index 5a9397b..c14956f 100644 --- a/lib/data.cpp +++ b/lib/data.cpp | |||
| @@ -57,4 +57,121 @@ namespace verbly { | |||
| 57 | return preposition_query(*this); | 57 | return preposition_query(*this); |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | binding::type binding::get_type() const | ||
| 61 | { | ||
| 62 | return _type; | ||
| 63 | } | ||
| 64 | |||
| 65 | binding::binding(const binding& other) | ||
| 66 | { | ||
| 67 | _type = other._type; | ||
| 68 | |||
| 69 | switch (_type) | ||
| 70 | { | ||
| 71 | case type::integer: | ||
| 72 | { | ||
| 73 | _integer = other._integer; | ||
| 74 | |||
| 75 | break; | ||
| 76 | } | ||
| 77 | |||
| 78 | case type::string: | ||
| 79 | { | ||
| 80 | new(&_string) std::string(other._string); | ||
| 81 | |||
| 82 | break; | ||
| 83 | } | ||
| 84 | } | ||
| 85 | } | ||
| 86 | |||
| 87 | binding::~binding() | ||
| 88 | { | ||
| 89 | switch (_type) | ||
| 90 | { | ||
| 91 | case type::string: | ||
| 92 | { | ||
| 93 | using string_type = std::string; | ||
| 94 | _string.~string_type(); | ||
| 95 | |||
| 96 | break; | ||
| 97 | } | ||
| 98 | } | ||
| 99 | } | ||
| 100 | |||
| 101 | binding& binding::operator=(const binding& other) | ||
| 102 | { | ||
| 103 | this->~binding(); | ||
| 104 | |||
| 105 | _type = other._type; | ||
| 106 | |||
| 107 | switch (_type) | ||
| 108 | { | ||
| 109 | case type::integer: | ||
| 110 | { | ||
| 111 | _integer = other._integer; | ||
| 112 | |||
| 113 | break; | ||
| 114 | } | ||
| 115 | |||
| 116 | case type::string: | ||
| 117 | { | ||
| 118 | new(&_string) std::string(other._string); | ||
| 119 | |||
| 120 | break; | ||
| 121 | } | ||
| 122 | } | ||
| 123 | |||
| 124 | return *this; | ||
| 125 | } | ||
| 126 | |||
| 127 | binding::binding(int _arg) | ||
| 128 | { | ||
| 129 | _type = type::integer; | ||
| 130 | _integer = _arg; | ||
| 131 | } | ||
| 132 | |||
| 133 | int binding::get_integer() const | ||
| 134 | { | ||
| 135 | assert(_type == type::integer); | ||
| 136 | |||
| 137 | return _integer; | ||
| 138 | } | ||
| 139 | |||
| 140 | void binding::set_integer(int _arg) | ||
| 141 | { | ||
| 142 | *this = binding(_arg); | ||
| 143 | } | ||
| 144 | |||
| 145 | binding& binding::operator=(int _arg) | ||
| 146 | { | ||
| 147 | *this = binding(_arg); | ||
| 148 | |||
| 149 | return *this; | ||
| 150 | } | ||
| 151 | |||
| 152 | binding::binding(std::string _arg) | ||
| 153 | { | ||
| 154 | _type = type::string; | ||
| 155 | new(&_string) std::string(_arg); | ||
| 156 | } | ||
| 157 | |||
| 158 | std::string binding::get_string() const | ||
| 159 | { | ||
| 160 | assert(_type == type::string); | ||
| 161 | |||
| 162 | return _string; | ||
| 163 | } | ||
| 164 | |||
| 165 | void binding::set_string(std::string _arg) | ||
| 166 | { | ||
| 167 | *this = binding(_arg); | ||
| 168 | } | ||
| 169 | |||
| 170 | binding& binding::operator=(std::string _arg) | ||
| 171 | { | ||
| 172 | *this = binding(_arg); | ||
| 173 | |||
| 174 | return *this; | ||
| 175 | } | ||
| 176 | |||
| 60 | }; | 177 | }; |
