mirror of
https://github.com/nlohmann/json.git
synced 2026-08-30 04:57:13 +00:00
⚗️ add Hedley annotations
This commit is contained in:
@@ -55,6 +55,7 @@ Input adapter for stdio file access. This adapter read only 1 byte and do not us
|
||||
class file_input_adapter : public input_adapter_protocol
|
||||
{
|
||||
public:
|
||||
HEDLEY_NON_NULL(2)
|
||||
explicit file_input_adapter(std::FILE* f) noexcept
|
||||
: m_file(f)
|
||||
{}
|
||||
@@ -130,6 +131,7 @@ class input_stream_adapter : public input_adapter_protocol
|
||||
class input_buffer_adapter : public input_adapter_protocol
|
||||
{
|
||||
public:
|
||||
HEDLEY_NON_NULL(2)
|
||||
input_buffer_adapter(const char* b, const std::size_t l) noexcept
|
||||
: cursor(b), limit(b + l)
|
||||
{}
|
||||
@@ -143,7 +145,7 @@ class input_buffer_adapter : public input_adapter_protocol
|
||||
|
||||
std::char_traits<char>::int_type get_character() noexcept override
|
||||
{
|
||||
if (JSON_LIKELY(cursor < limit))
|
||||
if (HEDLEY_LIKELY(cursor < limit))
|
||||
{
|
||||
return std::char_traits<char>::to_int_type(*(cursor++));
|
||||
}
|
||||
@@ -333,6 +335,7 @@ class input_adapter
|
||||
{
|
||||
public:
|
||||
// native support
|
||||
HEDLEY_NON_NULL(2)
|
||||
input_adapter(std::FILE* file)
|
||||
: ia(std::make_shared<file_input_adapter>(file)) {}
|
||||
/// input adapter for input stream
|
||||
@@ -401,7 +404,7 @@ class input_adapter
|
||||
"each element in the iterator range must have the size of 1 byte");
|
||||
|
||||
const auto len = static_cast<size_t>(std::distance(first, last));
|
||||
if (JSON_LIKELY(len > 0))
|
||||
if (HEDLEY_LIKELY(len > 0))
|
||||
{
|
||||
// there is at least one element: use the address of first
|
||||
ia = std::make_shared<input_buffer_adapter>(reinterpret_cast<const char*>(&(*first)), len);
|
||||
|
||||
Reference in New Issue
Block a user