MCPcopy Create free account
hub / github.com/arun11299/cpp-jwt / write_bson_unsigned

Method write_bson_unsigned

include/jwt/json/json.hpp:13744–13761  ·  view source on GitHub ↗

! @brief Writes a BSON element with key @a name and unsigned @a value */

Source from the content-addressed store, hash-verified

13742 @brief Writes a BSON element with key @a name and unsigned @a value
13743 */
13744 void write_bson_unsigned(const string_t& name,
13745 const std::uint64_t value)
13746 {
13747 if (value <= static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)()))
13748 {
13749 write_bson_entry_header(name, 0x10 /* int32 */);
13750 write_number<std::int32_t, true>(static_cast<std::int32_t>(value));
13751 }
13752 else if (value <= static_cast<std::uint64_t>((std::numeric_limits<std::int64_t>::max)()))
13753 {
13754 write_bson_entry_header(name, 0x12 /* int64 */);
13755 write_number<std::int64_t, true>(static_cast<std::int64_t>(value));
13756 }
13757 else
13758 {
13759 JSON_THROW(out_of_range::create(407, "integer number " + std::to_string(value) + " cannot be represented by BSON as it does not fit int64"));
13760 }
13761 }
13762
13763 /*!
13764 @brief Writes a BSON element with key @a name and object @a value

Callers

nothing calls this directly

Calls 1

createFunction · 0.85

Tested by

no test coverage detected