WPILibC++ 2025.1.1
Loading...
Searching...
No Matches
wpi::ProtoOutputStream< T > Class Template Reference

Class for wrapping a nanopb ostream. More...

#include <wpi/protobuf/Protobuf.h>

Public Member Functions

 ProtoOutputStream (pb_ostream_t *stream)
 Constructs a nanopb ostream from an existing ostream object Generally used internally for encoding messages.
 
 ProtoOutputStream (detail::SmallVectorType &out)
 Constructs a nanopb ostream from a buffer.
 
 ProtoOutputStream (detail::StdVectorType &out)
 Constructs a nanopb ostream from a buffer.
 
 ProtoOutputStream ()
 Constructs a empty nanopb stream.
 
pb_ostream_tStream () noexcept
 Gets the backing nanopb stream object.
 
bool IsSubmessage () const noexcept
 Gets if this stream points to a submessage, and will call pb_encode_submessage instead of pb_encode.
 
const pb_msgdesc_tMsgDesc () const noexcept
 Gets the nanopb message descriptor.
 
bool Encode (const typename Protobuf< std::remove_cvref_t< T > >::MessageStruct &msg)
 Decodes a protobuf.
 

Detailed Description

template<typename T>
class wpi::ProtoOutputStream< T >

Class for wrapping a nanopb ostream.

Constructor & Destructor Documentation

◆ ProtoOutputStream() [1/4]

template<typename T >
wpi::ProtoOutputStream< T >::ProtoOutputStream ( pb_ostream_t * stream)
inlineexplicit

Constructs a nanopb ostream from an existing ostream object Generally used internally for encoding messages.

This constructor will cause Encode to call pb_encode_submessage instead of pb_encode_ex

Parameters
[in]streamthe nanopb ostream

◆ ProtoOutputStream() [2/4]

template<typename T >
wpi::ProtoOutputStream< T >::ProtoOutputStream ( detail::SmallVectorType & out)
inlineexplicit

Constructs a nanopb ostream from a buffer.

This constructor will cause Encode to call pb_encode_ex`

Parameters
[in]outthe stream buffer

◆ ProtoOutputStream() [3/4]

template<typename T >
wpi::ProtoOutputStream< T >::ProtoOutputStream ( detail::StdVectorType & out)
inlineexplicit

Constructs a nanopb ostream from a buffer.

This constructor will cause Encode to call pb_encode_ex`

Parameters
[in]outthe stream buffer

◆ ProtoOutputStream() [4/4]

template<typename T >
wpi::ProtoOutputStream< T >::ProtoOutputStream ( )
inline

Constructs a empty nanopb stream.

You must fill out the stream returned from Stream before calling Encode.

This constructor exists to cause Encode to call pb_encode_ex`, but allow manipulating the stream manually.

Member Function Documentation

◆ Encode()

template<typename T >
bool wpi::ProtoOutputStream< T >::Encode ( const typename Protobuf< std::remove_cvref_t< T > >::MessageStruct & msg)
inline

Decodes a protobuf.

Flags are the same flags passed to pb_decode_ex.

Parameters
[in]msgThe message to encode from
Returns
true if encoding was successful, false otherwise

◆ IsSubmessage()

template<typename T >
bool wpi::ProtoOutputStream< T >::IsSubmessage ( ) const
inlinenoexcept

Gets if this stream points to a submessage, and will call pb_encode_submessage instead of pb_encode.

Returns
true if submessage, false otherwise

◆ MsgDesc()

template<typename T >
const pb_msgdesc_t * wpi::ProtoOutputStream< T >::MsgDesc ( ) const
inlinenoexcept

Gets the nanopb message descriptor.

Returns
the nanopb message descriptor

◆ Stream()

template<typename T >
pb_ostream_t * wpi::ProtoOutputStream< T >::Stream ( )
inlinenoexcept

Gets the backing nanopb stream object.

Returns
nanopb stream

The documentation for this class was generated from the following file: