TerraForge3D  2.3.1
3D Terrain And Landscape Generator

◆ write_number_with_ubjson_prefix() [3/3]

template<typename BasicJsonType , typename CharType >
template<typename NumberType , typename std::enable_if< std::is_signed< NumberType >::value &&!std::is_floating_point< NumberType >::value, int >::type = 0>
void nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_number_with_ubjson_prefix ( const NumberType  n,
const bool  add_prefix 
)
inlineprivate

Definition at line 15234 of file json.hpp.

15236 {
15237 if ((std::numeric_limits<std::int8_t>::min)() <= n && n <= (std::numeric_limits<std::int8_t>::max)())
15238 {
15239 if (add_prefix)
15240 {
15241 oa->write_character(to_char_type('i')); // int8
15242 }
15243
15244 write_number(static_cast<std::int8_t>(n));
15245 }
15246
15247 else if (static_cast<std::int64_t>((std::numeric_limits<std::uint8_t>::min)()) <= n && n <= static_cast<std::int64_t>((std::numeric_limits<std::uint8_t>::max)()))
15248 {
15249 if (add_prefix)
15250 {
15251 oa->write_character(to_char_type('U')); // uint8
15252 }
15253
15254 write_number(static_cast<std::uint8_t>(n));
15255 }
15256
15257 else if ((std::numeric_limits<std::int16_t>::min)() <= n && n <= (std::numeric_limits<std::int16_t>::max)())
15258 {
15259 if (add_prefix)
15260 {
15261 oa->write_character(to_char_type('I')); // int16
15262 }
15263
15264 write_number(static_cast<std::int16_t>(n));
15265 }
15266
15267 else if ((std::numeric_limits<std::int32_t>::min)() <= n && n <= (std::numeric_limits<std::int32_t>::max)())
15268 {
15269 if (add_prefix)
15270 {
15271 oa->write_character(to_char_type('l')); // int32
15272 }
15273
15274 write_number(static_cast<std::int32_t>(n));
15275 }
15276
15277 else if ((std::numeric_limits<std::int64_t>::min)() <= n && n <= (std::numeric_limits<std::int64_t>::max)())
15278 {
15279 if (add_prefix)
15280 {
15281 oa->write_character(to_char_type('L')); // int64
15282 }
15283
15284 write_number(static_cast<std::int64_t>(n));
15285 }
15286
15287 // LCOV_EXCL_START
15288 else
15289 {
15290 if (add_prefix)
15291 {
15292 oa->write_character(to_char_type('H')); // high-precision number
15293 }
15294
15295 const auto number = BasicJsonType(n).dump();
15296 write_number_with_ubjson_prefix(number.size(), true);
15297
15298 for (std::size_t i = 0; i < number.size(); ++i)
15299 {
15300 oa->write_character(to_char_type(static_cast<std::uint8_t>(number[i])));
15301 }
15302 }
15303
15304 // LCOV_EXCL_STOP
15305 }
output_adapter_t< CharType > oa
the output
Definition: json.hpp:15519