44
55namespace pe ::core::storage
66{
7-
8- CORE_DLLEXPORT size_t StrLen (const char * str);
9-
107 class CORE_DLLEXPORT String final : public BaseObjectLiteralType<>
118 {
129 public:
@@ -17,17 +14,20 @@ namespace pe::core::storage
1714
1815 // / <summary>String constructor that creates String based on provided Cstring</summary>
1916 // / <param name="data"></param>
20- String (const char * data);
17+ String (const char * str) : String(std::string_view(str)) {}
18+
19+ // / <summary>String constructor that creates String based on provided string_view</summary>
20+ // / <param name="data"></param>
21+ explicit String (std::string_view str);
2122
2223 // / <summary>String copy constructor</summary>
2324 // / <param name="rhs">Reference to String instance which state should be copied</param>
24- String (const String& rhs);
25+ explicit String (const String& rhs);
2526
2627 // / <summary>String move constructor</summary>
2728 // / <param name="rhs">Reference to String instance which state should be moved</param>
2829 String (String&& rhs);
2930
30-
3131 // / <summary>Casts int to String</summary>
3232 // / <param name="var">Integer value which should be used to make String instance</param>
3333 // / <returns>String containing integer value</returns>
@@ -62,15 +62,10 @@ namespace pe::core::storage
6262 // / <returns>String conaining only one char</returns>
6363 static String From (char var);
6464
65- // / <summary>Casts Cstring to String</summary>
66- // / <param name="var">Cstring value which should be used to make String instance</param>
67- // / <returns>String containing given Cstring</returns>
68- static String From (const char * var);
69-
70- // / <summary>Casts std::string to String</summary>
71- // / <param name="var">std::string reference which should be used to make String instance</param>
72- // / <returns>String containing given std::string</returns>
73- static String From (const std::string& var);
65+ // / <summary>Casts string_view to String</summary>
66+ // / <param name="var">string_view value which should be used to make String instance</param>
67+ // / <returns>String containing given content</returns>
68+ static String From (std::string_view str);
7469
7570
7671 // / <summary>Checks if String instance contains another String instance</summary>
@@ -164,18 +159,12 @@ namespace pe::core::storage
164159 // / <returns>Moved String reference</returns>
165160 String& operator =(String&& rhs);
166161
167- // / <summary>Compares String with Cstring</summary>
168- // / <param name="str">Cstring to be compared with</param>
169- bool operator ==(const char * str) const ;
170-
171- // / <summary>Compares two String references</summary>
172- // / <param name="str">String to be compared with</param>
173- bool operator ==(const String& str) const ;
174-
175- bool operator !=(const char * str) const { return !(*this == str); }
176- bool operator !=(const String& str) const { return !(*this == str); }
162+ // / <summary>Compares String with string_view</summary>
163+ // / <param name="str">string_view to be compared with</param>
164+ bool operator ==(std::string_view str) const ;
165+ bool operator !=(std::string_view str) const { return !(*this == str); }
177166
178- bool operator <(const String& rhs) const ;
167+ bool operator <(std::string_view rhs) const ;
179168
180169 // / <summary>Appends one String to another</summary>
181170 // / <param name="rhs">String instance to be appended to source String</param>
@@ -197,6 +186,7 @@ namespace pe::core::storage
197186
198187 friend std::ostream& operator << (std::ostream& stream, const String& rhs) { return stream << rhs.GetCStr (); }
199188
189+ operator std::string_view () const { return std::string_view (GetCStr ()); }
200190 private:
201191
202192 String (std::vector<char > rawData) : Data(std::move(rawData)) { Data.push_back (' \0 ' ); }
0 commit comments