MCPcopy Create free account
hub / github.com/bytedance/Fastbot_Android / get_number

Method get_number

native/thirdpart/json/json.hpp:6983–7009  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6981 */
6982 template<typename NumberType, bool InputIsLittleEndian = false>
6983 bool get_number(const input_format_t format, NumberType& result)
6984 {
6985 // step 1: read input into array with system's byte order
6986 std::array<std::uint8_t, sizeof(NumberType)> vec;
6987 for (std::size_t i = 0; i < sizeof(NumberType); ++i)
6988 {
6989 get();
6990 if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(format, "number")))
6991 {
6992 return false;
6993 }
6994
6995 // reverse byte order prior to conversion if necessary
6996 if (is_little_endian != InputIsLittleEndian)
6997 {
6998 vec[sizeof(NumberType) - i - 1] = static_cast<std::uint8_t>(current);
6999 }
7000 else
7001 {
7002 vec[i] = static_cast<std::uint8_t>(current); // LCOV_EXCL_LINE
7003 }
7004 }
7005
7006 // step 2: convert array into number of type T and return
7007 std::memcpy(&result, vec.data(), sizeof(NumberType));
7008 return true;
7009 }
7010
7011 /*!
7012 @brief create a string by reading characters from the input

Callers

nothing calls this directly

Calls 2

getFunction · 0.85
dataMethod · 0.45

Tested by

no test coverage detected