LBANN  0.103.0
LivermoreBigArtificialNeuralNetworkToolkit
lbann::protobuf Namespace Reference

Namespaces

 details
 
 text
 

Typedefs

Typedefs for working with Protobuf fixed-width types.
using int8 = google::protobuf::int8
 
using int16 = google::protobuf::int16
 
using int32 = google::protobuf::int32
 
using int64 = google::protobuf::int64
 
using uint8 = google::protobuf::uint8
 
using uint16 = google::protobuf::uint16
 
using uint32 = google::protobuf::uint32
 
using uint64 = google::protobuf::uint64
 

Functions

Message queries
bool has_oneof (google::protobuf::Message const &msg, std::string const &oneof_name)
 Test whether the message has a oneof field with the given name. More...
 
google::protobuf::Message const & get_oneof_message (google::protobuf::Message const &msg, std::string const &oneof_name)
 Get a message in a oneof from the given message. More...
 
std::string which_oneof (google::protobuf::Message const &msg, std::string const &oneof_name)
 Get the name of the set field in the named oneof. More...
 
std::string message_type (google::protobuf::Message const &msg)
 Get the name of the message type as a string. More...
 
std::string message_type (google::protobuf::Any const &any)
 Get the name of the underlying message type as a string. More...
 
Complex extraction methods
template<typename T >
auto as_vector (google::protobuf::Message const &msg, std::string const &field_name) -> std::vector< T >
 Extract the values from the named field as a vector. More...
 
template<typename T >
auto as_vector (google::protobuf::RepeatedField< T > const &) -> std::vector< T >
 Convert the repeated field to an STL vector. More...
 
template<typename T >
auto as_vector (google::protobuf::RepeatedPtrField< T > const &) -> std::vector< T >
 Convert the repeated field to an STL vector. More...
 
template<typename OutT , typename InT >
auto to_vector (google::protobuf::RepeatedField< InT > const &rf) -> std::vector< OutT >
 Convert the repeated field to an STL vector of given type. More...
 
template<typename T >
auto as_set (google::protobuf::Message const &msg, std::string const &field_name) -> std::set< T >
 Extract the values from the named field as a set. More...
 
template<typename T >
auto as_set (google::protobuf::RepeatedField< T > const &) -> std::set< T >
 Convert the repeated field to an STL set. More...
 
auto as_set (google::protobuf::RepeatedPtrField< std::string > const &) -> std::set< std::string >
 Convert the repeated field to an STL set. More...
 
template<typename OutT , typename InT >
auto to_set (google::protobuf::RepeatedField< InT > const &) -> std::set< OutT >
 Convert the repeated field to an STL set of given type. More...
 
template<typename T >
auto as_unordered_set (google::protobuf::Message const &msg, std::string const &field_name) -> std::unordered_set< T >
 Extract the values from the named field as an unordered_set. More...
 
template<typename T >
auto as_unordered_set (google::protobuf::RepeatedField< T > const &) -> std::unordered_set< T >
 Convert the repeated field to an STL unordered_set. More...
 
auto as_unordered_set (google::protobuf::RepeatedPtrField< std::string > const &) -> std::unordered_set< std::string >
 Convert the repeated field to an STL unordered_set. More...
 
template<typename OutT , typename InT >
auto to_unordered_set (google::protobuf::RepeatedField< InT > const &) -> std::unordered_set< OutT >
 Convert the repeated field to an STL unordered_set of given type. More...
 
Message I/O
void fill (std::istream &is, google::protobuf::Message &msg)
 Fill the protobuf message from a binary stream. More...
 
void fill (std::string const &pbuf_str, google::protobuf::Message &msg)
 Fill the protobuf message from a string of bytes. More...
 
void load (std::string const &pbuf_filename, google::protobuf::Message &msg)
 Fill the protobuf message from a binary file. More...
 
void serialize (std::ostream &os, google::protobuf::Message const &msg)
 Serialize the protobuf message to a stream. More...
 
std::string serialize (google::protobuf::Message const &msg)
 Serialize the protobuf message to a string. More...
 
void serialize (std::string const &pbuf_filename, google::protobuf::Message const &msg)
 Serialize the protobuf message to a file. More...
 
Writing protobufs
template<typename T , typename ContainerT >
void assign_to_repeated (google::protobuf::RepeatedField< T > &field, ContainerT const &values)
 Assign a range of values to a repeated protobuf field. More...
 
template<typename ContainerT >
std::string to_space_sep_string (ContainerT const &values)
 Concatenate a container of strings into a single string. Elements are space separated. More...
 

Typedef Documentation

◆ int16

using lbann::protobuf::int16 = typedef google::protobuf::int16

Definition at line 54 of file decl.hpp.

◆ int32

using lbann::protobuf::int32 = typedef google::protobuf::int32

Definition at line 55 of file decl.hpp.

◆ int64

using lbann::protobuf::int64 = typedef google::protobuf::int64

Definition at line 56 of file decl.hpp.

◆ int8

using lbann::protobuf::int8 = typedef google::protobuf::int8

Definition at line 53 of file decl.hpp.

◆ uint16

using lbann::protobuf::uint16 = typedef google::protobuf::uint16

Definition at line 59 of file decl.hpp.

◆ uint32

using lbann::protobuf::uint32 = typedef google::protobuf::uint32

Definition at line 60 of file decl.hpp.

◆ uint64

using lbann::protobuf::uint64 = typedef google::protobuf::uint64

Definition at line 61 of file decl.hpp.

◆ uint8

using lbann::protobuf::uint8 = typedef google::protobuf::uint8

Definition at line 58 of file decl.hpp.

Function Documentation

◆ as_set() [1/3]

template<typename T >
auto lbann::protobuf::as_set ( google::protobuf::Message const &  msg,
std::string const &  field_name 
) -> std::set<T>

Extract the values from the named field as a set.

Definition at line 181 of file impl.hpp.

◆ as_set() [2/3]

template<typename T >
auto lbann::protobuf::as_set ( google::protobuf::RepeatedField< T > const &  rf) -> std::set<T>

Convert the repeated field to an STL set.

This overload covers basic POD types, to include enum types.

Definition at line 192 of file impl.hpp.

◆ as_set() [3/3]

auto lbann::protobuf::as_set ( google::protobuf::RepeatedPtrField< std::string > const &  rf) -> std::set<std::string>
inline

Convert the repeated field to an STL set.

This overload is for strings.

Definition at line 198 of file impl.hpp.

◆ as_unordered_set() [1/3]

template<typename T >
auto lbann::protobuf::as_unordered_set ( google::protobuf::Message const &  msg,
std::string const &  field_name 
) -> std::unordered_set<T>

Extract the values from the named field as an unordered_set.

Definition at line 213 of file impl.hpp.

◆ as_unordered_set() [2/3]

template<typename T >
auto lbann::protobuf::as_unordered_set ( google::protobuf::RepeatedField< T > const &  rf) -> std::unordered_set<T>

Convert the repeated field to an STL unordered_set.

This overload covers basic POD types, to include enum types.

Definition at line 225 of file impl.hpp.

◆ as_unordered_set() [3/3]

auto lbann::protobuf::as_unordered_set ( google::protobuf::RepeatedPtrField< std::string > const &  rf) -> std::unordered_set<std::string>
inline

Convert the repeated field to an STL unordered_set.

This overload is for strings.

Definition at line 231 of file impl.hpp.

◆ as_vector() [1/3]

template<typename T >
auto lbann::protobuf::as_vector ( google::protobuf::Message const &  msg,
std::string const &  field_name 
) -> std::vector<T>

Extract the values from the named field as a vector.

Definition at line 152 of file impl.hpp.

◆ as_vector() [2/3]

template<typename T >
auto lbann::protobuf::as_vector ( google::protobuf::RepeatedField< T > const &  rf) -> std::vector<T>

Convert the repeated field to an STL vector.

This overload covers basic POD types, to include enum types.

Definition at line 160 of file impl.hpp.

◆ as_vector() [3/3]

template<typename T >
auto lbann::protobuf::as_vector ( google::protobuf::RepeatedPtrField< T > const &  rf) -> std::vector<T>

Convert the repeated field to an STL vector.

This overload covers "complex" types, namely strings and messages.

Definition at line 167 of file impl.hpp.

◆ assign_to_repeated()

template<typename T , typename ContainerT >
void lbann::protobuf::assign_to_repeated ( google::protobuf::RepeatedField< T > &  field,
ContainerT const &  values 
)

Assign a range of values to a repeated protobuf field.

Todo:
Change to Assign if Protobuf v3.16.0 and greater is required.

Definition at line 125 of file impl.hpp.

Here is the caller graph for this function:

◆ fill() [1/2]

void lbann::protobuf::fill ( std::istream &  is,
google::protobuf::Message &  msg 
)

Fill the protobuf message from a binary stream.

Here is the caller graph for this function:

◆ fill() [2/2]

void lbann::protobuf::fill ( std::string const &  pbuf_str,
google::protobuf::Message &  msg 
)

Fill the protobuf message from a string of bytes.

◆ get_oneof_message()

google::protobuf::Message const& lbann::protobuf::get_oneof_message ( google::protobuf::Message const &  msg,
std::string const &  oneof_name 
)

Get a message in a oneof from the given message.

A oneof field with the given name must exist in the message. The value set in the oneof must be a message.

◆ has_oneof()

bool lbann::protobuf::has_oneof ( google::protobuf::Message const &  msg,
std::string const &  oneof_name 
)

Test whether the message has a oneof field with the given name.

Returns
true iff the message has a field with the given name and the field is a oneof.

◆ load()

void lbann::protobuf::load ( std::string const &  pbuf_filename,
google::protobuf::Message &  msg 
)

Fill the protobuf message from a binary file.

Here is the caller graph for this function:

◆ message_type() [1/2]

std::string lbann::protobuf::message_type ( google::protobuf::Message const &  msg)

Get the name of the message type as a string.

Here is the caller graph for this function:

◆ message_type() [2/2]

std::string lbann::protobuf::message_type ( google::protobuf::Any const &  any)

Get the name of the underlying message type as a string.

◆ serialize() [1/3]

void lbann::protobuf::serialize ( std::ostream &  os,
google::protobuf::Message const &  msg 
)

Serialize the protobuf message to a stream.

Here is the caller graph for this function:

◆ serialize() [2/3]

std::string lbann::protobuf::serialize ( google::protobuf::Message const &  msg)

Serialize the protobuf message to a string.

◆ serialize() [3/3]

void lbann::protobuf::serialize ( std::string const &  pbuf_filename,
google::protobuf::Message const &  msg 
)

Serialize the protobuf message to a file.

◆ to_set()

template<typename OutT , typename InT >
auto lbann::protobuf::to_set ( google::protobuf::RepeatedField< InT > const &  rf) -> std::set<OutT>

Convert the repeated field to an STL set of given type.

The same warnings apply as for to_vector.

Definition at line 206 of file impl.hpp.

◆ to_space_sep_string()

template<typename ContainerT >
std::string lbann::protobuf::to_space_sep_string ( ContainerT const &  values)

Concatenate a container of strings into a single string. Elements are space separated.

Stringify the container with spaces between elements.

The value_type of the container must support stream output (e.g., vector or set, but not map).

Definition at line 140 of file impl.hpp.

◆ to_unordered_set()

template<typename OutT , typename InT >
auto lbann::protobuf::to_unordered_set ( google::protobuf::RepeatedField< InT > const &  rf) -> std::unordered_set<OutT>

Convert the repeated field to an STL unordered_set of given type.

The same warnings apply as for to_vector.

Definition at line 239 of file impl.hpp.

◆ to_vector()

template<typename OutT , typename InT >
auto lbann::protobuf::to_vector ( google::protobuf::RepeatedField< InT > const &  rf) -> std::vector<OutT>

Convert the repeated field to an STL vector of given type.

The input type must implicitly convert to the output type. Narrowing conversions are allowed and the onus is on the caller to prevent any associated problems. In the worst case, a caller could instead call as_vector and manually copy the values.

Definition at line 174 of file impl.hpp.

◆ which_oneof()

std::string lbann::protobuf::which_oneof ( google::protobuf::Message const &  msg,
std::string const &  oneof_name 
)

Get the name of the set field in the named oneof.

A oneof with the given name must exist in the message.