| 50 | } |
| 51 | |
| 52 | span<const value_type> read_buffer(std::error_code& ec) |
| 53 | { |
| 54 | if (source_.eof()) |
| 55 | { |
| 56 | return span<const value_type>(); |
| 57 | } |
| 58 | |
| 59 | auto s = source_.read_buffer(); |
| 60 | const value_type* data = s.data(); |
| 61 | std::size_t length = s.size(); |
| 62 | |
| 63 | if (bof_ && length > 0) |
| 64 | { |
| 65 | auto r = unicode_traits::detect_encoding_from_bom(data, length); |
| 66 | if (!(r.encoding == unicode_traits::encoding_kind::utf8 || r.encoding == unicode_traits::encoding_kind::undetected)) |
| 67 | { |
| 68 | ec = json_errc::illegal_unicode_character; |
| 69 | return span<const value_type>(); |
| 70 | } |
| 71 | length -= (r.ptr - data); |
| 72 | data = r.ptr; |
| 73 | bof_ = false; |
| 74 | } |
| 75 | return span<const value_type>(data, length); |
| 76 | } |
| 77 | }; |
| 78 | |
| 79 | // json_source_adaptor |
no test coverage detected