⚗️ add Hedley annotations

This commit is contained in:
Niels Lohmann 2019-06-30 22:14:02 +02:00
parent 9a775bcb14
commit 1720bfedd1
No known key found for this signature in database
GPG key ID: 7F3CEA63AE251B69
19 changed files with 3689 additions and 642 deletions

View file

@ -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);