-
Notifications
You must be signed in to change notification settings - Fork 45
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
Skip liveliness parts for qos elements with default values #266
Changes from 2 commits
89403d0
db537a8
bd3722f
8159b0b
f2ee15e
dd44983
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,9 @@ | |
#include <string> | ||
#include <vector> | ||
|
||
#include "logging_macros.hpp" | ||
|
||
#include "rmw/error_handling.h" | ||
#include "rmw/types.h" | ||
|
||
namespace rmw_zenoh_cpp | ||
|
@@ -218,7 +221,7 @@ std::string demangle_name(const std::string & input); | |
* | ||
* See rmw/types.h for the values of each policy enum. | ||
*/ | ||
std::string qos_to_keyexpr(rmw_qos_profile_t qos); | ||
std::string qos_to_keyexpr(const rmw_qos_profile_t & qos); | ||
|
||
///============================================================================= | ||
/// Convert a rmw_qos_profile_t from a keyexpr. Return std::nullopt if invalid. | ||
|
@@ -227,6 +230,35 @@ std::optional<rmw_qos_profile_t> keyexpr_to_qos(const std::string & keyexpr); | |
///============================================================================= | ||
/// Convert a Zenoh id to a string. | ||
std::string zid_to_str(const z_id_t & id); | ||
|
||
///============================================================================= | ||
// Helper function to convert string to size_t. | ||
// The function is templated to enable conversion to size_t or std::size_t. | ||
template<typename T> | ||
std::optional<T> str_to_size_t(const std::string & str, const T default_value) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This whole function doesn't need to live in the header file; we can just keep it as an anonymous namespace function within |
||
{ | ||
if (str.empty()) { | ||
return default_value; | ||
} | ||
errno = 0; | ||
char * endptr; | ||
size_t num = strtoul(str.c_str(), &endptr, 10); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thinking about it more today, I realized two problems here:
I would say neither of those are blockers, but if you decide not to fix them I'd appreciate a TODO comment explaining what should be improved here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the feedback! I've left 1) as a TODO but addressed 2) with an |
||
if (endptr == str.c_str()) { | ||
// No values were converted, this is an error | ||
RMW_SET_ERROR_MSG("no valid numbers available"); | ||
return std::nullopt; | ||
} else if (*endptr != '\0') { | ||
// There was junk after the number | ||
RMW_SET_ERROR_MSG("non-numeric values"); | ||
return std::nullopt; | ||
} else if (errno != 0) { | ||
// Some other error occurred, which may include overflow or underflow | ||
RMW_SET_ERROR_MSG( | ||
"an undefined error occurred while getting the number, this may be an overflow"); | ||
return std::nullopt; | ||
} | ||
return num; | ||
} | ||
} // namespace liveliness | ||
} // namespace rmw_zenoh_cpp | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both of these can be moved back into
liveliness_utils.cpp
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops my bad dd44983