diff --git a/cpp_utils/include/cpp_utils/types/Fuzzy.hpp b/cpp_utils/include/cpp_utils/types/Fuzzy.hpp index c1662f27..fb11ce5a 100644 --- a/cpp_utils/include/cpp_utils/types/Fuzzy.hpp +++ b/cpp_utils/include/cpp_utils/types/Fuzzy.hpp @@ -173,6 +173,9 @@ class Fuzzy //! Get the Fuzzy Level internal value. FuzzyLevelType get_level() const noexcept; + //! Get the FuzzyLevel's internal value as a string. + std::string get_level_as_str() const noexcept; + ///////////////////////// // SET METHODS ///////////////////////// @@ -218,7 +221,8 @@ class Fuzzy //! \c Fuzzy to stream serializator template -CPP_UTILS_DllAPI std::ostream& operator <<( +CPP_UTILS_DllAPI +std::ostream& operator <<( std::ostream& os, const Fuzzy& f); diff --git a/cpp_utils/include/cpp_utils/types/impl/Fuzzy.ipp b/cpp_utils/include/cpp_utils/types/impl/Fuzzy.ipp index de425a22..a080f326 100644 --- a/cpp_utils/include/cpp_utils/types/impl/Fuzzy.ipp +++ b/cpp_utils/include/cpp_utils/types/impl/Fuzzy.ipp @@ -151,6 +151,42 @@ FuzzyLevelType Fuzzy::get_level() const noexcept return fuzzy_level_; } +template +std::string Fuzzy::get_level_as_str() const noexcept +{ + // Ideally, we would overload the << operator for FuzzyLevelType, but we can't since it's a namespace to a short. + std::string fuzzy_level; + + switch (fuzzy_level_) + { + case FuzzyLevelValues::fuzzy_level_unset: + fuzzy_level = "UNSET"; + break; + + case FuzzyLevelValues::fuzzy_level_default: + fuzzy_level = "DEFAULT"; + break; + + case FuzzyLevelValues::fuzzy_level_fuzzy: + fuzzy_level = "FUZZY"; + break; + + case FuzzyLevelValues::fuzzy_level_set: + fuzzy_level = "SET"; + break; + + case FuzzyLevelValues::fuzzy_level_hard: + fuzzy_level = "HARD"; + break; + + default: + // TODO: error? + break; + } + + return fuzzy_level; +} + ///////////////////////// // SET METHODS ///////////////////////// @@ -187,7 +223,7 @@ std::ostream& operator <<( std::ostream& os, const Fuzzy& f) { - os << "Fuzzy{Level(" << f.get_level() << ") " << f.get_reference() << "}"; + os << "Fuzzy{Level(" << f.get_level_as_str() << ") " << f.get_reference() << "}"; return os; }