diff --git a/engine/utils/url_parser.h b/engine/utils/url_parser.h index 55dd557b8..6a6e01179 100644 --- a/engine/utils/url_parser.h +++ b/engine/utils/url_parser.h @@ -7,11 +7,35 @@ #include "exceptions/malformed_url_exception.h" namespace url_parser { + +struct explicit_bool { + bool b = false; + template , bool> = true> + explicit_bool(T v) : b(v) {} + explicit_bool(explicit_bool const&) noexcept = default; + explicit_bool& operator=(explicit_bool const&) & noexcept = default; + explicit_bool() noexcept = default; + ~explicit_bool() noexcept = default; + bool operator!() const { return !b; } + explicit operator bool() const { return b; } +}; + +struct explicit_int { + int i = 0; + template , int> = true> + explicit_int(T v) : i(v) {} + explicit_int(explicit_int const&) noexcept = default; + explicit_int& operator=(explicit_int const&) & noexcept = default; + explicit_int() noexcept = default; + ~explicit_int() noexcept = default; + + explicit operator int() const { return i; } +}; struct Url { std::string protocol; std::string host; std::vector pathParams; - std::unordered_map> queries; + std::unordered_map> queries; std::string GetProtocolAndHost() const { return protocol + "://" + host; } @@ -102,10 +126,10 @@ inline std::string FromUrl(const Url& url) { std::string value_str; if (std::holds_alternative(value)) { value_str = std::get(value); - } else if (std::holds_alternative(value)) { - value_str = std::to_string(std::get(value)); - } else if (std::holds_alternative(value)) { - value_str = std::get(value) ? "true" : "false"; + } else if (std::holds_alternative(value)) { + value_str = std::to_string(int(std::get(value))); + } else if (std::holds_alternative(value)) { + value_str = std::get(value) ? "true" : "false"; } if (!query_string.empty()) { query_string += "&";