Implement no_demangle in various get_... functions

Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
Erik Boasson 2019-08-21 14:29:52 +02:00 committed by eboasson
parent eb2d17c066
commit 8844880edd

View file

@ -2242,7 +2242,7 @@ static rmw_ret_t get_endpoint_names_and_types_by_node(
std::regex("^" + std::string(ros_topic_prefix) + "(/.*)", std::regex::extended); std::regex("^" + std::string(ros_topic_prefix) + "(/.*)", std::regex::extended);
const auto re_typ = std::regex("^(.*::)dds_::(.*)_$", std::regex::extended); const auto re_typ = std::regex("^(.*::)dds_::(.*)_$", std::regex::extended);
const auto filter_and_map = const auto filter_and_map =
[re_tp, re_typ, guids, node_name](const dds_builtintopic_endpoint_t & sample, [re_tp, re_typ, guids, node_name, no_demangle](const dds_builtintopic_endpoint_t & sample,
std::string & topic_name, std::string & type_name) -> bool { std::string & topic_name, std::string & type_name) -> bool {
std::cmatch cm_tp, cm_typ; std::cmatch cm_tp, cm_typ;
if (node_name != nullptr && guids.count(sample.participant_key) == 0) { if (node_name != nullptr && guids.count(sample.participant_key) == 0) {
@ -2252,11 +2252,15 @@ static rmw_ret_t get_endpoint_names_and_types_by_node(
re_tp) || !std::regex_search(sample.type_name, cm_typ, re_typ)) re_tp) || !std::regex_search(sample.type_name, cm_typ, re_typ))
{ {
return false; return false;
} else {
topic_name = std::string(cm_tp[1]);
if (no_demangle) {
type_name = std::string(type_name);
} else { } else {
std::string demangled_type = std::regex_replace(std::string(cm_typ[1]), std::regex( std::string demangled_type = std::regex_replace(std::string(cm_typ[1]), std::regex(
"::"), "/"); "::"), "/");
topic_name = std::string(cm_tp[1]);
type_name = std::string(demangled_type) + std::string(cm_typ[2]); type_name = std::string(demangled_type) + std::string(cm_typ[2]);
}
return true; return true;
} }
} }