| 275 | } |
| 276 | |
| 277 | inline |
| 278 | long value::asLong() const |
| 279 | { |
| 280 | // Attempt to convert a string to a long |
| 281 | if (kind_ == Kind::String) { |
| 282 | const std::string& str = variant_.strValue; |
| 283 | std::size_t pos; |
| 284 | const long ret = stol(str, &pos); // Throws if it can't convert |
| 285 | if (pos != str.length()) { |
| 286 | // The string ended in non-digits. |
| 287 | throw std::runtime_error( str + " contains non-numeric characters."); |
| 288 | } |
| 289 | return ret; |
| 290 | } |
| 291 | throwIfNotKind(Kind::Long); |
| 292 | return variant_.longValue; |
| 293 | } |
| 294 | |
| 295 | inline |
| 296 | std::string const& value::asString() const |
no outgoing calls
no test coverage detected