Browse Source

settings: enumeration string from sv, not cstring

test/dev
Maxim Prokhorov 1 month ago
parent
commit
424e1930d2
2 changed files with 7 additions and 7 deletions
  1. +1
    -1
      code/espurna/settings_convert.h
  2. +6
    -6
      code/espurna/settings_helpers.h

+ 1
- 1
code/espurna/settings_convert.h View File

@ -176,7 +176,7 @@ String serialize(const Container& options, T value) {
for (auto it = std::begin(options); it != std::end(options); ++it) {
if ((*it).value() == value) {
out = FPSTR((*it).string());
out = (*it).string().toString();
break;
}
}


+ 6
- 6
code/espurna/settings_helpers.h View File

@ -222,7 +222,7 @@ private:
namespace options {
struct EnumerationNumericHelper {
static bool check(const String& value);
static bool check(const String&);
};
template <typename Value>
@ -262,7 +262,7 @@ struct alignas(8) Enumeration {
Enumeration() = delete;
constexpr Enumeration(ValueType value, const char* string) noexcept :
constexpr Enumeration(ValueType value, StringView string) noexcept :
_value(value),
_string(string)
{}
@ -275,17 +275,17 @@ struct alignas(8) Enumeration {
return static_cast<UnderlyingType>(_value);
}
constexpr const char* string() const {
constexpr StringView string() const {
return _string;
}
bool operator==(const String& string) const {
return strcmp_P(string.c_str(), _string) == 0;
bool operator==(StringView other) const {
return _string == other;
}
private:
ValueType _value;
const char* _string;
StringView _string;
};
} // namespace options


Loading…
Cancel
Save