From dd2d8eb694a7559dbd60e8fdc331668c6c348b7d Mon Sep 17 00:00:00 2001 From: Michel Hidalgo Date: Sat, 18 May 2019 12:35:28 -0300 Subject: [PATCH] Include 'srv' in service type namespace. Signed-off-by: Michel Hidalgo --- rmw_connext_shared_cpp/src/demangle.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/rmw_connext_shared_cpp/src/demangle.cpp b/rmw_connext_shared_cpp/src/demangle.cpp index 9781adf0..25aa7cda 100644 --- a/rmw_connext_shared_cpp/src/demangle.cpp +++ b/rmw_connext_shared_cpp/src/demangle.cpp @@ -97,7 +97,7 @@ _demangle_service_from_topic(const std::string & topic_name) std::string _demangle_service_type_only(const std::string & dds_type_name) { - std::string ns_substring = "::srv::dds_::"; + std::string ns_substring = "dds_::"; size_t ns_substring_position = dds_type_name.find(ns_substring); if (ns_substring_position == std::string::npos) { // not a ROS service type @@ -114,7 +114,7 @@ _demangle_service_type_only(const std::string & dds_type_name) if (suffix_position != std::string::npos) { if (dds_type_name.length() - suffix_position - suffix.length() != 0) { RCUTILS_LOG_WARN_NAMED("rmw_connext_shared_cpp", - "service type contains '::srv::dds_::' and a suffix, but not at the end" + "service type contains 'dds_::' and a suffix, but not at the end" ", report this: '%s'", dds_type_name.c_str()); continue; } @@ -124,13 +124,15 @@ _demangle_service_type_only(const std::string & dds_type_name) } if (suffix_position == std::string::npos) { RCUTILS_LOG_WARN_NAMED("rmw_connext_shared_cpp", - "service type contains '::srv::dds_::' but does not have a suffix" + "service type contains 'dds_::' but does not have a suffix" ", report this: '%s'", dds_type_name.c_str()); return ""; } - // everything checks out, reformat it from '::srv::dds_::' to '/' - std::string pkg = dds_type_name.substr(0, ns_substring_position); + // everything checks out, reformat it from '::dds_::' + // to '/' + std::string type_namespace = dds_type_name.substr(0, ns_substring_position); + type_namespace = std::regex_replace(type_namespace, std::regex("::"), "/"); size_t start = ns_substring_position + ns_substring.length(); std::string type_name = dds_type_name.substr(start, suffix_position - start); - return pkg + "/" + type_name; + return type_namespace + type_name; }