mirror of
https://github.com/nlohmann/json.git
synced 2025-07-28 12:02:00 +03:00
misc formatting fixes
This commit is contained in:
@ -4526,7 +4526,7 @@ class input_stream_adapter
|
||||
{
|
||||
auto res = sb->sbumpc();
|
||||
// set eof manually, as we don't use the istream interface.
|
||||
if (res == EOF)
|
||||
if (JSON_HEDLEY_UNLIKELY(res == EOF))
|
||||
{
|
||||
is->clear(is->rdstate() | std::ios::eofbit);
|
||||
}
|
||||
@ -4552,7 +4552,7 @@ class iterator_input_adapter
|
||||
|
||||
typename std::char_traits<char_type>::int_type get_character()
|
||||
{
|
||||
if (current != end)
|
||||
if (JSON_HEDLEY_LIKELY(current != end))
|
||||
{
|
||||
auto result = std::char_traits<char_type>::to_int_type(*current);
|
||||
std::advance(current, 1);
|
||||
@ -4593,7 +4593,7 @@ struct wide_string_input_helper<BaseInputAdapter, 4>
|
||||
{
|
||||
utf8_bytes_index = 0;
|
||||
|
||||
if (input.empty())
|
||||
if (JSON_HEDLEY_UNLIKELY(input.empty()))
|
||||
{
|
||||
utf8_bytes[0] = std::char_traits<char>::eof();
|
||||
utf8_bytes_filled = 1;
|
||||
@ -4651,7 +4651,7 @@ struct wide_string_input_helper<BaseInputAdapter, 2>
|
||||
{
|
||||
utf8_bytes_index = 0;
|
||||
|
||||
if (input.empty())
|
||||
if (JSON_HEDLEY_UNLIKELY(input.empty()))
|
||||
{
|
||||
utf8_bytes[0] = std::char_traits<char>::eof();
|
||||
utf8_bytes_filled = 1;
|
||||
@ -4753,34 +4753,39 @@ struct iterator_input_adapter_factory
|
||||
using char_type = typename std::iterator_traits<iterator_type>::value_type;
|
||||
using adapter_type = iterator_input_adapter<iterator_type>;
|
||||
|
||||
static adapter_type create(IteratorType begin, IteratorType end)
|
||||
static adapter_type create(IteratorType first, IteratorType last)
|
||||
{
|
||||
return adapter_type(std::move(begin), std::move(end));
|
||||
return adapter_type(std::move(first), std::move(last));
|
||||
}
|
||||
};
|
||||
|
||||
template<typename IteratorType>
|
||||
struct iterator_input_adapter_factory<IteratorType,
|
||||
typename std::enable_if<(sizeof(typename std::iterator_traits<IteratorType>::value_type)>1)>::type >
|
||||
{
|
||||
|
||||
using iterator_type = IteratorType;
|
||||
using char_type = typename std::iterator_traits<iterator_type>::value_type;
|
||||
using base_adapter_type = iterator_input_adapter<iterator_type>;
|
||||
using adapter_type = wide_string_input_adapter<base_adapter_type, char_type>;
|
||||
|
||||
static adapter_type create(IteratorType begin, IteratorType end)
|
||||
// This test breaks astyle formatting when inlined in a template specialization.
|
||||
template<typename T>
|
||||
inline constexpr bool is_iterator_of_multibyte()
|
||||
{
|
||||
return adapter_type(base_adapter_type(std::move(begin), std::move(end)));
|
||||
return sizeof(typename std::iterator_traits<T>::value_type) > 1;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename IteratorType>
|
||||
struct iterator_input_adapter_factory<IteratorType, enable_if_t<is_iterator_of_multibyte<IteratorType>()>>
|
||||
{
|
||||
using iterator_type = IteratorType;
|
||||
using char_type = typename std::iterator_traits<iterator_type>::value_type;
|
||||
using base_adapter_type = iterator_input_adapter<iterator_type>;
|
||||
using adapter_type = wide_string_input_adapter<base_adapter_type, char_type>;
|
||||
|
||||
static adapter_type create(IteratorType first, IteratorType last)
|
||||
{
|
||||
return adapter_type(base_adapter_type(std::move(first), std::move(last)));
|
||||
}
|
||||
};
|
||||
|
||||
// General purpose iterator-based input
|
||||
template<typename IteratorType>
|
||||
typename iterator_input_adapter_factory<IteratorType>::adapter_type input_adapter(IteratorType begin, IteratorType end)
|
||||
typename iterator_input_adapter_factory<IteratorType>::adapter_type input_adapter(IteratorType first, IteratorType last)
|
||||
{
|
||||
using factory_type = iterator_input_adapter_factory<IteratorType>;
|
||||
return factory_type::create(begin, end);
|
||||
return factory_type::create(first, last);
|
||||
}
|
||||
|
||||
// Convenience shorthand from container to iterator
|
||||
@ -22381,13 +22386,13 @@ class basic_json
|
||||
|
||||
template<typename IteratorType>
|
||||
JSON_HEDLEY_WARN_UNUSED_RESULT
|
||||
static basic_json parse(IteratorType begin,
|
||||
IteratorType end,
|
||||
static basic_json parse(IteratorType first,
|
||||
IteratorType last,
|
||||
const parser_callback_t cb = nullptr,
|
||||
const bool allow_exceptions = true)
|
||||
{
|
||||
basic_json result;
|
||||
parser(detail::input_adapter(std::move(begin), std::move(end)), cb, allow_exceptions).parse(true, result);
|
||||
parser(detail::input_adapter(std::move(first), std::move(last)), cb, allow_exceptions).parse(true, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -22408,9 +22413,9 @@ class basic_json
|
||||
}
|
||||
|
||||
template<typename IteratorType>
|
||||
static bool accept(IteratorType begin, IteratorType end)
|
||||
static bool accept(IteratorType first, IteratorType last)
|
||||
{
|
||||
return parser(detail::input_adapter(std::move(begin), std::move(end))).accept(true);
|
||||
return parser(detail::input_adapter(std::move(first), std::move(last))).accept(true);
|
||||
}
|
||||
|
||||
static bool accept(detail::span_input_adapter&& i)
|
||||
|
Reference in New Issue
Block a user