66 google::protobuf::Arena* arena,
const google::protobuf::Message& inmsg,
67 google::protobuf::Message* outmsg,
const T& value) {
68 typename Protobuf<typename std::remove_cvref_t<T>>;
70 Protobuf<typename std::remove_cvref_t<T>>
::New(arena)
71 } -> std::same_as<google::protobuf::Message*>;
73 Protobuf<typename std::remove_cvref_t<T>>
::Unpack(inmsg)
74 } -> std::same_as<typename std::remove_cvref_t<T>>;
75 Protobuf<typename std::remove_cvref_t<T>>
::Pack(outmsg, value);
89 requires(T* out,
const google::protobuf::Message& msg) {
90 Protobuf<typename std::remove_cvref_t<T>>::UnpackInto(out, msg);
100template <ProtobufSerializable T>
102 return Protobuf<T>::Unpack(msg);
111template <ProtobufSerializable T>
112inline void PackProtobuf(google::protobuf::Message* msg,
const T& value) {
113 Protobuf<typename std::remove_cvref_t<T>>
::Pack(msg, value);
122template <ProtobufSerializable T>
125 Protobuf<T>::UnpackInto(out, msg);
127 *out = UnpackProtobuf<T>(msg);
135 std::span<const uint8_t> data);
137 const google::protobuf::Message& msg);
139 const google::protobuf::Message& msg);
142 const google::protobuf::Message& msg,
145 std::span<const uint8_t> descriptor)>
157template <ProtobufSerializable T>
179 const google::protobuf::Message*
GetMessage()
const {
return m_msg; }
187 std::optional<T>
Unpack(std::span<const uint8_t> data) {
228 bool Pack(std::vector<uint8_t>& out,
const T& value) {
251 std::span<const uint8_t> descriptor)>
257 google::protobuf::Message* m_msg =
nullptr;
Owning wrapper (ala std::unique_ptr) for google::protobuf::Message* that does not require the protobu...
Definition: Protobuf.h:158
std::string GetTypeString() const
Gets the type string for the message.
Definition: Protobuf.h:238
std::optional< T > Unpack(std::span< const uint8_t > data)
Unpacks from a byte array.
Definition: Protobuf.h:187
ProtobufMessage & operator=(ProtobufMessage &&rhs)
Definition: Protobuf.h:168
bool UnpackInto(T *out, std::span< const uint8_t > data)
Unpacks from a byte array into an existing object.
Definition: Protobuf.h:201
ProtobufMessage(ProtobufMessage &&rhs)
Definition: Protobuf.h:165
ProtobufMessage(google::protobuf::Arena *arena=nullptr)
Definition: Protobuf.h:160
google::protobuf::Message * GetMessage()
Gets the stored message object.
Definition: Protobuf.h:178
~ProtobufMessage()
Definition: Protobuf.h:162
const google::protobuf::Message * GetMessage() const
Definition: Protobuf.h:179
ProtobufMessage & operator=(const ProtobufMessage &)=delete
bool Pack(std::vector< uint8_t > &out, const T &value)
Packs object into a std::vector.
Definition: Protobuf.h:228
ProtobufMessage(const ProtobufMessage &)=delete
void ForEachProtobufDescriptor(function_ref< bool(std::string_view filename)> exists, function_ref< void(std::string_view filename, std::span< const uint8_t > descriptor)> fn)
Loops over all protobuf descriptors including nested/referenced descriptors.
Definition: Protobuf.h:248
bool Pack(wpi::SmallVectorImpl< uint8_t > &out, const T &value)
Packs object into a SmallVector.
Definition: Protobuf.h:216
An efficient, type-erasing, non-owning reference to a callable.
Definition: function_ref.h:31
Specifies that a type is capable of in-place protobuf deserialization.
Definition: Protobuf.h:87
Specifies that a type is capable of protobuf serialization and deserialization.
Definition: Protobuf.h:65
basic_string_view< char > string_view
Definition: core.h:501
detail namespace with internal helper functions
Definition: xchar.h:20
Definition: Protobuf.h:19
WPI_BASIC_JSON_TPL_DECLARATION void swap(wpi::WPI_BASIC_JSON_TPL &j1, wpi::WPI_BASIC_JSON_TPL &j2) noexcept(//NOLINT(readability-inconsistent-declaration-parameter-name) is_nothrow_move_constructible< wpi::WPI_BASIC_JSON_TPL >::value &&//NOLINT(misc-redundant-expression) is_nothrow_move_assignable< wpi::WPI_BASIC_JSON_TPL >::value)
exchanges the values of two JSON objects
Definition: json.h:5219
void ForEachProtobufDescriptor(const google::protobuf::Message &msg, function_ref< bool(std::string_view filename)> wants, function_ref< void(std::string_view filename, std::span< const uint8_t > descriptor)> fn)
std::string GetTypeString(const google::protobuf::Message &msg)
bool SerializeProtobuf(wpi::SmallVectorImpl< uint8_t > &out, const google::protobuf::Message &msg)
bool ParseProtobuf(google::protobuf::Message *msg, std::span< const uint8_t > data)
void DeleteProtobuf(google::protobuf::Message *msg)
Definition: ntcore_cpp.h:26
void PackProtobuf(google::protobuf::Message *msg, const T &value)
Pack a serialized protobuf message.
Definition: Protobuf.h:112
T UnpackProtobuf(const google::protobuf::Message &msg)
Unpack a serialized protobuf message.
Definition: Protobuf.h:101
void UnpackProtobufInto(T *out, const google::protobuf::Message &msg)
Unpack a serialized struct into an existing object, overwriting its contents.
Definition: Protobuf.h:123
Protobuf serialization template.
Definition: Protobuf.h:37
static void Pack(std::span< uint8_t > data, const frc::DifferentialDriveWheelVoltages &value)
static google::protobuf::Message * New(google::protobuf::Arena *arena)
static constexpr std::string_view GetTypeString()
Definition: DifferentialDriveWheelVoltagesStruct.h:14
static frc::DifferentialDriveWheelVoltages Unpack(std::span< const uint8_t > data)