aboutsummaryrefslogtreecommitdiff
path: root/include/cru/common/String.hpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-01-08 21:17:56 +0800
committercrupest <crupest@outlook.com>2022-01-08 21:17:56 +0800
commit6b90be37d3ba7e094837bd01a19381bd59657041 (patch)
tree31bc841e7bc958e7ef31a3860321e8570bbef821 /include/cru/common/String.hpp
parent45ae34c5f31eca1258f6df278c9862ff829f39db (diff)
downloadcru-6b90be37d3ba7e094837bd01a19381bd59657041.tar.gz
cru-6b90be37d3ba7e094837bd01a19381bd59657041.tar.bz2
cru-6b90be37d3ba7e094837bd01a19381bd59657041.zip
...
Diffstat (limited to 'include/cru/common/String.hpp')
-rw-r--r--include/cru/common/String.hpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/include/cru/common/String.hpp b/include/cru/common/String.hpp
index 0ae223cf..8acb6a87 100644
--- a/include/cru/common/String.hpp
+++ b/include/cru/common/String.hpp
@@ -82,6 +82,8 @@ class CRU_BASE_API String {
String(std::initializer_list<value_type> l);
+ explicit String(StringView str);
+
#ifdef CRU_PLATFORM_WINDOWS
String(const wchar_t* str);
String(const wchar_t* str, Index size);
@@ -259,6 +261,7 @@ class CRU_BASE_API StringView {
~StringView() = default;
+ bool empty() const { return size_ == 0; }
Index size() const { return size_; }
const value_type* data() const { return ptr_; }
@@ -405,6 +408,8 @@ inline void String::append(StringView str) {
inline String String::From(StringView str) { return str.ToString(); }
+inline String::String(StringView str) : String(str.data(), str.size()) {}
+
inline String ToString(StringView value) { return value.ToString(); }
inline CodePoint Utf16PreviousCodePoint(StringView str, Index current,