66 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;
152 auto result = std::char_traits<char_type>::to_int_type(*current);
153 std::advance(current, 1);
157 return std::char_traits<char_type>::eof();
161 IteratorType current;
164 template<
typename BaseInputAdapter,
size_t T>
169 return current == end;
174template<
typename BaseInputAdapter,
size_t T>
177template<
typename BaseInputAdapter>
182 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
183 size_t& utf8_bytes_index,
184 size_t& utf8_bytes_filled)
186 utf8_bytes_index = 0;
190 utf8_bytes[0] = std::char_traits<char>::eof();
191 utf8_bytes_filled = 1;
196 const auto wc = input.get_character();
201 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
202 utf8_bytes_filled = 1;
204 else if (wc <= 0x7FF)
206 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x1Fu));
207 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
208 utf8_bytes_filled = 2;
210 else if (wc <= 0xFFFF)
212 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x0Fu));
213 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
214 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
215 utf8_bytes_filled = 3;
217 else if (wc <= 0x10FFFF)
219 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | ((
static_cast<unsigned int>(wc) >> 18u) & 0x07u));
220 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x3Fu));
221 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
222 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
223 utf8_bytes_filled = 4;
228 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
229 utf8_bytes_filled = 1;
235template<
typename BaseInputAdapter>
240 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
241 size_t& utf8_bytes_index,
242 size_t& utf8_bytes_filled)
244 utf8_bytes_index = 0;
248 utf8_bytes[0] = std::char_traits<char>::eof();
249 utf8_bytes_filled = 1;
254 const auto wc = input.get_character();
259 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
260 utf8_bytes_filled = 1;
262 else if (wc <= 0x7FF)
264 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u)));
265 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
266 utf8_bytes_filled = 2;
268 else if (0xD800 > wc || wc >= 0xE000)
270 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u)));
271 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
272 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
273 utf8_bytes_filled = 3;
279 const auto wc2 =
static_cast<unsigned int>(input.get_character());
280 const auto charcode = 0x10000u + (((
static_cast<unsigned int>(wc) & 0x3FFu) << 10u) | (wc2 & 0x3FFu));
281 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | (charcode >> 18u));
282 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 12u) & 0x3Fu));
283 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 6u) & 0x3Fu));
284 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (charcode & 0x3Fu));
285 utf8_bytes_filled = 4;
289 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
290 utf8_bytes_filled = 1;
298template<
typename BaseInputAdapter,
typename W
ideCharType>
305 : base_adapter(base) {}
310 if (utf8_bytes_index == utf8_bytes_filled)
312 fill_buffer<sizeof(WideCharType)>();
321 return utf8_bytes[utf8_bytes_index++];
325 BaseInputAdapter base_adapter;
334 std::array<std::char_traits<char>::int_type, 4> utf8_bytes = {{0, 0, 0, 0}};
337 std::size_t utf8_bytes_index = 0;
339 std::size_t utf8_bytes_filled = 0;
343template<
typename IteratorType,
typename Enable =
void>
347 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
359 using value_type =
typename std::iterator_traits<T>::value_type;
366template<
typename IteratorType>
370 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
381template<
typename IteratorType>
385 return factory_type::create(
first, last);
392namespace container_input_adapter_factory_impl
398template<
typename ContainerType,
typename Enable =
void>
401template<
typename ContainerType>
403 void_t<decltype(begin(
std::declval<ContainerType>()), end(std::declval<ContainerType>()))>>
415template<
typename ContainerType>
442template <
typename CharT,
443 typename std::enable_if <
444 std::is_pointer<CharT>::value&&
445 !std::is_array<CharT>::value&&
451 auto length = std::strlen(
reinterpret_cast<const char*
>(
b));
452 const auto*
ptr =
reinterpret_cast<const char*
>(
b);
456template<
typename T, std::
size_t N>
468 template <
typename CharT,
469 typename std::enable_if <
470 std::is_pointer<CharT>::value&&
475 : ia(
reinterpret_cast<const char*
>(
b),
reinterpret_cast<const char*
>(
b) + l) {}
477 template<
class IteratorType,
478 typename std::enable_if<
479 std::is_same<typename iterator_traits<IteratorType>::iterator_category, std::random_access_iterator_tag>::value,
486 return std::move(ia);
then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file
Definition: ThirdPartyNotices.txt:192
#define WPI_JSON_NAMESPACE_END
Definition: abi_macros.h:59
#define WPI_JSON_NAMESPACE_BEGIN
Definition: abi_macros.h:53
a class to store JSON values
Definition: json.h:96
#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:192
detail namespace with internal helper functions
Definition: xchar.h:20
input_format_t
the supported input formats
Definition: input_adapters.h:34
void void_t
Definition: core.h:1510
typename std::enable_if< B, T >::type enable_if_t
Definition: cpp_future.h:38
const T & first(const T &value, const Tail &...)
Definition: compile.h:60
decltype(input_adapter(std::declval< const char * >(), std::declval< const char * >())) contiguous_bytes_input_adapter
Definition: input_adapters.h:439
iterator_input_adapter_factory< IteratorType >::adapter_type input_adapter(IteratorType first, IteratorType last)
Definition: input_adapters.h:382
type
Definition: core.h:556
Definition: input_adapters.h:358
typename std::iterator_traits< T >::value_type value_type
Definition: input_adapters.h:359