TerraForge3D  2.3.1
3D Terrain And Landscape Generator

◆ get_number()

template<typename BasicJsonType , typename InputAdapterType , typename SAX = json_sax_dom_parser<BasicJsonType>>
template<typename NumberType , bool InputIsLittleEndian = false>
bool nlohmann::detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::get_number ( const input_format_t  format,
NumberType &  result 
)
inlineprivate

Definition at line 10803 of file json.hpp.

10804 {
10805 // step 1: read input into array with system's byte order
10806 std::array<std::uint8_t, sizeof(NumberType)> vec{};
10807
10808 for (std::size_t i = 0; i < sizeof(NumberType); ++i)
10809 {
10810 get();
10811
10812 if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(format, "number")))
10813 {
10814 return false;
10815 }
10816
10817 // reverse byte order prior to conversion if necessary
10818 if (is_little_endian != InputIsLittleEndian)
10819 {
10820 vec[sizeof(NumberType) - i - 1] = static_cast<std::uint8_t>(current);
10821 }
10822
10823 else
10824 {
10825 vec[i] = static_cast<std::uint8_t>(current); // LCOV_EXCL_LINE
10826 }
10827 }
10828
10829 // step 2: convert array into number of type T and return
10830 std::memcpy(&result, vec.data(), sizeof(NumberType));
10831 return true;
10832 }
bool unexpect_eof(const input_format_t format, const char *context) const
Definition: json.hpp:10914
char_int_type current
the current character
Definition: json.hpp:10978
char_int_type get()
get next character from the input
Definition: json.hpp:10769
const bool is_little_endian
whether we can assume little endianess
Definition: json.hpp:10984