MCPcopy Create free account
hub / github.com/docopt/docopt.cpp / asLong

Method asLong

docopt_value.h:277–293  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 2

docopt.cppFile · 0.80
matchMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected