-
Notifications
You must be signed in to change notification settings - Fork 735
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix arguments when using the rclcpp_component as a regular node
Signed-off-by: Alejandro Hernández Cordero <[email protected]>
- Loading branch information
Showing
5 changed files
with
158 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright 2023 Open Source Robotics Foundation, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include "utilities.hpp" | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
namespace image_view | ||
{ | ||
std::string get_option(const std::vector<std::string> & args, const std::string & option_name) | ||
{ | ||
for (auto it = args.begin(), end = args.end(); it != end; ++it) { | ||
if (*it == option_name) { | ||
if (it + 1 != end) { | ||
return *(it + 1); | ||
} | ||
} | ||
} | ||
|
||
return ""; | ||
} | ||
|
||
bool has_option(const std::vector<std::string> & args, const std::string & option_name) | ||
{ | ||
for (auto it = args.begin(), end = args.end(); it != end; ++it) { | ||
if (*it == option_name) { | ||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
} // namespace image_view |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright 2023 Open Source Robotics Foundation, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#ifndef UTILITIES_HPP_ | ||
#define UTILITIES_HPP_ | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
namespace image_view | ||
{ | ||
/// Get the option from a list of arguments | ||
/// param[in] args List of arguments | ||
/// param[in] option name to extract | ||
/// return option value | ||
std::string get_option(const std::vector<std::string> & args, const std::string & option_name); | ||
|
||
/// Is the option available in the list of arguments | ||
/// param[in] args List of arguments | ||
/// param[in] option name to extract | ||
/// return true if the option exists or false otherwise | ||
bool has_option(const std::vector<std::string> & args, const std::string & option_name); | ||
} // namespace image_view | ||
#endif // UTILITIES_HPP_ |