From f32117549d2e88b311f3fc7d2cd936a2c21887ea Mon Sep 17 00:00:00 2001 From: Davide Faconti Date: Thu, 1 Feb 2024 19:06:08 +0100 Subject: [PATCH] bug fix --- data_tamer_cpp/include/data_tamer/channel.hpp | 9 +++------ .../include/data_tamer_parser/data_tamer_parser.hpp | 4 ++-- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/data_tamer_cpp/include/data_tamer/channel.hpp b/data_tamer_cpp/include/data_tamer/channel.hpp index 63ad3f1..3a76094 100644 --- a/data_tamer_cpp/include/data_tamer/channel.hpp +++ b/data_tamer_cpp/include/data_tamer/channel.hpp @@ -54,7 +54,7 @@ class LoggedValue * @param value new value * @param auto_enable if true and the current instance is disabled, call setEnabled(true) */ - void set(const T& value, bool auto_enable = false); + void set(const T& value, bool auto_enable = true); /// @brief get the stored value. [[nodiscard]] T get(); @@ -416,7 +416,7 @@ inline void LoggedValue::set(const T& val, bool auto_enable) if (auto channel = channel_.lock()) { value_ = val; - if (auto_enable) + if (!enabled_ && auto_enable) { channel->setEnabled(id_, true); enabled_ = true; @@ -425,10 +425,7 @@ inline void LoggedValue::set(const T& val, bool auto_enable) else { value_ = val; - if (!enabled_ && auto_enable) - { - enabled_ = true; - } + enabled_ |= auto_enable; } } diff --git a/data_tamer_cpp/include/data_tamer_parser/data_tamer_parser.hpp b/data_tamer_cpp/include/data_tamer_parser/data_tamer_parser.hpp index 94b0737..2c680cf 100644 --- a/data_tamer_cpp/include/data_tamer_parser/data_tamer_parser.hpp +++ b/data_tamer_cpp/include/data_tamer_parser/data_tamer_parser.hpp @@ -219,11 +219,11 @@ bool TypeField::operator==(const TypeField& other) const inline Schema BuilSchemaFromText(const std::string& txt) { auto trimString = [](std::string& str) { - while (str.back() == ' ' || str.back() == '\r') + while (!str.empty() && (str.back() == ' ' || str.back() == '\r')) { str.pop_back(); } - while (str.front() == ' ' || str.front() == '\r') + while (!str.empty() && (str.front() == ' ' || str.front() == '\r')) { str.erase(0, 1); }