* ✏️ fix typos

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* ✏️ address review comments

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* ✏️ address review comments

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

---------

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann
2025-05-04 10:28:24 +02:00
committed by GitHub
parent 0a8b48ac6a
commit 9110918cf8
42 changed files with 329 additions and 325 deletions
@@ -334,7 +334,7 @@ class binary_reader
return get_number<std::uint64_t, true>(input_format_t::bson, value) && sax->number_unsigned(value);
}
default: // anything else not supported (yet)
default: // anything else is not supported (yet)
{
std::array<char, 3> cr{{}};
static_cast<void>((std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast<unsigned char>(element_type))); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
@@ -731,7 +731,7 @@ class binary_reader
case 0xD2:
case 0xD3:
case 0xD4:
case 0xD8: // tagged item (1 bytes follow)
case 0xD8: // tagged item (1 byte follows)
case 0xD9: // tagged item (2 bytes follow)
case 0xDA: // tagged item (4 bytes follow)
case 0xDB: // tagged item (8 bytes follow)
@@ -783,7 +783,7 @@ class binary_reader
case cbor_tag_handler_t::store:
{
binary_t b;
// use binary subtype and store in binary container
// use binary subtype and store in a binary container
switch (current)
{
case 0xD8:
@@ -852,7 +852,7 @@ class binary_reader
const auto byte1 = static_cast<unsigned char>(byte1_raw);
const auto byte2 = static_cast<unsigned char>(byte2_raw);
// code from RFC 7049, Appendix D, Figure 3:
// Code from RFC 7049, Appendix D, Figure 3:
// As half-precision floating-point numbers were only added
// to IEEE 754 in 2008, today's programming platforms often
// still only have limited support for them. It is very
@@ -2159,7 +2159,7 @@ class binary_reader
{
break;
}
if (is_ndarray) // ndarray dimensional vector can only contain integers, and can not embed another array
if (is_ndarray) // ndarray dimensional vector can only contain integers and cannot embed another array
{
return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, exception_message(input_format, "ndarray dimensional vector is not allowed", "size"), nullptr));
}
@@ -2417,7 +2417,7 @@ class binary_reader
const auto byte1 = static_cast<unsigned char>(byte1_raw);
const auto byte2 = static_cast<unsigned char>(byte2_raw);
// code from RFC 7049, Appendix D, Figure 3:
// Code from RFC 7049, Appendix D, Figure 3:
// As half-precision floating-point numbers were only added
// to IEEE 754 in 2008, today's programming platforms often
// still only have limited support for them. It is very
@@ -2705,7 +2705,7 @@ class binary_reader
bool get_ubjson_high_precision_number()
{
// get size of following number string
// get the size of the following number string
std::size_t size{};
bool no_ndarray = true;
auto res = get_ubjson_size_value(size, no_ndarray);
@@ -2803,7 +2803,7 @@ class binary_reader
chars_read += new_chars_read;
if (JSON_HEDLEY_UNLIKELY(new_chars_read < sizeof(T)))
{
// in case of failure, advance position by 1 to report failing location
// in case of failure, advance position by 1 to report the failing location
++chars_read;
sax->parse_error(chars_read, "<end of file>", parse_error::create(110, chars_read, exception_message(format, "unexpected end of input", context), nullptr));
return false;
@@ -108,7 +108,7 @@ class input_stream_adapter
: is(&i), sb(i.rdbuf())
{}
// delete because of pointer members
// deleted because of pointer members
input_stream_adapter(const input_stream_adapter&) = delete;
input_stream_adapter& operator=(input_stream_adapter&) = delete;
input_stream_adapter& operator=(input_stream_adapter&&) = delete;
@@ -122,7 +122,7 @@ class input_stream_adapter
// std::istream/std::streambuf use std::char_traits<char>::to_int_type, to
// ensure that std::char_traits<char>::eof() and the character 0xFF do not
// end up as the same value, e.g. 0xFFFFFFFF.
// end up as the same value, e.g., 0xFFFFFFFF.
std::char_traits<char>::int_type get_character()
{
auto res = sb->sbumpc();
@@ -344,7 +344,7 @@ class wide_string_input_adapter
typename std::char_traits<char>::int_type get_character() noexcept
{
// check if buffer needs to be filled
// check if the buffer needs to be filled
if (utf8_bytes_index == utf8_bytes_filled)
{
fill_buffer<sizeof(WideCharType)>();
+3 -3
View File
@@ -260,7 +260,7 @@ class json_sax_dom_parser
JSON_ASSERT(!ref_stack.empty());
JSON_ASSERT(ref_stack.back()->is_object());
// add null at given key and store the reference for later
// add null at the given key and store the reference for later
object_element = &(ref_stack.back()->m_data.m_value.object->operator[](val));
return true;
}
@@ -576,11 +576,11 @@ class json_sax_dom_callback_parser
{
BasicJsonType k = BasicJsonType(val);
// check callback for key
// check callback for the key
const bool keep = callback(static_cast<int>(ref_stack.size()), parse_event_t::key, k);
key_keep_stack.push_back(keep);
// add discarded value at given key and store the reference for later
// add discarded value at the given key and store the reference for later
if (keep && ref_stack.back())
{
object_element = &(ref_stack.back()->m_data.m_value.object->operator[](val) = discarded);
+9 -9
View File
@@ -127,7 +127,7 @@ class lexer : public lexer_base<BasicJsonType>
, decimal_point_char(static_cast<char_int_type>(get_decimal_point()))
{}
// delete because of pointer members
// deleted because of pointer members
lexer(const lexer&) = delete;
lexer(lexer&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor)
lexer& operator=(lexer&) = delete;
@@ -262,10 +262,10 @@ class lexer : public lexer_base<BasicJsonType>
while (true)
{
// get next character
// get the next character
switch (get())
{
// end of file while parsing string
// end of file while parsing the string
case char_traits<char_type>::eof():
{
error_message = "invalid string: missing closing quote";
@@ -351,7 +351,7 @@ class lexer : public lexer_base<BasicJsonType>
(static_cast<unsigned int>(codepoint1) << 10u)
// low surrogate occupies the least significant 15 bits
+ static_cast<unsigned int>(codepoint2)
// there is still the 0xD800, 0xDC00 and 0x10000 noise
// there is still the 0xD800, 0xDC00, and 0x10000 noise
// in the result, so we have to subtract with:
// (0xD800 << 10) + DC00 - 0x10000 = 0x35FDC00
- 0x35FDC00u);
@@ -377,7 +377,7 @@ class lexer : public lexer_base<BasicJsonType>
}
}
// result of the above calculation yields a proper codepoint
// the result of the above calculation yields a proper codepoint
JSON_ASSERT(0x00 <= codepoint && codepoint <= 0x10FFFF);
// translate codepoint into bytes
@@ -828,7 +828,7 @@ class lexer : public lexer_base<BasicJsonType>
break;
}
// remaining bytes (80..C1 and F5..FF) are ill-formed
// the remaining bytes (80..C1 and F5..FF) are ill-formed
default:
{
error_message = "invalid string: ill-formed UTF-8 byte";
@@ -973,7 +973,7 @@ class lexer : public lexer_base<BasicJsonType>
reset();
// the type of the parsed number; initially set to unsigned; will be
// changed if minus sign, decimal point or exponent is read
// changed if minus sign, decimal point, or exponent is read
token_type number_type = token_type::value_unsigned;
// state (init): we just found out we need to scan a number
@@ -1345,7 +1345,7 @@ scan_number_done:
if (next_unget)
{
// just reset the next_unget variable and work with current
// only reset the next_unget variable and work with current
next_unget = false;
}
else
@@ -1524,7 +1524,7 @@ scan_number_done:
return token_type::parse_error;
}
// read next character and ignore whitespace
// read the next character and ignore whitespace
skip_whitespace();
// ignore comments
+3 -3
View File
@@ -106,7 +106,7 @@ class parser
exception_message(token_type::end_of_input, "value"), nullptr));
}
// in case of an error, return discarded value
// in case of an error, return a discarded value
if (sdp.is_errored())
{
result = value_t::discarded;
@@ -133,7 +133,7 @@ class parser
parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input, "value"), nullptr));
}
// in case of an error, return discarded value
// in case of an error, return a discarded value
if (sdp.is_errored())
{
result = value_t::discarded;
@@ -336,7 +336,7 @@ class parser
case token_type::parse_error:
{
// using "uninitialized" to avoid "expected" message
// using "uninitialized" to avoid an "expected" message
return sax->parse_error(m_lexer.get_position(),
m_lexer.get_token_string(),
parse_error::create(101, m_lexer.get_position(), exception_message(token_type::uninitialized, "value"), nullptr));