Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hasField method to the interface #7

Merged
merged 1 commit into from
Jan 10, 2024

Conversation

marcinolokk
Copy link

Allows to check if the field exists. If so, we can safely access rawData() and get away from copying data what seems to be done by as() method.

*/
bool hasField(const std::string& field_name) const
{
return _message_format_ref.field(field_name)->definitionResolved();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return _message_format_ref.field(field_name)->definitionResolved();
const auto iter = _message_format_ref.fieldMap().find(field_name);
return iter != _message_format_ref.fieldMap().end() && iter.second->definitionResolved();

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was an arrow operator missing. Should be good now.

@bkueng bkueng merged commit 73cda62 into PX4:main Jan 10, 2024
2 checks passed
@marcinolokk marcinolokk deleted the pr-add-hasField branch January 10, 2024 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants