diff options
author | Dominick Allen <djallen@librehumanitas.org> | 2024-10-18 21:43:44 -0500 |
---|---|---|
committer | Dominick Allen <djallen@librehumanitas.org> | 2024-10-18 21:43:44 -0500 |
commit | e94db4695e236b42ae1be44b2605075161d5144f (patch) | |
tree | ada1a0442abdd08375df7f9a8f9cd50924e0840a /include/fud_string_view.hpp | |
parent | 8249b28bea29e8ce17eac12776a60ec3f9e47176 (diff) |
Add temporary work for formatting.
Diffstat (limited to 'include/fud_string_view.hpp')
-rw-r--r-- | include/fud_string_view.hpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/include/fud_string_view.hpp b/include/fud_string_view.hpp index 4796003..7b4925e 100644 --- a/include/fud_string_view.hpp +++ b/include/fud_string_view.hpp @@ -15,23 +15,27 @@ * limitations under the License. */ - #ifndef FUD_STRING_VIEW_HPP #define FUD_STRING_VIEW_HPP #include "fud_status.hpp" #include "fud_utf8.hpp" +#include <string_view> + namespace fud { class String; -class StringView { - public: +struct StringView { constexpr StringView() noexcept = default; + constexpr StringView(const StringView& rhs) noexcept = default; + constexpr StringView(StringView&& rhs) noexcept = default; + constexpr ~StringView() noexcept = default; + constexpr StringView& operator=(const StringView& rhs) = default; constexpr StringView& operator=(StringView&& rhs) = default; @@ -40,11 +44,13 @@ class StringView { } StringView(size_t strLen, const char* strData) : - m_length(strLen), // line break + m_length(strLen), // line break m_data{reinterpret_cast<const utf8*>(strData)} // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast) { } + StringView(std::string_view rhs) noexcept : StringView(rhs.length(), rhs.data()) {} + explicit StringView(const String& fudString) noexcept; [[nodiscard]] constexpr size_t length() const @@ -85,8 +91,8 @@ class StringView { FudStatus toDouble(double& number, size_t& strLen) const; - private: size_t m_length{0}; + const utf8* m_data{nullptr}; }; |