| 505 | // if the context requires it (eg: key in a map pair). |
| 506 | template <typename NumberType> |
| 507 | uint32_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 | |
| 526 | namespace { |
| 527 | std::string doubleToString(double d) { |
nothing calls this directly
no test coverage detected