X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/e9ae1f101b5418c0ba2e6c9d86b23c12f0140982..59fa9c93d72d1e065274dadc44a53595fd54648a:/libs/srvconf/parsers/optional_utils.h diff --git a/libs/srvconf/parsers/optional_utils.h b/libs/srvconf/parsers/optional_utils.h index 9b6054bc..9cffc1ed 100644 --- a/libs/srvconf/parsers/optional_utils.h +++ b/libs/srvconf/parsers/optional_utils.h @@ -20,11 +20,11 @@ #pragma once -#include "stg/optional.h" #include "stg/common.h" #include #include +#include namespace STG { @@ -87,51 +87,51 @@ void appendAttr(std::ostream& stream, const std::string& name, const int template inline -void appendResetableTag(std::ostream& stream, const std::string& name, const T& value) +void appendResetableTag(std::ostream& stream, const std::string& name, const std::optional& value) { - if (!value.empty()) - appendTag(stream, name, value.const_data()); + if (value) + appendTag(stream, name, value.value()); } template inline -void appendResetableTag(std::ostream& stream, const std::string& name, size_t suffix, const T& value) +void appendResetableTag(std::ostream& stream, const std::string& name, size_t suffix, const std::optional& value) { - if (!value.empty()) - appendTag(stream, name, suffix, value.const_data()); + if (value) + appendTag(stream, name, suffix, value.value()); } template inline -void appendResetableAttr(std::ostream& stream, const std::string& name, const T& value) +void appendResetableAttr(std::ostream& stream, const std::string& name, const std::optional& value) { - if (!value.empty()) - appendAttr(stream, name, value.const_data()); + if (value) + appendAttr(stream, name, value.value()); } template inline -void appendResetableAttr(std::ostream& stream, const std::string& name, size_t suffix, const T& value) +void appendResetableAttr(std::ostream& stream, const std::string& name, size_t suffix, const std::optional& value) { - if (!value.empty()) - appendAttr(stream, name, suffix, value.const_data()); + if (value) + appendAttr(stream, name, suffix, value.value()); } inline -Optional maybeEncode(const Optional& value) +std::optional maybeEncode(const std::optional& value) { - Optional res; - if (!value.empty()) - res = Encode12str(value.data()); + std::optional res; + if (value) + res = Encode12str(value.value()); return res; } inline -Optional maybeIconv(const Optional& value, const std::string& fromEncoding, const std::string& toEncoding) +std::optional maybeIconv(const std::optional& value, const std::string& fromEncoding, const std::string& toEncoding) { - Optional res; - if (!value.empty()) - res = IconvString(value.data(), fromEncoding, toEncoding); + std::optional res; + if (value) + res = IconvString(value.value(), fromEncoding, toEncoding); return res; }