Skip to content

Commit

Permalink
charset: add method str()
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxKellermann committed Sep 6, 2024
1 parent 0c7c32b commit f2b886c
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/charset.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ utf8_to_locale(std::string_view src, std::span<char> buffer) noexcept;
*/
class Utf8ToLocale {
#ifdef HAVE_ICONV
const std::string value;
std::string value;
#else
const std::string_view value;
#endif
Expand Down Expand Up @@ -58,6 +58,14 @@ public:
const char *c_str() const noexcept {
return value.c_str();
}

std::string &&str() && noexcept {
return std::move(value);
}
#else
std::string str() && noexcept {
return std::string{value};
}
#endif
};

Expand All @@ -68,7 +76,7 @@ public:
*/
class LocaleToUtf8 {
#ifdef HAVE_ICONV
const std::string value;
std::string value;
#else
const std::string_view value;
#endif
Expand Down Expand Up @@ -96,6 +104,14 @@ public:
const char *c_str() const noexcept {
return value.c_str();
}

std::string &&str() && noexcept {
return std::move(value);
}
#else
std::string str() && noexcept {
return std::string{value};
}
#endif
};

Expand Down

0 comments on commit f2b886c

Please sign in to comment.