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

Function readPrimitive

valdi_protobuf/test/Field_tests.cpp:30–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28
29template<typename CType, enum WireFormat::FieldType DeclaredType>
30static std::optional<CType> readPrimitive(ByteBuffer& buffer) {
31 google::protobuf::io::CodedInputStream inputStream(reinterpret_cast<uint8_t*>(buffer.data()), buffer.size());
32
33 if (inputStream.ReadTag() == 0) {
34 return std::nullopt;
35 }
36
37 CType output;
38
39 if (!WireFormat::ReadPrimitive<CType, DeclaredType>(&inputStream, &output)) {
40 return std::nullopt;
41 }
42 return {output};
43}
44
45class FieldTest : public ::testing::Test {
46protected:

Callers

nothing calls this directly

Calls 2

dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected