From e2974d536ac78a027334d526c675bf0240844563 Mon Sep 17 00:00:00 2001 From: Sam Khalandovsky Date: Mon, 14 Sep 2020 22:45:02 -0700 Subject: [PATCH] Direct variant access --- include/ros_msg_parser/utils/variant.hpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/ros_msg_parser/utils/variant.hpp b/include/ros_msg_parser/utils/variant.hpp index 869a3f2..2de990d 100644 --- a/include/ros_msg_parser/utils/variant.hpp +++ b/include/ros_msg_parser/utils/variant.hpp @@ -118,6 +118,9 @@ class Variant void assign(const char* buffer, size_t length); + // Direct access to raw data. Undefined behavior if this variant holds a STRING + const uint8_t* getRawStorage() const; + private: union { @@ -166,6 +169,10 @@ inline BuiltinType Variant::getTypeID() const { return _type; } +inline const uint8_t* Variant::getRawStorage() const { + return _storage.raw_data.data(); +} + template inline T Variant::extract( ) const { static_assert (std::numeric_limits::is_specialized ||