chrono::ros::core::MessageBuilder Class Reference

Description

Mutable, schema-backed message under construction. Move-only.

#include <ChROSMessageCodec.h>

Public Member Functions

 MessageBuilder (std::shared_ptr< const Schema > schema)
 Create a builder for the schema's root type.
 
 MessageBuilder (MessageBuilder &&)=default
 
MessageBuilderoperator= (MessageBuilder &&)=default
 
 MessageBuilder (const MessageBuilder &)=delete
 
MessageBuilderoperator= (const MessageBuilder &)=delete
 
void SetBool (const std::string &path, bool value)
 
void SetInt (const std::string &path, int64_t value)
 Accepted by all integer fields (with range check) and float fields.
 
void SetUInt (const std::string &path, uint64_t value)
 
void SetDouble (const std::string &path, double value)
 Accepted by float32/float64 fields only (integer fields refuse doubles to surface accidental lossy writes).
 
void SetString (const std::string &path, const std::string &value)
 
void SetBlob (const std::string &path, const void *data, size_t count)
 Set a primitive array/sequence from raw little-endian element data. More...
 
void SetBlobCopy (const std::string &path, const void *data, size_t count)
 As SetBlob, but copies the data into the builder (safe lifetime).
 
void SetBlobBytes (const std::string &path, const void *data, size_t nbytes)
 As SetBlobCopy, but sized in bytes rather than elements: the element count is 'nbytes / element_size', and 'nbytes' must be a whole multiple of the field's element size (else FieldError). More...
 
void SetStringArray (const std::string &path, const std::vector< std::string > &value)
 Set a string array/sequence.
 
MessageBuilderGetNested (const std::string &path)
 Builder for a singular nested message field (created on first access).
 
MessageBuilderAppendMessage (const std::string &path)
 Append an element to a message array/sequence field and return its builder. More...
 
void SetTime (const std::string &path, double time_seconds)
 Set a builtin_interfaces/Time-shaped nested message ("<path>.sec", "<path>.nanosec") from seconds. More...
 
void Clear ()
 Remove all values (schema is retained).
 
void SerializeTo (std::vector< uint8_t > &out) const
 Append the wire-format serialization (encapsulation header + CDR body) of this message to 'out'. More...
 
const SchemaGetSchema () const
 
int32_t TypeIndex () const
 

Member Function Documentation

◆ AppendMessage()

MessageBuilder & chrono::ros::core::MessageBuilder::AppendMessage ( const std::string &  path)

Append an element to a message array/sequence field and return its builder.

Bounded sequences and fixed arrays enforce their capacity.

◆ SerializeTo()

void chrono::ros::core::MessageBuilder::SerializeTo ( std::vector< uint8_t > &  out) const

Append the wire-format serialization (encapsulation header + CDR body) of this message to 'out'.

May be called repeatedly.

◆ SetBlob()

void chrono::ros::core::MessageBuilder::SetBlob ( const std::string &  path,
const void *  data,
size_t  count 
)

Set a primitive array/sequence from raw little-endian element data.

'count' is the element count; the byte size is derived from the field's element type. The data is NOT copied: it must stay alive until serialization. For bool elements, bytes must be 0 or 1.

◆ SetBlobBytes()

void chrono::ros::core::MessageBuilder::SetBlobBytes ( const std::string &  path,
const void *  data,
size_t  nbytes 
)

As SetBlobCopy, but sized in bytes rather than elements: the element count is 'nbytes / element_size', and 'nbytes' must be a whole multiple of the field's element size (else FieldError).

Convenient for byte-oriented sources (Python buffers, raw serialized blobs) that do not carry the schema's element size themselves.

◆ SetTime()

void chrono::ros::core::MessageBuilder::SetTime ( const std::string &  path,
double  time_seconds 
)

Set a builtin_interfaces/Time-shaped nested message ("<path>.sec", "<path>.nanosec") from seconds.

Negative times are rejected.


The documentation for this class was generated from the following files:
  • /builds/uwsbel/chrono/src/chrono_ros/core/ChROSMessageCodec.h
  • /builds/uwsbel/chrono/src/chrono_ros/core/ChROSMessageCodec.cpp