17 using artifacts = std::variant<std::monostate, std::string, std::string_view, char*>;
22 [[nodiscard]] artifacts
get() const noexcept {
return buffer; }
28 if (
const auto *sv = std::get_if<std::string_view>(&anything); sv !=
nullptr)
30 buffer = std::string{*sv};
34 if (
const auto *cstr = std::get_if<char *>(&anything); cstr !=
nullptr)
36 buffer = *cstr ? std::string{*cstr} : std::string{};
40 buffer = std::move(anything);
46 bool set(
const std::string_view sv)
noexcept
57 return std::visit([](
const auto& value) ->
bool
59 using T = std::decay_t<
decltype(value)>;
60 if constexpr (std::is_same_v<T, std::monostate>)
64 else if constexpr (std::is_same_v<T, std::string> || std::is_same_v<T, std::string_view>)
66 return !value.empty();
68 else if constexpr (std::is_same_v<T, char*>)
70 return value !=
nullptr && *value !=
'\0';
79 static std::string to_string(
const artifacts& artifact)
noexcept
81 return std::visit([](
const auto& value) -> std::string
83 using T = std::decay_t<
decltype(value)>;
84 if constexpr (std::is_same_v<T, std::monostate>)
88 else if constexpr (std::is_same_v<T, std::string>)
92 else if constexpr (std::is_same_v<T, std::string_view>)
94 return std::string{value};
96 else if constexpr (std::is_same_v<T, char*>)
98 return value ? std::string{value} : std::string{};
Class for managing processed text resources.
Definition processed_text.h:15
artifacts get() const noexcept
Gets the processed artifact.
Definition processed_text.h:22
bool set(const std::string_view sv) noexcept
Sets the processed artifact from a string view.
Definition processed_text.h:46
void set_processed(artifacts anything) noexcept
Sets the processed artifact.
Definition processed_text.h:26
bool is_processed() const noexcept
Checks if the processed artifact is finalized - empty or null.
Definition processed_text.h:55