67 return std::fgetc(m_file);
95 is->clear(is->rdstate() & std::ios::eofbit);
100 : is(&i), sb(i.rdbuf())
109 : is(rhs.is), sb(rhs.sb)
120 auto res = sb->sbumpc();
124 is->clear(is->rdstate() | std::ios::eofbit);
131 std::istream* is =
nullptr;
132 std::streambuf* sb =
nullptr;
138template<
typename IteratorType>
142 using char_type =
typename std::iterator_traits<IteratorType>::value_type;
153 std::advance(current, 1);
161 IteratorType current;
164 template<
typename BaseInputAdapter,
size_t T>
169 return current == end;
173template<
typename BaseInputAdapter,
size_t T>
176template<
typename BaseInputAdapter>
181 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
182 size_t& utf8_bytes_index,
183 size_t& utf8_bytes_filled)
185 utf8_bytes_index = 0;
189 utf8_bytes[0] = std::char_traits<char>::eof();
190 utf8_bytes_filled = 1;
195 const auto wc = input.get_character();
200 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
201 utf8_bytes_filled = 1;
203 else if (wc <= 0x7FF)
205 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x1Fu));
206 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
207 utf8_bytes_filled = 2;
209 else if (wc <= 0xFFFF)
211 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x0Fu));
212 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
213 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
214 utf8_bytes_filled = 3;
216 else if (wc <= 0x10FFFF)
218 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | ((
static_cast<unsigned int>(wc) >> 18u) & 0x07u));
219 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x3Fu));
220 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
221 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
222 utf8_bytes_filled = 4;
227 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
228 utf8_bytes_filled = 1;
234template<
typename BaseInputAdapter>
239 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
240 size_t& utf8_bytes_index,
241 size_t& utf8_bytes_filled)
243 utf8_bytes_index = 0;
247 utf8_bytes[0] = std::char_traits<char>::eof();
248 utf8_bytes_filled = 1;
253 const auto wc = input.get_character();
258 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
259 utf8_bytes_filled = 1;
261 else if (wc <= 0x7FF)
263 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u)));
264 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
265 utf8_bytes_filled = 2;
267 else if (0xD800 > wc || wc >= 0xE000)
269 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u)));
270 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
271 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
272 utf8_bytes_filled = 3;
278 const auto wc2 =
static_cast<unsigned int>(input.get_character());
279 const auto charcode = 0x10000u + (((
static_cast<unsigned int>(wc) & 0x3FFu) << 10u) | (wc2 & 0x3FFu));
280 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | (charcode >> 18u));
281 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 12u) & 0x3Fu));
282 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 6u) & 0x3Fu));
283 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (charcode & 0x3Fu));
284 utf8_bytes_filled = 4;
288 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
289 utf8_bytes_filled = 1;
297template<
typename BaseInputAdapter,
typename W
ideCharType>
304 : base_adapter(base) {}
309 if (utf8_bytes_index == utf8_bytes_filled)
311 fill_buffer<sizeof(WideCharType)>();
320 return utf8_bytes[utf8_bytes_index++];
324 BaseInputAdapter base_adapter;
333 std::array<std::char_traits<char>::int_type, 4> utf8_bytes = {{0, 0, 0, 0}};
336 std::size_t utf8_bytes_index = 0;
338 std::size_t utf8_bytes_filled = 0;
341template<
typename IteratorType,
typename Enable =
void>
345 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
357 using value_type =
typename std::iterator_traits<T>::value_type;
364template<
typename IteratorType>
368 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
379template<
typename IteratorType>
383 return factory_type::create(
first, last);
390namespace container_input_adapter_factory_impl
396template<
typename ContainerType,
typename Enable =
void>
399template<
typename ContainerType>
401 void_t<decltype(begin(
std::declval<ContainerType>()), end(std::declval<ContainerType>()))>>
413template<
typename ContainerType>
440template <
typename CharT,
441 typename std::enable_if <
442 std::is_pointer<CharT>::value&&
443 !std::is_array<CharT>::value&&
444 std::is_integral<typename std::remove_pointer<CharT>::type>
::value&&
445 sizeof(
typename std::remove_pointer<CharT>::type) == 1,
449 auto length = std::strlen(
reinterpret_cast<const char*
>(b));
450 const auto*
ptr =
reinterpret_cast<const char*
>(b);
454template<
typename T, std::
size_t N>
466 template <
typename CharT,
467 typename std::enable_if <
468 std::is_pointer<CharT>::value&&
469 std::is_integral<typename std::remove_pointer<CharT>::type>
::value&&
470 sizeof(
typename std::remove_pointer<CharT>::type) == 1,
473 : ia(
reinterpret_cast<const char*
>(b),
reinterpret_cast<const char*
>(b) + l) {}
475 template<
class IteratorType,
476 typename std::enable_if<
477 std::is_same<typename iterator_traits<IteratorType>::iterator_category, std::random_access_iterator_tag>
::value,
484 return std::move(ia);
#define WPI_JSON_NAMESPACE_END
Definition abi_macros.h:59
#define WPI_JSON_NAMESPACE_BEGIN
Definition abi_macros.h:53
#define JSON_HEDLEY_LIKELY(expr)
Definition hedley.h:1395
#define JSON_HEDLEY_NON_NULL(...)
Definition hedley.h:1288
#define JSON_HEDLEY_UNLIKELY(expr)
Definition hedley.h:1396
#define JSON_ASSERT(x)
Definition macro_scope.h:200
detail namespace with internal helper functions
Definition input_adapters.h:32
auto first(const T &value, const Tail &...) -> const T &
Definition compile.h:55
input_format_t
the supported input formats
Definition input_adapters.h:35
typename std::enable_if< B, T >::type enable_if_t
Definition cpp_future.h:38
@ value
the parser finished reading a JSON value
decltype(input_adapter(std::declval< const char * >(), std::declval< const char * >())) contiguous_bytes_input_adapter
Definition input_adapters.h:437
@ array
array (ordered collection of values)
typename make_void< Ts... >::type void_t
Definition void_t.h:21
iterator_input_adapter_factory< IteratorType >::adapter_type input_adapter(IteratorType first, IteratorType last)
Definition input_adapters.h:380
Implement std::hash so that hash_code can be used in STL containers.
Definition PointerIntPair.h:280
Definition type_traits.h:192
Definition input_adapters.h:356
typename std::iterator_traits< T >::value_type value_type
Definition input_adapters.h:357