|
@@ -3,7 +3,7 @@
|
|
* Company: Lynar Studios
|
|
* Company: Lynar Studios
|
|
* E-Mail: webmaster@lynarstudios.com
|
|
* E-Mail: webmaster@lynarstudios.com
|
|
* Created: 2020-08-14
|
|
* Created: 2020-08-14
|
|
- * Changed: 2023-02-23
|
|
|
|
|
|
+ * Changed: 2023-05-17
|
|
*
|
|
*
|
|
* */
|
|
* */
|
|
|
|
|
|
@@ -16,6 +16,7 @@ using ls::std::core::type::byte_type;
|
|
using std::move;
|
|
using std::move;
|
|
using std::reverse;
|
|
using std::reverse;
|
|
using std::string;
|
|
using std::string;
|
|
|
|
+using std::string_view;
|
|
using std::transform;
|
|
using std::transform;
|
|
using std::vector;
|
|
using std::vector;
|
|
|
|
|
|
@@ -50,7 +51,7 @@ string String::operator+(const char *_string) const
|
|
return this->value + _string;
|
|
return this->value + _string;
|
|
}
|
|
}
|
|
|
|
|
|
-string String::operator-(int _number)
|
|
|
|
|
|
+string String::operator-(int _number) const
|
|
{
|
|
{
|
|
string copy = this->value;
|
|
string copy = this->value;
|
|
return copy.substr(0, copy.size() - _number);
|
|
return copy.substr(0, copy.size() - _number);
|
|
@@ -68,39 +69,39 @@ String &String::operator+=(const string &_text)
|
|
return *this;
|
|
return *this;
|
|
}
|
|
}
|
|
|
|
|
|
-bool String::operator==(String _string)
|
|
|
|
|
|
+bool String::operator==(String _string) const
|
|
{
|
|
{
|
|
return this->value == _string.toString();
|
|
return this->value == _string.toString();
|
|
}
|
|
}
|
|
|
|
|
|
-bool String::operator==(const string &_value)
|
|
|
|
|
|
+bool String::operator==(string_view _value) const
|
|
{
|
|
{
|
|
return this->value == _value;
|
|
return this->value == _value;
|
|
}
|
|
}
|
|
|
|
|
|
-bool String::operator==(const char *_value)
|
|
|
|
|
|
+bool String::operator==(const char *_value) const
|
|
{
|
|
{
|
|
return this->value == _value;
|
|
return this->value == _value;
|
|
}
|
|
}
|
|
|
|
|
|
-bool String::operator!=(String _string)
|
|
|
|
|
|
+bool String::operator!=(String _string) const
|
|
{
|
|
{
|
|
return this->value != _string.toString();
|
|
return this->value != _string.toString();
|
|
}
|
|
}
|
|
|
|
|
|
-bool String::operator!=(const string &_value)
|
|
|
|
|
|
+bool String::operator!=(string_view _value) const
|
|
{
|
|
{
|
|
return this->value != _value;
|
|
return this->value != _value;
|
|
}
|
|
}
|
|
|
|
|
|
-bool String::operator!=(const char *_value)
|
|
|
|
|
|
+bool String::operator!=(const char *_value) const
|
|
{
|
|
{
|
|
return this->value != _value;
|
|
return this->value != _value;
|
|
}
|
|
}
|
|
|
|
|
|
-void String::parse(string _parseText)
|
|
|
|
|
|
+void String::parse(const string &_parseText)
|
|
{
|
|
{
|
|
- this->value = ::move(_parseText);
|
|
|
|
|
|
+ this->value = _parseText;
|
|
}
|
|
}
|
|
|
|
|
|
string String::toString()
|
|
string String::toString()
|
|
@@ -108,22 +109,22 @@ string String::toString()
|
|
return this->value;
|
|
return this->value;
|
|
}
|
|
}
|
|
|
|
|
|
-bool String::contains(const string &_text)
|
|
|
|
|
|
+bool String::contains(string_view _text) const
|
|
{
|
|
{
|
|
return this->value.find(_text) != string::npos;
|
|
return this->value.find(_text) != string::npos;
|
|
}
|
|
}
|
|
|
|
|
|
-bool String::endsWith(const string &_text)
|
|
|
|
|
|
+bool String::endsWith(string_view _text) const
|
|
{
|
|
{
|
|
return this->value.rfind(_text) == (this->value.size() - _text.size());
|
|
return this->value.rfind(_text) == (this->value.size() - _text.size());
|
|
}
|
|
}
|
|
|
|
|
|
-bool String::equalsIgnoreCase(String _string)
|
|
|
|
|
|
+bool String::equalsIgnoreCase(const String &_string) const
|
|
{
|
|
{
|
|
return this->toLowerCase() == _string.toLowerCase();
|
|
return this->toLowerCase() == _string.toLowerCase();
|
|
}
|
|
}
|
|
|
|
|
|
-bool String::equalsIgnoreCase(string _text)
|
|
|
|
|
|
+bool String::equalsIgnoreCase(string _text) const
|
|
{
|
|
{
|
|
return this->toLowerCase() == String{::move(_text)}.toLowerCase();
|
|
return this->toLowerCase() == String{::move(_text)}.toLowerCase();
|
|
}
|
|
}
|
|
@@ -136,17 +137,17 @@ vector<byte_type> String::getByteData()
|
|
return byteData;
|
|
return byteData;
|
|
}
|
|
}
|
|
|
|
|
|
-string String::padLeft(size_t _width, const char _fillCharacter)
|
|
|
|
|
|
+string String::padLeft(size_t _width, const char _fillCharacter) const
|
|
{
|
|
{
|
|
return String::_createFillContent(this->value, _width, _fillCharacter) + this->value;
|
|
return String::_createFillContent(this->value, _width, _fillCharacter) + this->value;
|
|
}
|
|
}
|
|
|
|
|
|
-string String::padRight(size_t _width, const char _fillCharacter)
|
|
|
|
|
|
+string String::padRight(size_t _width, const char _fillCharacter) const
|
|
{
|
|
{
|
|
return this->value + String::_createFillContent(this->value, _width, _fillCharacter);
|
|
return this->value + String::_createFillContent(this->value, _width, _fillCharacter);
|
|
}
|
|
}
|
|
|
|
|
|
-string String::reverse()
|
|
|
|
|
|
+string String::reverse() const
|
|
{
|
|
{
|
|
string copy = this->value;
|
|
string copy = this->value;
|
|
::reverse(copy.begin(), copy.end());
|
|
::reverse(copy.begin(), copy.end());
|
|
@@ -154,12 +155,12 @@ string String::reverse()
|
|
return copy;
|
|
return copy;
|
|
}
|
|
}
|
|
|
|
|
|
-bool String::startsWith(const string &_text)
|
|
|
|
|
|
+bool String::startsWith(string_view _text) const
|
|
{
|
|
{
|
|
return this->value.rfind(_text, 0) == 0;
|
|
return this->value.rfind(_text, 0) == 0;
|
|
}
|
|
}
|
|
|
|
|
|
-string String::toLowerCase()
|
|
|
|
|
|
+string String::toLowerCase() const
|
|
{
|
|
{
|
|
string copy = this->value;
|
|
string copy = this->value;
|
|
transform(copy.begin(), copy.end(), copy.begin(), ::tolower);
|
|
transform(copy.begin(), copy.end(), copy.begin(), ::tolower);
|
|
@@ -167,7 +168,7 @@ string String::toLowerCase()
|
|
return copy;
|
|
return copy;
|
|
}
|
|
}
|
|
|
|
|
|
-string String::toUpperCase()
|
|
|
|
|
|
+string String::toUpperCase() const
|
|
{
|
|
{
|
|
string copy = this->value;
|
|
string copy = this->value;
|
|
transform(copy.begin(), copy.end(), copy.begin(), ::toupper);
|
|
transform(copy.begin(), copy.end(), copy.begin(), ::toupper);
|
|
@@ -187,7 +188,7 @@ string String::_buildCharacterChain(size_t _amount, const char _fillCharacter)
|
|
return fillContent;
|
|
return fillContent;
|
|
}
|
|
}
|
|
|
|
|
|
-string String::_createFillContent(const string &_text, size_t _width, const char _fillCharacter)
|
|
|
|
|
|
+string String::_createFillContent(string_view _text, size_t _width, const char _fillCharacter)
|
|
{
|
|
{
|
|
size_t fillSize = _text.size() > _width ? 0 : _width - _text.size();
|
|
size_t fillSize = _text.size() > _width ? 0 : _width - _text.size();
|
|
string fillContent{};
|
|
string fillContent{};
|