MCPcopy Create free account
hub / github.com/ArduPilot/ardupilot / to_str

Method to_str

libraries/AP_JSON/AP_JSON.cpp:364–387  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

362}
363
364std::string AP_JSON::value::to_str() const
365{
366 switch (type_) {
367 case null_type:
368 return "null";
369 case boolean_type:
370 return u_.boolean_ ? "true" : "false";
371 case number_type: {
372 char buf[256];
373 double tmp;
374 snprintf(buf, sizeof(buf), fabs(u_.number_) < (1ULL << 53) && is_zero(modf(u_.number_, &tmp)) ? "%.f" : "%.17g", u_.number_);
375 return buf;
376 }
377 case string_type:
378 return *u_.string_;
379 case array_type:
380 return "array";
381 case object_type:
382 return "object";
383 default:
384 break;
385 }
386 return std::string();
387}
388
389template <typename Iter> void copy(const std::string &s, Iter oi)
390{

Callers 3

load_dref_mapMethod · 0.80
parse_floatMethod · 0.80
parse_vector3Method · 0.80

Calls 2

stringClass · 0.85
is_zeroFunction · 0.50

Tested by

no test coverage detected