Modulo 5.0.0
Loading...
Searching...
No Matches
parsing.hpp
1#pragma once
2
3#include <string>
4
5#include <rclcpp/rclcpp.hpp>
6
11namespace modulo_utils::parsing {
12
20[[maybe_unused]] static const std::string topic_validation_warning(const std::string& name, const std::string& type) {
21 return "The parsed signal name for " + type + " '" + name
22 + "' is empty. Provide a string with valid characters for the signal name ([a-z0-9_]).";
23}
24
31[[maybe_unused]] static std::string
32parse_node_name(const rclcpp::NodeOptions& options, const std::string& fallback = "") {
33 std::string node_name = fallback;
34 const std::string pattern("__node:=");
35 for (const auto& arg : options.arguments()) {
36 std::string::size_type index = arg.find(pattern);
37 if (index != std::string::npos) {
38 node_name = arg;
39 node_name.erase(index, pattern.length());
40 break;
41 }
42 }
43 return node_name;
44}
45
53[[maybe_unused]] static std::string parse_topic_name(const std::string& topic_name) {
54 std::string output;
55 for (char c : topic_name) {
56 if (c >= 'a' && c <= 'z') {
57 output.insert(output.end(), c);
58 } else if (!output.empty() && ((c >= '0' && c <= '9') || c == '_')) {
59 output.insert(output.end(), c);
60 }
61 }
62 return output;
63}
64
65}// namespace modulo_utils::parsing
Modulo parsing helpers.