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 std::string::compare API to fixed_string [15351] #2901

Merged
merged 6 commits into from
Aug 8, 2022

Conversation

richiware
Copy link
Member

@richiware richiware commented Aug 3, 2022

Description

Updating generated code from IDL files with last fastddsgen version breaks the compilation of several tests because
fixed_string doesn't implement std::string::compare. This PR implements this function.

Contributor Checklist

  • Commit messages follow the project guidelines.
  • The code follows the style guidelines of this project.
  • Tests that thoroughly check the new feature have been added/Regression tests checking the bug and its fix have been added.
  • Any new/modified methods have been properly documented using Doxygen.
  • Fast DDS test suite has been run locally.
  • Changes are ABI compatible.
  • Changes are API compatible.
  • Documentation builds and tests pass locally.
  • New feature has been added to the versions.md file (if applicable).
  • New feature has been documented/Current behavior is correctly described in the documentation.

Reviewer Checklist

  • Check contributor checklist is correct.
  • Check CI results: changes do not issue any warning.
  • Check CI results: failing tests are unrelated with the changes.

Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>
Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>
@@ -170,6 +170,13 @@ struct fixed_string
return string_len;
}

/*!
* Compare with a std:.string.
Copy link
Contributor

Choose a reason for hiding this comment

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

Little typo: std::string instead of std:.string

Copy link
Member Author

Choose a reason for hiding this comment

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

Done in a4d80e5

@richiware richiware changed the title Add std::string::compare API to fixed_string Add std::string::compare API to fixed_string [15351] Aug 3, 2022
Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>
Copy link
Member

@MiguelCompany MiguelCompany left a comment

Choose a reason for hiding this comment

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

A test should be added to test/unittest/utils/FixedSizeStringTests.cpp

It would also be nice to have overloads for the compare method, similar to what we have for operator ==:

int compare(
        const char* s) const;

template<size_t N> int compare(
        const fixed_string<N>& str) const;

include/fastrtps/utils/fixed_size_string.hpp Outdated Show resolved Hide resolved
Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>
Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>
Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>
@richiware
Copy link
Member Author

@richiprosima Please test this

Copy link
Member

@MiguelCompany MiguelCompany left a comment

Choose a reason for hiding this comment

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

LGTM

@richiware
Copy link
Member Author

Failed tests not related.

@richiware richiware merged commit e9e933b into master Aug 8, 2022
@richiware richiware deleted the feature/fixed-string-compare branch August 8, 2022 05:40
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.

3 participants