Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

Commit

Permalink
Merge pull request #7 from samkhal/raw_storage_access
Browse files Browse the repository at this point in the history
Allow direct access to variant data
  • Loading branch information
facontidavide authored Oct 16, 2020
2 parents 91ceba7 + e2974d5 commit 17d60f9
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions include/ros_msg_parser/utils/variant.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -166,6 +169,10 @@ inline BuiltinType Variant::getTypeID() const {
return _type;
}

inline const uint8_t* Variant::getRawStorage() const {
return _storage.raw_data.data();
}

template<typename T> inline T Variant::extract( ) const
{
static_assert (std::numeric_limits<T>::is_specialized ||
Expand Down

0 comments on commit 17d60f9

Please sign in to comment.