add to_yaml() function for C++ messages#523
Conversation
Signed-off-by: Dirk Thomas <dirk-thomas@users.noreply.github.com>
Signed-off-by: Dirk Thomas <dirk-thomas@users.noreply.github.com>
There was a problem hiding this comment.
I have left some minor comments, otherwise lgtm!
If in the future we want to support different serialization formats, we could use policy based design, where a serialize_to_x template function takes a policy providing overloads for the corresponding character_value_to_x, value_to_x functions.
In that way, different formats can be supported without the need of generating more code.
(edit) maybe some other things need to be added to the policy in order to be more general, but I think it's possible.
Signed-off-by: Dirk Thomas <dirk-thomas@users.noreply.github.com>
Signed-off-by: Dirk Thomas <dirk-thomas@users.noreply.github.com>
Signed-off-by: Dirk Thomas <dirk-thomas@users.noreply.github.com>
Signed-off-by: Dirk Thomas <dirk-thomas@users.noreply.github.com>
Signed-off-by: Dirk Thomas <dirk-thomas@users.noreply.github.com>
Signed-off-by: Dirk Thomas <dirk-thomas@users.noreply.github.com>
Signed-off-by: Dirk Thomas <dirk-thomas@users.noreply.github.com>
This reverts commit aac71e5.
| inline void character_value_to_yaml(unsigned char value, std::ostream & out) | ||
| { | ||
| auto flags = out.flags(); | ||
| out << "0x" << std::hex << std::setw(2) << std::setfill('0') << \ |
There was a problem hiding this comment.
This causes a downstream build failure in rmw_dds_common
https://ci.ros2.org/job/ci_linux/12266/console
--- stderr: rmw_dds_common
15:49:21 In file included from /home/jenkins-agent/workspace/ci_linux/ws/build/rmw_dds_common/rosidl_generator_cpp/rmw_dds_common/msg/detail/gid__traits.hpp:9,
15:49:21 from /home/jenkins-agent/workspace/ci_linux/ws/build/rmw_dds_common/rosidl_generator_cpp/rmw_dds_common/msg/gid.hpp:9,
15:49:21 from /home/jenkins-agent/workspace/ci_linux/ws/src/ros2/rmw_dds_common/rmw_dds_common/include/rmw_dds_common/gid_utils.hpp:21,
15:49:21 from /home/jenkins-agent/workspace/ci_linux/ws/src/ros2/rmw_dds_common/rmw_dds_common/src/gid_utils.cpp:21:
15:49:21 /home/jenkins-agent/workspace/ci_linux/ws/install/rosidl_runtime_cpp/include/rosidl_runtime_cpp/traits.hpp: In function ‘void rosidl_generator_traits::character_value_to_yaml(unsigned char, std::ostream&)’:
15:49:21 /home/jenkins-agent/workspace/ci_linux/ws/install/rosidl_runtime_cpp/include/rosidl_runtime_cpp/traits.hpp:33:35: error: ‘setw’ is not a member of ‘std’
15:49:21 33 | out << "0x" << std::hex << std::setw(2) << std::setfill('0') << \
15:49:21 | ^~~~
15:49:21 /home/jenkins-agent/workspace/ci_linux/ws/install/rosidl_runtime_cpp/include/rosidl_runtime_cpp/traits.hpp:33:51: error: ‘setfill’ is not a member of ‘std’; did you mean ‘fill’?
There was a problem hiding this comment.
Possibly just needs the <iomanip> include https://en.cppreference.com/w/cpp/io/manip/setw
This reverts commit aac71e5. Signed-off-by: Devin Bonnie <dbbonnie@amazon.com>
Closes #259. Instead of defining a
<<operator on the message this patch adds ato_yaml()function taking a message as well as anostream. That allows to implement other formats liketo_xml()side by side.Atm all logic is in header files since
rosidl_generator_cppdoesn't create a library.CI builds testing
rosidl_generator_cpp: