MCPcopy Create free account
hub / github.com/Snapchat/Valdi / writeLengthDelimited

Function writeLengthDelimited

valdi_protobuf/src/valdi_protobuf/Field.cpp:235–251  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

233
234template<typename F>
235static Byte* writeLengthDelimited(
236 FieldNumber fieldNumber, size_t length, bool writeEvenIfEmpty, Byte* bufferStart, Byte* bufferEnd, F&& write) {
237 if (!writeEvenIfEmpty && length == 0) {
238 return bufferStart;
239 }
240
241 bufferStart = writeTag(fieldNumber, WireFormat::WIRETYPE_LENGTH_DELIMITED, bufferStart, bufferEnd);
242 bufferStart = CodedOutputStream::WriteVarint32ToArray(static_cast<uint32_t>(length), bufferStart);
243
244 auto* endPtr = bufferStart + length;
245
246 SC_ABORT_UNLESS(endPtr <= bufferEnd, "Out of bounds");
247
248 write(bufferStart);
249
250 return endPtr;
251}
252
253Byte* Field::write(FieldNumber fieldNumber,
254 bool writeEvenIfEmpty,

Callers 1

writeMethod · 0.85

Calls 1

writeTagFunction · 0.85

Tested by

no test coverage detected