summaryrefslogtreecommitdiff
path: root/include/fud_string_view.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/fud_string_view.hpp')
-rw-r--r--include/fud_string_view.hpp16
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};
};