From f4a9872fe0ad13419be06b01049b628ba155b719 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Fri, 30 Aug 2024 19:45:08 -0500 Subject: [PATCH] [ox/std] Add StringParam --- deps/ox/src/ox/std/CMakeLists.txt | 1 + deps/ox/src/ox/std/std.hpp | 1 + deps/ox/src/ox/std/stringparam.hpp | 32 ++++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 deps/ox/src/ox/std/stringparam.hpp diff --git a/deps/ox/src/ox/std/CMakeLists.txt b/deps/ox/src/ox/std/CMakeLists.txt index 0c1ad783..890868a4 100644 --- a/deps/ox/src/ox/std/CMakeLists.txt +++ b/deps/ox/src/ox/std/CMakeLists.txt @@ -128,6 +128,7 @@ install( stringview.hpp strongint.hpp strconv.hpp + stringparam.hpp strops.hpp trace.hpp typeinfo.hpp diff --git a/deps/ox/src/ox/std/std.hpp b/deps/ox/src/ox/std/std.hpp index 85cbc879..8029f56c 100644 --- a/deps/ox/src/ox/std/std.hpp +++ b/deps/ox/src/ox/std/std.hpp @@ -46,6 +46,7 @@ #include "stddef.hpp" #include "string.hpp" #include "stringliteral.hpp" +#include "stringparam.hpp" #include "stringview.hpp" #include "strongint.hpp" #include "strops.hpp" diff --git a/deps/ox/src/ox/std/stringparam.hpp b/deps/ox/src/ox/std/stringparam.hpp new file mode 100644 index 00000000..a8505db7 --- /dev/null +++ b/deps/ox/src/ox/std/stringparam.hpp @@ -0,0 +1,32 @@ +/* + * Copyright 2015 - 2024 gary@drinkingtea.net + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#include "string.hpp" + +namespace ox { + +class StringParam { + private: + ox::String m_value; + public: + StringParam(StringParam const&) = delete; + constexpr StringParam(StringParam &&o) noexcept: m_value{std::move(o.m_value)} {} + constexpr StringParam(char const*value) noexcept: m_value{value} {} + constexpr StringParam(detail::BaseStringView const&value) noexcept: m_value{value} {} + constexpr StringParam(ox::String const&value) noexcept: m_value{value} {} + constexpr StringParam(ox::String &&value) noexcept: m_value{std::move(value)} {} + constexpr operator ox::String() && noexcept { return std::move(m_value); } + explicit constexpr operator ox::CStringView() const noexcept { return m_value; } + explicit constexpr operator ox::StringView() const noexcept { return m_value; } + [[nodiscard]] + constexpr ox::CStringView view() const noexcept { return m_value; } +}; + +}