[ox/std] Add StringParam
All checks were successful
Build / build (push) Successful in 2m32s

This commit is contained in:
Gary Talent 2024-08-30 19:45:08 -05:00
parent f8aa60e4c1
commit f4a9872fe0
3 changed files with 34 additions and 0 deletions

View File

@ -128,6 +128,7 @@ install(
stringview.hpp
strongint.hpp
strconv.hpp
stringparam.hpp
strops.hpp
trace.hpp
typeinfo.hpp

View File

@ -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"

32
deps/ox/src/ox/std/stringparam.hpp vendored Normal file
View File

@ -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; }
};
}