Function cras::setHeader

Function Documentation

bool cras::setHeader(::topic_tools::ShapeShifter &msg, ::std_msgs::Header &header)

Change the header field of the given message, if it has any.

Note

This function does not (de)serialize the whole message, it only serializes its header part.

Note

If the new header is shorter or same length as the old one, there is no memory allocation happening.

Parameters:
  • msg[inout] The message to change.

  • header[in] The header to set.

Returns:

Whether setting the new header has succeeded. It will fail if either the message does not seem to have a header field, or if some serialization/deserialization error occurs. If the function returns false, the message has to be considered invalid and has to be discarded. The caller should use getHeader() or other information sources to make sure the message type actually does have a header.