MCPcopy Create free account
hub / github.com/danielaparker/jsoncons / read_buffer

Method read_buffer

include/jsoncons/source_adaptor.hpp:52–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

read_bufferMethod · 0.45

Calls 4

detect_encoding_from_bomFunction · 0.85
eofMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected