From 6b98d8d69cdc2233586ff0e085d861559ed7b0ea Mon Sep 17 00:00:00 2001 From: danipiza Date: Fri, 16 Jan 2026 13:12:54 +0100 Subject: [PATCH 1/3] [#24061] Updated read_next_command() for the new FastDDS-Spy filter Signed-off-by: danipiza --- .../user_interface/CommandReader.hpp | 3 ++ .../user_interface/impl/CommandReader.ipp | 36 +++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/cpp_utils/include/cpp_utils/user_interface/CommandReader.hpp b/cpp_utils/include/cpp_utils/user_interface/CommandReader.hpp index f73a7aed..b04bf35a 100644 --- a/cpp_utils/include/cpp_utils/user_interface/CommandReader.hpp +++ b/cpp_utils/include/cpp_utils/user_interface/CommandReader.hpp @@ -94,6 +94,9 @@ class CommandReader void read_command_callback_( std::string command_read); + std::vector join_quoted_strings( + const std::vector& input); + //! Builder to transform string into a command enum value. EnumBuilder builder_; diff --git a/cpp_utils/include/cpp_utils/user_interface/impl/CommandReader.ipp b/cpp_utils/include/cpp_utils/user_interface/impl/CommandReader.ipp index 443ac811..6ed2f514 100644 --- a/cpp_utils/include/cpp_utils/user_interface/impl/CommandReader.ipp +++ b/cpp_utils/include/cpp_utils/user_interface/impl/CommandReader.ipp @@ -45,13 +45,45 @@ bool CommandReader::read_next_command( std::string full_command = commands_read_.consume(); // Divide command - command.arguments = utils::split_string(full_command, " "); - + command.arguments = join_quoted_strings(utils::split_string(full_command, " ")); // Check if command exists // The args are already set in command, and the enum value will be set string_to_enumeration return builder_.string_to_enumeration(command.arguments[0], command.command); } +template +std::vector CommandReader::join_quoted_strings( + const std::vector& input) +{ + std::vector result; + + for (size_t i = 0; i < input.size(); ++i) + { + // Check if string starts with a quote + if (!input[i].empty() && input[i].front() == '"') + { + std::string joined = input[i]; + + // Keep joining until we find a string ending with a quote + while (i + 1 < input.size() && + (joined.empty() || joined.back() != '"')) + { + joined += " " + input[++i]; + } + + result.push_back(joined.substr(1, joined.size() - 2)); + } + else + { + result.push_back(input[i]); + } + } + + return result; +} + + + template void CommandReader::read_command_callback_( std::string command_read) From fa0f1e0198f6073634a87c362a6e741c860ff216 Mon Sep 17 00:00:00 2001 From: danipiza Date: Thu, 22 Jan 2026 10:39:56 +0100 Subject: [PATCH 2/3] [#24061] Uncrustify Signed-off-by: danipiza --- .../user_interface/impl/CommandReader.ipp | 124 +++++++++--------- 1 file changed, 62 insertions(+), 62 deletions(-) diff --git a/cpp_utils/include/cpp_utils/user_interface/impl/CommandReader.ipp b/cpp_utils/include/cpp_utils/user_interface/impl/CommandReader.ipp index 6ed2f514..ba0db4a2 100644 --- a/cpp_utils/include/cpp_utils/user_interface/impl/CommandReader.ipp +++ b/cpp_utils/include/cpp_utils/user_interface/impl/CommandReader.ipp @@ -17,81 +17,81 @@ #include namespace eprosima { -namespace utils { - -template -CommandReader::CommandReader( - const EnumBuilder& builder, - std::istream& source /* = std::cin */) - : builder_(builder) - , stdin_handler_( - [this](std::string st) + namespace utils { + + template < typename CommandEnum > + CommandReader < CommandEnum > ::CommandReader( + const EnumBuilder < CommandEnum > &builder, + std::istream& source /* = std::cin */) + : builder_(builder) + , stdin_handler_( + [this](std::string st) { this->read_command_callback_(st); }, - true, - 0, - source) - , commands_read_(0, true) -{ - // Do nothing -} - -template -bool CommandReader::read_next_command( - Command& command) -{ - stdin_handler_.read_one_more_line(); - std::string full_command = commands_read_.consume(); - - // Divide command - command.arguments = join_quoted_strings(utils::split_string(full_command, " ")); - // Check if command exists - // The args are already set in command, and the enum value will be set string_to_enumeration - return builder_.string_to_enumeration(command.arguments[0], command.command); -} - -template -std::vector CommandReader::join_quoted_strings( - const std::vector& input) -{ - std::vector result; - - for (size_t i = 0; i < input.size(); ++i) - { - // Check if string starts with a quote - if (!input[i].empty() && input[i].front() == '"') + true, + 0, + source) + , commands_read_(0, true) { - std::string joined = input[i]; + // Do nothing + } + + template < typename CommandEnum > + bool CommandReader < CommandEnum > ::read_next_command( + Command < CommandEnum > &command) + { + stdin_handler_.read_one_more_line(); + std::string full_command = commands_read_.consume(); + + // Divide command + command.arguments = join_quoted_strings(utils::split_string(full_command, " ")); + // Check if command exists + // The args are already set in command, and the enum value will be set string_to_enumeration + return builder_.string_to_enumeration(command.arguments[0], command.command); + } + + template < typename CommandEnum > + std::vector < std::string > CommandReader < CommandEnum > ::join_quoted_strings( + const std::vector < std::string > &input) + { + std::vector < std::string > result; - // Keep joining until we find a string ending with a quote - while (i + 1 < input.size() && - (joined.empty() || joined.back() != '"')) + for (size_t i = 0; i < input.size(); ++i) { - joined += " " + input[++i]; + // Check if string starts with a quote + if (!input[i].empty() && input[i].front() == '"') + { + std::string joined = input[i]; + + // Keep joining until we find a string ending with a quote + while (i + 1 < input.size() && + (joined.empty() || joined.back() != '"')) + { + joined += " " + input[++i]; + } + + result.push_back(joined.substr(1, joined.size() - 2)); + } + else + { + result.push_back(input[i]); + } } - result.push_back(joined.substr(1, joined.size() - 2)); + return result; } - else - { - result.push_back(input[i]); - } - } - - return result; -} -template -void CommandReader::read_command_callback_( - std::string command_read) -{ - commands_read_.produce(command_read); -} + template < typename CommandEnum > + void CommandReader < CommandEnum > ::read_command_callback_( + std::string command_read) + { + commands_read_.produce(command_read); + } -} /* namespace utils */ + } /* namespace utils */ } /* namespace eprosima */ // Include implementation template file From 87b881293fe26306bb843ed1e85fc9a4625b1787 Mon Sep 17 00:00:00 2001 From: danipiza Date: Fri, 23 Jan 2026 13:08:26 +0100 Subject: [PATCH 3/3] [#24061] New uncrustify Signed-off-by: danipiza --- .../user_interface/CommandReader.hpp | 6 +- .../user_interface/impl/CommandReader.ipp | 124 +++++++++--------- 2 files changed, 64 insertions(+), 66 deletions(-) diff --git a/cpp_utils/include/cpp_utils/user_interface/CommandReader.hpp b/cpp_utils/include/cpp_utils/user_interface/CommandReader.hpp index b04bf35a..1544c94f 100644 --- a/cpp_utils/include/cpp_utils/user_interface/CommandReader.hpp +++ b/cpp_utils/include/cpp_utils/user_interface/CommandReader.hpp @@ -26,7 +26,7 @@ namespace utils { * * @tparam CommandEnum enumeration that represent the different commands available. */ -template +template struct Command { //! Command in the way of a enumeration class. @@ -48,7 +48,7 @@ struct Command * * @note This class relies on \c StdinEventHandler to read from stdin and in \c EnumBuilder to interpret command. */ -template +template class CommandReader { public: @@ -121,7 +121,7 @@ class CommandReader }; -} /* namespace utils */ +} /* namespace utils */ } /* namespace eprosima */ // Include implementation template file diff --git a/cpp_utils/include/cpp_utils/user_interface/impl/CommandReader.ipp b/cpp_utils/include/cpp_utils/user_interface/impl/CommandReader.ipp index ba0db4a2..b2e42343 100644 --- a/cpp_utils/include/cpp_utils/user_interface/impl/CommandReader.ipp +++ b/cpp_utils/include/cpp_utils/user_interface/impl/CommandReader.ipp @@ -17,81 +17,79 @@ #include namespace eprosima { - namespace utils { - - template < typename CommandEnum > - CommandReader < CommandEnum > ::CommandReader( - const EnumBuilder < CommandEnum > &builder, - std::istream& source /* = std::cin */) - : builder_(builder) - , stdin_handler_( - [this](std::string st) +namespace utils { + +template +CommandReader::CommandReader( + const EnumBuilder& builder, + std::istream& source /* = std::cin */) + : builder_(builder) + , stdin_handler_( + [this](std::string st) { this->read_command_callback_(st); }, - true, - 0, - source) - , commands_read_(0, true) - { - // Do nothing - } - - template < typename CommandEnum > - bool CommandReader < CommandEnum > ::read_next_command( - Command < CommandEnum > &command) - { - stdin_handler_.read_one_more_line(); - std::string full_command = commands_read_.consume(); - - // Divide command - command.arguments = join_quoted_strings(utils::split_string(full_command, " ")); - // Check if command exists - // The args are already set in command, and the enum value will be set string_to_enumeration - return builder_.string_to_enumeration(command.arguments[0], command.command); - } - - template < typename CommandEnum > - std::vector < std::string > CommandReader < CommandEnum > ::join_quoted_strings( - const std::vector < std::string > &input) + true, + 0, + source) + , commands_read_(0, true) +{ + // Do nothing +} + +template +bool CommandReader::read_next_command( + Command& command) +{ + stdin_handler_.read_one_more_line(); + std::string full_command = commands_read_.consume(); + + // Divide command + command.arguments = join_quoted_strings(utils::split_string(full_command, " ")); + // Check if command exists + // The args are already set in command, and the enum value will be set string_to_enumeration + return builder_.string_to_enumeration(command.arguments[0], command.command); +} + +template +std::vector CommandReader::join_quoted_strings( + const std::vector& input) +{ + std::vector result; + + for (size_t i = 0; i < input.size(); ++i) + { + // Check if string starts with a quote + if (!input[i].empty() && input[i].front() == '"') { - std::vector < std::string > result; + std::string joined = input[i]; - for (size_t i = 0; i < input.size(); ++i) + // Keep joining until we find a string ending with a quote + while (i + 1 < input.size() && + (joined.empty() || joined.back() != '"')) { - // Check if string starts with a quote - if (!input[i].empty() && input[i].front() == '"') - { - std::string joined = input[i]; - - // Keep joining until we find a string ending with a quote - while (i + 1 < input.size() && - (joined.empty() || joined.back() != '"')) - { - joined += " " + input[++i]; - } - - result.push_back(joined.substr(1, joined.size() - 2)); - } - else - { - result.push_back(input[i]); - } + joined += " " + input[++i]; } - return result; + result.push_back(joined.substr(1, joined.size() - 2)); } - - - - template < typename CommandEnum > - void CommandReader < CommandEnum > ::read_command_callback_( - std::string command_read) + else { - commands_read_.produce(command_read); + result.push_back(input[i]); } + } + + return result; +} + +template +void CommandReader::read_command_callback_( + std::string command_read) +{ + commands_read_.produce(command_read); +} - } /* namespace utils */ +} /* namespace utils */ } /* namespace eprosima */ // Include implementation template file