Class Parser
Defined in File ros_parser.hpp
Nested Relationships
Nested Types
Class Documentation
-
class Parser
Public Types
Public Functions
-
Parser(const std::string &topic_name, const ROSType &msg_type, const std::string &definition, SchemaFormat format = ROS_MSG)
- Parameters:
topic_name – name of the topic to be used as node of the StringTree
msg_type – message type of the topic.
definition – schema text (ROS .msg or DDS IDL)
format – schema format: ROS_MSG (default) or DDS_IDL
-
inline void setMaxArrayPolicy(MaxArrayPolicy discard_entire_array, size_t max_array_size)
Default values are DISCARD_LARGE_ARRAYS and 100. The maximum permissible value of max_array_size is 10.000 (but don’t)
-
inline MaxArrayPolicy maxArrayPolicy() const
-
inline size_t maxArraySize() const
-
inline void setBlobPolicy(BlobPolicy policy)
-
inline BlobPolicy blobPolicy() const
-
const std::shared_ptr<MessageSchema> &getSchema() const
getSchema provides some metadata amount a registered ROSMessage.
-
ROSMessage::Ptr getMessageByType(const ROSType &type) const
-
bool deserialize(Span<const uint8_t> buffer, FlatMessage *flat_output, Deserializer *deserializer) const
deserializeIntoFlatContainer takes a raw buffer of memory and extract information from it. This data is stored in two key/value vectors, FlatMessage::value and FlatMessage::name. It must be noted that the key type is FieldsVector. This type is not particularly user-friendly, but allows a much faster post-processing.
IMPORTANT: this approach is not meant to be used with use arrays such as maps, point clouds and images.For this reason the argument max_array_size is used.
This function is almost always followed by CreateRenamedValues, which provide a more human-readable key-value representation.
- Parameters:
buffer – raw memory to be parsed.
flat_output – output to store the result. It is recommended to reuse the same object multiple times to avoid memory allocations and speed up the parsing.
- Returns:
true if the entire message was parsed or false if parts of the message were skipped because an array has (size > max_array_size)
-
bool deserializeIntoJson(Span<const uint8_t> buffer, std::string *json_txt, Deserializer *deserializer, int indent = 0, bool ignore_constants = false) const
-
bool serializeFromJson(const std::string_view json_string, Serializer *serializer) const
-
void applyVisitorToBuffer(const ROSType &msg_type, Span<uint8_t> &buffer, VisitingCallback callback) const
applyVisitorToBuffer is used to pass a callback that is invoked every time a chunk of memory storing an instance of ROSType = monitored_type is reached. Note that the VisitingCallback can modify the original message, but can NOT change its size. This means that strings and vectors can not be change their length.
- Parameters:
msg_identifier – String ID to identify the registered message (use registerMessageDefinition first).
monitored_type – ROSType that triggers the invocation to the callback
buffer – Original buffer, passed as mutable since it might be modified.
callback – The callback.
-
bool walkSchema(Span<const uint8_t> buffer, Deserializer *deserializer, MessageWriter *writer) const
Walk the schema and write deserialized values to a MessageWriter. This is the unified deserialization path used by deserialize() and deserializeIntoJson().
-
inline void setWarningsStream(std::ostream *output)
Change where the warning messages are displayed.
-
Parser(const std::string &topic_name, const ROSType &msg_type, const std::string &definition, SchemaFormat format = ROS_MSG)