mirror of
https://github.com/nlohmann/json.git
synced 2025-08-09 05:22:48 +03:00
🔨 add NLOHMANN_JSON prefix and undef macros
This commit is contained in:
@@ -59,7 +59,7 @@ class lexer
|
||||
};
|
||||
|
||||
/// return name of values of type token_type (only used for errors)
|
||||
HEDLEY_RETURNS_NON_NULL
|
||||
NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL
|
||||
static const char* token_type_name(const token_type t) noexcept
|
||||
{
|
||||
switch (t)
|
||||
@@ -201,7 +201,7 @@ class lexer
|
||||
for (auto range = ranges.begin(); range != ranges.end(); ++range)
|
||||
{
|
||||
get();
|
||||
if (HEDLEY_LIKELY(*range <= current and current <= *(++range)))
|
||||
if (NLOHMANN_JSON_HEDLEY_LIKELY(*range <= current and current <= *(++range)))
|
||||
{
|
||||
add(current);
|
||||
}
|
||||
@@ -300,7 +300,7 @@ class lexer
|
||||
const int codepoint1 = get_codepoint();
|
||||
int codepoint = codepoint1; // start with codepoint1
|
||||
|
||||
if (HEDLEY_UNLIKELY(codepoint1 == -1))
|
||||
if (NLOHMANN_JSON_HEDLEY_UNLIKELY(codepoint1 == -1))
|
||||
{
|
||||
error_message = "invalid string: '\\u' must be followed by 4 hex digits";
|
||||
return token_type::parse_error;
|
||||
@@ -310,18 +310,18 @@ class lexer
|
||||
if (0xD800 <= codepoint1 and codepoint1 <= 0xDBFF)
|
||||
{
|
||||
// expect next \uxxxx entry
|
||||
if (HEDLEY_LIKELY(get() == '\\' and get() == 'u'))
|
||||
if (NLOHMANN_JSON_HEDLEY_LIKELY(get() == '\\' and get() == 'u'))
|
||||
{
|
||||
const int codepoint2 = get_codepoint();
|
||||
|
||||
if (HEDLEY_UNLIKELY(codepoint2 == -1))
|
||||
if (NLOHMANN_JSON_HEDLEY_UNLIKELY(codepoint2 == -1))
|
||||
{
|
||||
error_message = "invalid string: '\\u' must be followed by 4 hex digits";
|
||||
return token_type::parse_error;
|
||||
}
|
||||
|
||||
// check if codepoint2 is a low surrogate
|
||||
if (HEDLEY_LIKELY(0xDC00 <= codepoint2 and codepoint2 <= 0xDFFF))
|
||||
if (NLOHMANN_JSON_HEDLEY_LIKELY(0xDC00 <= codepoint2 and codepoint2 <= 0xDFFF))
|
||||
{
|
||||
// overwrite codepoint
|
||||
codepoint = static_cast<int>(
|
||||
@@ -348,7 +348,7 @@ class lexer
|
||||
}
|
||||
else
|
||||
{
|
||||
if (HEDLEY_UNLIKELY(0xDC00 <= codepoint1 and codepoint1 <= 0xDFFF))
|
||||
if (NLOHMANN_JSON_HEDLEY_UNLIKELY(0xDC00 <= codepoint1 and codepoint1 <= 0xDFFF))
|
||||
{
|
||||
error_message = "invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF";
|
||||
return token_type::parse_error;
|
||||
@@ -723,7 +723,7 @@ class lexer
|
||||
case 0xDE:
|
||||
case 0xDF:
|
||||
{
|
||||
if (HEDLEY_UNLIKELY(not next_byte_in_range({0x80, 0xBF})))
|
||||
if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not next_byte_in_range({0x80, 0xBF})))
|
||||
{
|
||||
return token_type::parse_error;
|
||||
}
|
||||
@@ -733,7 +733,7 @@ class lexer
|
||||
// U+0800..U+0FFF: bytes E0 A0..BF 80..BF
|
||||
case 0xE0:
|
||||
{
|
||||
if (HEDLEY_UNLIKELY(not (next_byte_in_range({0xA0, 0xBF, 0x80, 0xBF}))))
|
||||
if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0xA0, 0xBF, 0x80, 0xBF}))))
|
||||
{
|
||||
return token_type::parse_error;
|
||||
}
|
||||
@@ -757,7 +757,7 @@ class lexer
|
||||
case 0xEE:
|
||||
case 0xEF:
|
||||
{
|
||||
if (HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0xBF, 0x80, 0xBF}))))
|
||||
if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0xBF, 0x80, 0xBF}))))
|
||||
{
|
||||
return token_type::parse_error;
|
||||
}
|
||||
@@ -767,7 +767,7 @@ class lexer
|
||||
// U+D000..U+D7FF: bytes ED 80..9F 80..BF
|
||||
case 0xED:
|
||||
{
|
||||
if (HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0x9F, 0x80, 0xBF}))))
|
||||
if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0x9F, 0x80, 0xBF}))))
|
||||
{
|
||||
return token_type::parse_error;
|
||||
}
|
||||
@@ -777,7 +777,7 @@ class lexer
|
||||
// U+10000..U+3FFFF F0 90..BF 80..BF 80..BF
|
||||
case 0xF0:
|
||||
{
|
||||
if (HEDLEY_UNLIKELY(not (next_byte_in_range({0x90, 0xBF, 0x80, 0xBF, 0x80, 0xBF}))))
|
||||
if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0x90, 0xBF, 0x80, 0xBF, 0x80, 0xBF}))))
|
||||
{
|
||||
return token_type::parse_error;
|
||||
}
|
||||
@@ -789,7 +789,7 @@ class lexer
|
||||
case 0xF2:
|
||||
case 0xF3:
|
||||
{
|
||||
if (HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0xBF, 0x80, 0xBF, 0x80, 0xBF}))))
|
||||
if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0xBF, 0x80, 0xBF, 0x80, 0xBF}))))
|
||||
{
|
||||
return token_type::parse_error;
|
||||
}
|
||||
@@ -799,7 +799,7 @@ class lexer
|
||||
// U+100000..U+10FFFF F4 80..8F 80..BF 80..BF
|
||||
case 0xF4:
|
||||
{
|
||||
if (HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0x8F, 0x80, 0xBF, 0x80, 0xBF}))))
|
||||
if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0x8F, 0x80, 0xBF, 0x80, 0xBF}))))
|
||||
{
|
||||
return token_type::parse_error;
|
||||
}
|
||||
@@ -816,19 +816,19 @@ class lexer
|
||||
}
|
||||
}
|
||||
|
||||
HEDLEY_NON_NULL(2)
|
||||
NLOHMANN_JSON_HEDLEY_NON_NULL(2)
|
||||
static void strtof(float& f, const char* str, char** endptr) noexcept
|
||||
{
|
||||
f = std::strtof(str, endptr);
|
||||
}
|
||||
|
||||
HEDLEY_NON_NULL(2)
|
||||
NLOHMANN_JSON_HEDLEY_NON_NULL(2)
|
||||
static void strtof(double& f, const char* str, char** endptr) noexcept
|
||||
{
|
||||
f = std::strtod(str, endptr);
|
||||
}
|
||||
|
||||
HEDLEY_NON_NULL(2)
|
||||
NLOHMANN_JSON_HEDLEY_NON_NULL(2)
|
||||
static void strtof(long double& f, const char* str, char** endptr) noexcept
|
||||
{
|
||||
f = std::strtold(str, endptr);
|
||||
@@ -1204,14 +1204,14 @@ scan_number_done:
|
||||
@param[in] length the length of the passed literal text
|
||||
@param[in] return_type the token type to return on success
|
||||
*/
|
||||
HEDLEY_NON_NULL(2)
|
||||
NLOHMANN_JSON_HEDLEY_NON_NULL(2)
|
||||
token_type scan_literal(const char* literal_text, const std::size_t length,
|
||||
token_type return_type)
|
||||
{
|
||||
assert(current == literal_text[0]);
|
||||
for (std::size_t i = 1; i < length; ++i)
|
||||
{
|
||||
if (HEDLEY_UNLIKELY(get() != literal_text[i]))
|
||||
if (NLOHMANN_JSON_HEDLEY_UNLIKELY(get() != literal_text[i]))
|
||||
{
|
||||
error_message = "invalid literal";
|
||||
return token_type::parse_error;
|
||||
@@ -1257,7 +1257,7 @@ scan_number_done:
|
||||
current = ia->get_character();
|
||||
}
|
||||
|
||||
if (HEDLEY_LIKELY(current != std::char_traits<char>::eof()))
|
||||
if (NLOHMANN_JSON_HEDLEY_LIKELY(current != std::char_traits<char>::eof()))
|
||||
{
|
||||
token_string.push_back(std::char_traits<char>::to_char_type(current));
|
||||
}
|
||||
@@ -1298,7 +1298,7 @@ scan_number_done:
|
||||
--position.chars_read_current_line;
|
||||
}
|
||||
|
||||
if (HEDLEY_LIKELY(current != std::char_traits<char>::eof()))
|
||||
if (NLOHMANN_JSON_HEDLEY_LIKELY(current != std::char_traits<char>::eof()))
|
||||
{
|
||||
assert(not token_string.empty());
|
||||
token_string.pop_back();
|
||||
@@ -1377,7 +1377,7 @@ scan_number_done:
|
||||
}
|
||||
|
||||
/// return syntax error message
|
||||
HEDLEY_RETURNS_NON_NULL
|
||||
NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL
|
||||
constexpr const char* get_error_message() const noexcept
|
||||
{
|
||||
return error_message;
|
||||
|
Reference in New Issue
Block a user