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 function 'find_and_replace' #13

Merged
merged 6 commits into from
Jun 12, 2019
Merged

Conversation

jacobperron
Copy link
Member

This will be used for improvements related to ros2/rmw_fastrtps#277.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
@jacobperron jacobperron requested a review from a team as a code owner June 8, 2019 00:16
@jacobperron
Copy link
Member Author

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

std::string output = input;
const std::size_t find_len = find.length();
const std::size_t replace_len = replace.length();
if (0u == find_len) {

Choose a reason for hiding this comment

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

We can also check if 0u == input.length() here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Would this improve anything? We won't enter the while-loop anyways.

Copy link

@prajakta-gokhale prajakta-gokhale left a comment

Choose a reason for hiding this comment

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

Few minor suggestions and nitpicks, looks good otherwise.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
Signed-off-by: Jacob Perron <jacob@openrobotics.org>
Signed-off-by: Jacob Perron <jacob@openrobotics.org>
@jacobperron jacobperron force-pushed the jacob/find_and_replace branch from 9fe5c66 to eb1ec92 Compare June 11, 2019 19:13
Signed-off-by: William Woodall <william@osrfoundation.org>
FindT && find,
ReplaceT && replace)
{
auto input_str = detail::normalize_to_basic_string(input);
Copy link
Member

Choose a reason for hiding this comment

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

There is one limitation here which is that the three argument normalize to the same char typed basic_string. Which I think is fine.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I think that's okay.

@jacobperron
Copy link
Member Author

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
@jacobperron
Copy link
Member Author

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@jacobperron jacobperron merged commit 1760a4f into master Jun 12, 2019
@delete-merged-branch delete-merged-branch bot deleted the jacob/find_and_replace branch June 12, 2019 15:53
jacobperron added a commit that referenced this pull request Jul 26, 2019
* Add function 'find_and_replace'

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Fix spelling

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Add shortcut for find == replace

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Template on std::basic_string

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* changed find_and_replace to accept literals using magic 🌈✨

Signed-off-by: William Woodall <william@osrfoundation.org>

* Fix lint

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
jacobperron added a commit that referenced this pull request Jul 26, 2019
* Add function 'find_and_replace'

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Fix spelling

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Add shortcut for find == replace

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Template on std::basic_string

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* changed find_and_replace to accept literals using magic 🌈✨

Signed-off-by: William Woodall <william@osrfoundation.org>

* Fix lint

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
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