From 94b0268cc2409c43f37da0fca960b207a1fe138f Mon Sep 17 00:00:00 2001 From: Qianqian Fang Date: Thu, 17 Feb 2022 00:21:34 -0500 Subject: [PATCH] partially fix VS compilation errors --- .../nlohmann/detail/input/binary_reader.hpp | 24 ++++----- .../nlohmann/detail/output/binary_writer.hpp | 26 +++++----- single_include/nlohmann/json.hpp | 50 +++++++++---------- 3 files changed, 50 insertions(+), 50 deletions(-) diff --git a/include/nlohmann/detail/input/binary_reader.hpp b/include/nlohmann/detail/input/binary_reader.hpp index 469379bc9..785eccb61 100644 --- a/include/nlohmann/detail/input/binary_reader.hpp +++ b/include/nlohmann/detail/input/binary_reader.hpp @@ -1891,17 +1891,17 @@ class binary_reader case 'u': { uint16_t len; - return get_number(format, len) and get_string(format, len, result); + return get_number(format, len) && get_string(format, len, result); } case 'm': { uint32_t len; - return get_number(format, len) and get_string(format, len, result); + return get_number(format, len) && get_string(format, len, result); } case 'M': { uint64_t len; - return get_number(format, len) and get_string(format, len, result); + return get_number(format, len) && get_string(format, len, result); } } } @@ -2256,17 +2256,17 @@ class binary_reader case 'u': { uint16_t number; - return get_number(format, number) and sax->number_integer(number); + return get_number(format, number) && sax->number_integer(number); } case 'm': { uint32_t number; - return get_number(format, number) and sax->number_integer(number); + return get_number(format, number) && sax->number_integer(number); } case 'M': { uint64_t number; - return get_number(format, number) and sax->number_integer(number); + return get_number(format, number) && sax->number_integer(number); } case 'h': { @@ -2294,8 +2294,8 @@ class binary_reader { const int exp = (half >> 10) & 0x1F; const int mant = half & 0x3FF; - JSON_ASSERT(0 <= exp and exp <= 32); - JSON_ASSERT(0 <= mant and mant <= 1024); + JSON_ASSERT(0 <= exp&& exp <= 32); + JSON_ASSERT(0 <= mant&& mant <= 1024); switch (exp) { case 0: @@ -2586,8 +2586,8 @@ class binary_reader } // reverse byte order prior to conversion if necessary - if ((is_little_endian != InputIsLittleEndian and format != input_format_t::bjdata) or - (is_little_endian == InputIsLittleEndian and format == input_format_t::bjdata)) + if ((is_little_endian != InputIsLittleEndian && format != input_format_t::bjdata) or + (is_little_endian == InputIsLittleEndian && format == input_format_t::bjdata)) { vec[sizeof(NumberType) - i - 1] = static_cast(current); } @@ -2700,13 +2700,13 @@ class binary_reader @param[in] context further context information @return a message string to use in the parse_error exceptions */ - std::string exception_message(const input_format_t format, + std::string exception_message(const input_format_t format_, const std::string& detail, const std::string& context) const { std::string error_msg = "syntax error while parsing "; - switch (format) + switch (format_) { case input_format_t::cbor: error_msg += "CBOR"; diff --git a/include/nlohmann/detail/output/binary_writer.hpp b/include/nlohmann/detail/output/binary_writer.hpp index c51e2b9ae..cb2d8b640 100644 --- a/include/nlohmann/detail/output/binary_writer.hpp +++ b/include/nlohmann/detail/output/binary_writer.hpp @@ -1335,7 +1335,7 @@ class binary_writer } write_number(static_cast(n)); } - else if (is_bjdata and n <= static_cast((std::numeric_limits::max)())) + else if (is_bjdata && n <= static_cast((std::numeric_limits::max)())) { if (add_prefix) { @@ -1351,7 +1351,7 @@ class binary_writer } write_number(static_cast(n)); } - else if (is_bjdata and n <= static_cast((std::numeric_limits::max)())) + else if (is_bjdata && n <= static_cast((std::numeric_limits::max)())) { if (add_prefix) { @@ -1367,7 +1367,7 @@ class binary_writer } write_number(static_cast(n)); } - else if (is_bjdata and n <= static_cast((std::numeric_limits::max)())) + else if (is_bjdata && n <= static_cast((std::numeric_limits::max)())) { if (add_prefix) { @@ -1422,7 +1422,7 @@ class binary_writer } write_number(static_cast(n)); } - else if (is_bjdata and (static_cast((std::numeric_limits::min)()) <= n && n <= static_cast((std::numeric_limits::max)()))) + else if (is_bjdata && (static_cast((std::numeric_limits::min)()) <= n && n <= static_cast((std::numeric_limits::max)()))) { if (add_prefix) { @@ -1438,7 +1438,7 @@ class binary_writer } write_number(static_cast(n)); } - else if (is_bjdata and (static_cast((std::numeric_limits::min)()) <= n && n <= static_cast((std::numeric_limits::max)()))) + else if (is_bjdata && (static_cast((std::numeric_limits::min)()) <= n && n <= static_cast((std::numeric_limits::max)()))) { if (add_prefix) { @@ -1454,7 +1454,7 @@ class binary_writer } write_number(static_cast(n)); } - else if (is_bjdata and (static_cast((std::numeric_limits::min)()) <= n && n <= static_cast((std::numeric_limits::max)()))) + else if (is_bjdata && (static_cast((std::numeric_limits::min)()) <= n && n <= static_cast((std::numeric_limits::max)()))) { if (add_prefix) { @@ -1507,7 +1507,7 @@ class binary_writer { return 'I'; } - if (is_bjdata and ((std::numeric_limits::min)() <= j.m_value.number_integer and j.m_value.number_integer <= (std::numeric_limits::max)())) + if (is_bjdata && ((std::numeric_limits::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits::max)())) { return 'u'; } @@ -1515,7 +1515,7 @@ class binary_writer { return 'l'; } - if (is_bjdata and ((std::numeric_limits::min)() <= j.m_value.number_integer and j.m_value.number_integer <= (std::numeric_limits::max)())) + if (is_bjdata && ((std::numeric_limits::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits::max)())) { return 'm'; } @@ -1523,7 +1523,7 @@ class binary_writer { return 'L'; } - if (is_bjdata and ((std::numeric_limits::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits::max)())) + if (is_bjdata && ((std::numeric_limits::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits::max)())) { return 'M'; } @@ -1545,7 +1545,7 @@ class binary_writer { return 'I'; } - if (is_bjdata and j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) + if (is_bjdata && j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) { return 'u'; } @@ -1553,7 +1553,7 @@ class binary_writer { return 'l'; } - if (is_bjdata and j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) + if (is_bjdata && j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) { return 'm'; } @@ -1561,7 +1561,7 @@ class binary_writer { return 'L'; } - if (is_bjdata and j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) + if (is_bjdata && j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) { return 'M'; } @@ -1622,7 +1622,7 @@ class binary_writer std::memcpy(vec.data(), &n, sizeof(NumberType)); // step 2: write array to output (with possible reordering) - if ((!is_bjdata and (is_little_endian != OutputIsLittleEndian)) or (is_bjdata and !is_little_endian)) + if ((!is_bjdata && (is_little_endian != OutputIsLittleEndian)) or (is_bjdata && !is_little_endian)) { // reverse byte order prior to conversion if necessary std::reverse(vec.begin(), vec.end()); diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 81fb82739..1385bf73a 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -10267,17 +10267,17 @@ class binary_reader case 'u': { uint16_t len; - return get_number(format, len) and get_string(format, len, result); + return get_number(format, len) && get_string(format, len, result); } case 'm': { uint32_t len; - return get_number(format, len) and get_string(format, len, result); + return get_number(format, len) && get_string(format, len, result); } case 'M': { uint64_t len; - return get_number(format, len) and get_string(format, len, result); + return get_number(format, len) && get_string(format, len, result); } } } @@ -10632,17 +10632,17 @@ class binary_reader case 'u': { uint16_t number; - return get_number(format, number) and sax->number_integer(number); + return get_number(format, number) && sax->number_integer(number); } case 'm': { uint32_t number; - return get_number(format, number) and sax->number_integer(number); + return get_number(format, number) && sax->number_integer(number); } case 'M': { uint64_t number; - return get_number(format, number) and sax->number_integer(number); + return get_number(format, number) && sax->number_integer(number); } case 'h': { @@ -10670,8 +10670,8 @@ class binary_reader { const int exp = (half >> 10) & 0x1F; const int mant = half & 0x3FF; - JSON_ASSERT(0 <= exp and exp <= 32); - JSON_ASSERT(0 <= mant and mant <= 1024); + JSON_ASSERT(0 <= exp&& exp <= 32); + JSON_ASSERT(0 <= mant&& mant <= 1024); switch (exp) { case 0: @@ -10962,8 +10962,8 @@ class binary_reader } // reverse byte order prior to conversion if necessary - if ((is_little_endian != InputIsLittleEndian and format != input_format_t::bjdata) or - (is_little_endian == InputIsLittleEndian and format == input_format_t::bjdata)) + if ((is_little_endian != InputIsLittleEndian && format != input_format_t::bjdata) or + (is_little_endian == InputIsLittleEndian && format == input_format_t::bjdata)) { vec[sizeof(NumberType) - i - 1] = static_cast(current); } @@ -11076,13 +11076,13 @@ class binary_reader @param[in] context further context information @return a message string to use in the parse_error exceptions */ - std::string exception_message(const input_format_t format, + std::string exception_message(const input_format_t format_, const std::string& detail, const std::string& context) const { std::string error_msg = "syntax error while parsing "; - switch (format) + switch (format_) { case input_format_t::cbor: error_msg += "CBOR"; @@ -15120,7 +15120,7 @@ class binary_writer } write_number(static_cast(n)); } - else if (is_bjdata and n <= static_cast((std::numeric_limits::max)())) + else if (is_bjdata && n <= static_cast((std::numeric_limits::max)())) { if (add_prefix) { @@ -15136,7 +15136,7 @@ class binary_writer } write_number(static_cast(n)); } - else if (is_bjdata and n <= static_cast((std::numeric_limits::max)())) + else if (is_bjdata && n <= static_cast((std::numeric_limits::max)())) { if (add_prefix) { @@ -15152,7 +15152,7 @@ class binary_writer } write_number(static_cast(n)); } - else if (is_bjdata and n <= static_cast((std::numeric_limits::max)())) + else if (is_bjdata && n <= static_cast((std::numeric_limits::max)())) { if (add_prefix) { @@ -15207,7 +15207,7 @@ class binary_writer } write_number(static_cast(n)); } - else if (is_bjdata and (static_cast((std::numeric_limits::min)()) <= n && n <= static_cast((std::numeric_limits::max)()))) + else if (is_bjdata && (static_cast((std::numeric_limits::min)()) <= n && n <= static_cast((std::numeric_limits::max)()))) { if (add_prefix) { @@ -15223,7 +15223,7 @@ class binary_writer } write_number(static_cast(n)); } - else if (is_bjdata and (static_cast((std::numeric_limits::min)()) <= n && n <= static_cast((std::numeric_limits::max)()))) + else if (is_bjdata && (static_cast((std::numeric_limits::min)()) <= n && n <= static_cast((std::numeric_limits::max)()))) { if (add_prefix) { @@ -15239,7 +15239,7 @@ class binary_writer } write_number(static_cast(n)); } - else if (is_bjdata and (static_cast((std::numeric_limits::min)()) <= n && n <= static_cast((std::numeric_limits::max)()))) + else if (is_bjdata && (static_cast((std::numeric_limits::min)()) <= n && n <= static_cast((std::numeric_limits::max)()))) { if (add_prefix) { @@ -15292,7 +15292,7 @@ class binary_writer { return 'I'; } - if (is_bjdata and ((std::numeric_limits::min)() <= j.m_value.number_integer and j.m_value.number_integer <= (std::numeric_limits::max)())) + if (is_bjdata && ((std::numeric_limits::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits::max)())) { return 'u'; } @@ -15300,7 +15300,7 @@ class binary_writer { return 'l'; } - if (is_bjdata and ((std::numeric_limits::min)() <= j.m_value.number_integer and j.m_value.number_integer <= (std::numeric_limits::max)())) + if (is_bjdata && ((std::numeric_limits::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits::max)())) { return 'm'; } @@ -15308,7 +15308,7 @@ class binary_writer { return 'L'; } - if (is_bjdata and ((std::numeric_limits::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits::max)())) + if (is_bjdata && ((std::numeric_limits::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits::max)())) { return 'M'; } @@ -15330,7 +15330,7 @@ class binary_writer { return 'I'; } - if (is_bjdata and j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) + if (is_bjdata && j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) { return 'u'; } @@ -15338,7 +15338,7 @@ class binary_writer { return 'l'; } - if (is_bjdata and j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) + if (is_bjdata && j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) { return 'm'; } @@ -15346,7 +15346,7 @@ class binary_writer { return 'L'; } - if (is_bjdata and j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) + if (is_bjdata && j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) { return 'M'; } @@ -15407,7 +15407,7 @@ class binary_writer std::memcpy(vec.data(), &n, sizeof(NumberType)); // step 2: write array to output (with possible reordering) - if ((!is_bjdata and (is_little_endian != OutputIsLittleEndian)) or (is_bjdata and !is_little_endian)) + if ((!is_bjdata && (is_little_endian != OutputIsLittleEndian)) or (is_bjdata && !is_little_endian)) { // reverse byte order prior to conversion if necessary std::reverse(vec.begin(), vec.end());