MCPcopy Create free account
hub / github.com/apache/thrift / writeJSONInteger

Method writeJSONInteger

lib/cpp/src/thrift/protocol/TJSONProtocol.cpp:507–524  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

505// if the context requires it (eg: key in a map pair).
506template <typename NumberType>
507uint32_t TJSONProtocol::writeJSONInteger(NumberType num) {
508 uint32_t result = context_->write(*trans_);
509 std::string val(to_string(num));
510 bool escapeNum = context_->escapeNum();
511 if (escapeNum) {
512 trans_->write(&kJSONStringDelimiter, 1);
513 result += 1;
514 }
515 if (val.length() > (std::numeric_limits<uint32_t>::max)())
516 throw TProtocolException(TProtocolException::SIZE_LIMIT);
517 trans_->write((const uint8_t*)val.c_str(), static_cast<uint32_t>(val.length()));
518 result += static_cast<uint32_t>(val.length());
519 if (escapeNum) {
520 trans_->write(&kJSONStringDelimiter, 1);
521 result += 1;
522 }
523 return result;
524}
525
526namespace {
527std::string doubleToString(double d) {

Callers

nothing calls this directly

Calls 5

TProtocolExceptionClass · 0.70
writeMethod · 0.65
lengthMethod · 0.65
to_stringFunction · 0.50
escapeNumMethod · 0.45

Tested by

no test coverage detected