From 07daa9d6bf2f0c071225aecf4f03edb13c43918c Mon Sep 17 00:00:00 2001 From: Marcin Date: Wed, 10 Jan 2024 10:45:24 +0100 Subject: [PATCH] add hasField method --- ulog_cpp/subscription.hpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ulog_cpp/subscription.hpp b/ulog_cpp/subscription.hpp index da4a936..b0b7e79 100644 --- a/ulog_cpp/subscription.hpp +++ b/ulog_cpp/subscription.hpp @@ -93,6 +93,15 @@ class TypedDataView { */ const MessageFormat& format() const { return _message_format_ref; } + /** + * Checks if a field is present in the underlying MessageFormat + */ + bool hasField(const std::string& field_name) const + { + const auto iter = _message_format_ref.fieldMap().find(field_name); + return iter != _message_format_ref.fieldMap().end() && iter->second->definitionResolved(); + } + /** * @return The underlying raw data vector */