| 28 | |
| 29 | template<typename CType, enum WireFormat::FieldType DeclaredType> |
| 30 | static 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 | |
| 45 | class FieldTest : public ::testing::Test { |
| 46 | protected: |