diff --git a/core/include/gnuradio-4.0/Settings.hpp b/core/include/gnuradio-4.0/Settings.hpp index 2218cc951..4df099086 100644 --- a/core/include/gnuradio-4.0/Settings.hpp +++ b/core/include/gnuradio-4.0/Settings.hpp @@ -270,13 +270,7 @@ class BasicSettings : public SettingsBase { using RawType = std::remove_cvref_t; using Type = unwrap_if_wrapped_t; if constexpr (!traits::block::detail::is_port_or_collection() && !std::is_const_v && is_writable(member) && isSupportedType()) { - auto matchesIgnoringPrefix = [](std::string_view str, std::string_view prefix, std::string_view target) { - if (str.starts_with(prefix)) { - str.remove_prefix(prefix.size()); - } - return str == target; - }; - if (matchesIgnoringPrefix(default_tag.shortKey(), std::string_view(GR_TAG_PREFIX), get_display_name(member))) { + if (default_tag == get_display_name(member)) { _auto_forward.emplace(get_display_name(member)); } _auto_update.emplace(get_display_name(member)); diff --git a/core/include/gnuradio-4.0/Tag.hpp b/core/include/gnuradio-4.0/Tag.hpp index 2e39ee67c..9cd20f7ef 100644 --- a/core/include/gnuradio-4.0/Tag.hpp +++ b/core/include/gnuradio-4.0/Tag.hpp @@ -181,6 +181,38 @@ class DefaultTag { } }; +template +inline constexpr std::strong_ordering +operator<=>(const DefaultTag &dt, const TOtherString &str) noexcept { + if ((dt.shortKey() <=> str) == 0) { + return std::strong_ordering::equal; // shortKeys are equal + } else { + return dt.key() <=> str; // compare key() + } +} + +template +inline constexpr std::strong_ordering +operator<=>(const TOtherString &str, const DefaultTag &dt) noexcept { + if ((str <=> dt.shortKey()) == std::strong_ordering::equal) { + return std::strong_ordering::equal; // shortKeys are equal + } else { + return str <=> dt.key(); // compare key() + } +} + +template +inline constexpr bool +operator==(const DefaultTag &dt, const TOtherString &str) noexcept { + return (dt <=> std::string_view(str)) == 0; +} + +template +inline constexpr bool +operator==(const TOtherString &str, const DefaultTag &dt) noexcept { + return (std::string_view(str) <=> dt) == 0; +} + namespace tag { // definition of default tags and names inline EM_CONSTEXPR_STATIC DefaultTag<"sample_rate", float, "Hz", "signal sample rate"> SAMPLE_RATE; inline EM_CONSTEXPR_STATIC DefaultTag<"sample_rate", float, "Hz", "signal sample rate"> SIGNAL_RATE; diff --git a/core/include/gnuradio-4.0/reflection.hpp b/core/include/gnuradio-4.0/reflection.hpp index 7e63c2080..c3a619f8f 100644 --- a/core/include/gnuradio-4.0/reflection.hpp +++ b/core/include/gnuradio-4.0/reflection.hpp @@ -4,6 +4,7 @@ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-variable" #pragma GCC diagnostic ignored "-Wshadow" +#pragma GCC diagnostic ignored "-Wsign-conversion" #include /** diff --git a/core/test/qa_DynamicPort.cpp b/core/test/qa_DynamicPort.cpp index 9dddd6c15..a549f5b67 100644 --- a/core/test/qa_DynamicPort.cpp +++ b/core/test/qa_DynamicPort.cpp @@ -1,7 +1,5 @@ #include -#include - #include #include diff --git a/core/test/qa_Tags.cpp b/core/test/qa_Tags.cpp index de1d39754..1e7388ef9 100644 --- a/core/test/qa_Tags.cpp +++ b/core/test/qa_Tags.cpp @@ -51,6 +51,30 @@ const boost::ut::suite TagTests = [] { static_assert(tag::TRIGGER_NAME.shortKey() == "trigger_name"); static_assert(tag::TRIGGER_TIME.shortKey() == "trigger_time"); static_assert(tag::TRIGGER_OFFSET.shortKey() == "trigger_offset"); + + // test other tag on key definition only + static_assert(tag::SIGNAL_UNIT.key() == "gr:signal_unit"); + static_assert(tag::SIGNAL_MIN.key() == "gr:signal_min"); + static_assert(tag::SIGNAL_MAX.key() == "gr:signal_max"); + static_assert(tag::TRIGGER_NAME.key() == "gr:trigger_name"); + static_assert(tag::TRIGGER_TIME.key() == "gr:trigger_time"); + static_assert(tag::TRIGGER_OFFSET.key() == "gr:trigger_offset"); + + using namespace std::string_literals; + using namespace std::string_view_literals; + static_assert(tag::SIGNAL_UNIT == "signal_unit"s); + static_assert("signal_unit"s == tag::SIGNAL_UNIT); + + static_assert("signal_unit"sv == tag::SIGNAL_UNIT); + static_assert(tag::SIGNAL_UNIT == "signal_unit"sv); + + static_assert(tag::SIGNAL_UNIT == "signal_unit"); + static_assert("signal_unit" == tag::SIGNAL_UNIT); + + // alt definition -> eventually needed for SigMF compatibility + using namespace gr::tag; + static_assert(SIGNAL_UNIT == "gr:signal_unit"sv); + static_assert("gr:signal_unit" == tag::SIGNAL_UNIT); }; }; diff --git a/meta/include/gnuradio-4.0/meta/utils.hpp b/meta/include/gnuradio-4.0/meta/utils.hpp index fc8210899..2fd23e833 100644 --- a/meta/include/gnuradio-4.0/meta/utils.hpp +++ b/meta/include/gnuradio-4.0/meta/utils.hpp @@ -36,8 +36,8 @@ struct print_types; template struct fixed_string { - constexpr static std::size_t N = SIZE; - CharT _data[N + 1] = {}; + constexpr static std::size_t N = SIZE; + CharT _data[N + 1UZ] = {}; constexpr fixed_string() = default; @@ -78,6 +78,20 @@ struct fixed_string { operator==(const fixed_string &, const fixed_string &) { return false; } + + constexpr auto + operator<=>(const fixed_string &other) const noexcept + = default; + + friend constexpr auto + operator<=>(const fixed_string &fs, std::string_view sv) noexcept { + return std::string_view(fs) <=> sv; + } + + friend constexpr auto + operator<=>(const fixed_string &fs, const std::string &str) noexcept { + return std::string(fs) <=> str; + } }; template @@ -504,6 +518,9 @@ static_assert(std::is_same_v, int>); static_assert(std::is_same_v>, float>); static_assert(std::is_same_v>>, double>); +template +concept string_like = std::is_same_v || std::is_same_v || std::is_convertible_v; + } // namespace gr::meta #endif // include guard