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

Method read_buffer

include/jsoncons/source_adaptor.hpp:112–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110 }
111
112 span<const value_type> read_buffer(std::error_code& ec)
113 {
114 if (source_.eof())
115 {
116 return span<const value_type>();
117 }
118
119 auto s = source_.read_buffer();
120 const value_type* data = s.data();
121 std::size_t length = s.size();
122
123 if (bof_ && length > 0)
124 {
125 auto r = unicode_traits::detect_json_encoding(data, length);
126 if (!(r.encoding == unicode_traits::encoding_kind::utf8 || r.encoding == unicode_traits::encoding_kind::undetected))
127 {
128 ec = json_errc::illegal_unicode_character;
129 return span<const value_type>();
130 }
131 length -= (r.ptr - data);
132 data = r.ptr;
133 bof_ = false;
134 }
135
136 return span<const value_type>(data, length);
137 }
138 };
139
140} // namespace jsoncons

Callers

nothing calls this directly

Calls 5

detect_json_encodingFunction · 0.85
eofMethod · 0.45
read_bufferMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected