|
@@ -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: 2020-11-26
|
|
|
|
|
|
+ * Changed: 2021-05-01
|
|
*
|
|
*
|
|
* */
|
|
* */
|
|
|
|
|
|
@@ -13,78 +13,96 @@
|
|
ls_std::String::String() : ls_std::Class("String")
|
|
ls_std::String::String() : ls_std::Class("String")
|
|
{}
|
|
{}
|
|
|
|
|
|
-ls_std::String::String(std::string _value) : ls_std::Class("String"),
|
|
|
|
-value(std::move(_value))
|
|
|
|
|
|
+ls_std::String::String(std::string _value)
|
|
|
|
+ : ls_std::Class("String"),
|
|
|
|
+ value(std::move(_value))
|
|
{}
|
|
{}
|
|
|
|
|
|
-ls_std::String::operator const char*() const {
|
|
|
|
|
|
+ls_std::String::operator const char *() const
|
|
|
|
+{
|
|
return this->value.c_str();
|
|
return this->value.c_str();
|
|
}
|
|
}
|
|
|
|
|
|
-ls_std::String::operator std::string() const {
|
|
|
|
|
|
+ls_std::String::operator std::string() const
|
|
|
|
+{
|
|
return this->value;
|
|
return this->value;
|
|
}
|
|
}
|
|
|
|
|
|
-ls_std::String & ls_std::String::operator=(std::string _value) {
|
|
|
|
|
|
+ls_std::String &ls_std::String::operator=(std::string _value)
|
|
|
|
+{
|
|
this->value = std::move(_value);
|
|
this->value = std::move(_value);
|
|
return *this;
|
|
return *this;
|
|
}
|
|
}
|
|
|
|
|
|
-std::string ls_std::String::operator+(ls_std::String _string) const {
|
|
|
|
|
|
+std::string ls_std::String::operator+(ls_std::String _string) const
|
|
|
|
+{
|
|
return this->value + _string.toString();
|
|
return this->value + _string.toString();
|
|
}
|
|
}
|
|
|
|
|
|
-std::string ls_std::String::operator+(const std::string& _string) const {
|
|
|
|
|
|
+std::string ls_std::String::operator+(const std::string &_string) const
|
|
|
|
+{
|
|
return this->value + _string;
|
|
return this->value + _string;
|
|
}
|
|
}
|
|
|
|
|
|
-std::string ls_std::String::operator+(const char *_string) const {
|
|
|
|
|
|
+std::string ls_std::String::operator+(const char *_string) const
|
|
|
|
+{
|
|
return this->value + _string;
|
|
return this->value + _string;
|
|
}
|
|
}
|
|
|
|
|
|
-std::string ls_std::String::operator-(int _number) {
|
|
|
|
|
|
+std::string ls_std::String::operator-(int _number)
|
|
|
|
+{
|
|
std::string copy = this->value;
|
|
std::string copy = this->value;
|
|
return copy.substr(0, copy.size() - _number);
|
|
return copy.substr(0, copy.size() - _number);
|
|
}
|
|
}
|
|
|
|
|
|
-ls_std::String & ls_std::String::operator+=(ls_std::String _string) {
|
|
|
|
|
|
+ls_std::String &ls_std::String::operator+=(ls_std::String _string)
|
|
|
|
+{
|
|
this->value = this->value + _string.toString();
|
|
this->value = this->value + _string.toString();
|
|
return *this;
|
|
return *this;
|
|
}
|
|
}
|
|
|
|
|
|
-ls_std::String & ls_std::String::operator+=(const std::string &_text) {
|
|
|
|
|
|
+ls_std::String &ls_std::String::operator+=(const std::string &_text)
|
|
|
|
+{
|
|
this->value = this->value + _text;
|
|
this->value = this->value + _text;
|
|
return *this;
|
|
return *this;
|
|
}
|
|
}
|
|
|
|
|
|
-bool ls_std::String::operator==(ls_std::String _string) {
|
|
|
|
|
|
+bool ls_std::String::operator==(ls_std::String _string)
|
|
|
|
+{
|
|
return this->value == _string.toString();
|
|
return this->value == _string.toString();
|
|
}
|
|
}
|
|
|
|
|
|
-bool ls_std::String::operator==(const std::string& _value) {
|
|
|
|
|
|
+bool ls_std::String::operator==(const std::string &_value)
|
|
|
|
+{
|
|
return this->value == _value;
|
|
return this->value == _value;
|
|
}
|
|
}
|
|
|
|
|
|
-bool ls_std::String::operator==(const char *_value) {
|
|
|
|
|
|
+bool ls_std::String::operator==(const char *_value)
|
|
|
|
+{
|
|
return this->value == _value;
|
|
return this->value == _value;
|
|
}
|
|
}
|
|
|
|
|
|
-bool ls_std::String::operator!=(ls_std::String _string) {
|
|
|
|
|
|
+bool ls_std::String::operator!=(ls_std::String _string)
|
|
|
|
+{
|
|
return this->value != _string.toString();
|
|
return this->value != _string.toString();
|
|
}
|
|
}
|
|
|
|
|
|
-bool ls_std::String::operator!=(const std::string& _value) {
|
|
|
|
|
|
+bool ls_std::String::operator!=(const std::string &_value)
|
|
|
|
+{
|
|
return this->value != _value;
|
|
return this->value != _value;
|
|
}
|
|
}
|
|
|
|
|
|
-bool ls_std::String::operator!=(const char *_value) {
|
|
|
|
|
|
+bool ls_std::String::operator!=(const char *_value)
|
|
|
|
+{
|
|
return this->value != _value;
|
|
return this->value != _value;
|
|
}
|
|
}
|
|
|
|
|
|
-ls_std::byte_field ls_std::String::load() {
|
|
|
|
- ls_std::byte_field data {};
|
|
|
|
|
|
+ls_std::byte_field ls_std::String::load()
|
|
|
|
+{
|
|
|
|
+ ls_std::byte_field data{};
|
|
|
|
|
|
- if(this->storable != nullptr && this->serializable != nullptr) {
|
|
|
|
|
|
+ if (this->storable != nullptr && this->serializable != nullptr)
|
|
|
|
+ {
|
|
data = this->storable->load();
|
|
data = this->storable->load();
|
|
this->serializable->unmarshal(data);
|
|
this->serializable->unmarshal(data);
|
|
}
|
|
}
|
|
@@ -92,53 +110,68 @@ ls_std::byte_field ls_std::String::load() {
|
|
return data;
|
|
return data;
|
|
}
|
|
}
|
|
|
|
|
|
-ls_std::byte_field ls_std::String::marshal() {
|
|
|
|
- ls_std::byte_field data {};
|
|
|
|
|
|
+ls_std::byte_field ls_std::String::marshal()
|
|
|
|
+{
|
|
|
|
+ ls_std::byte_field data{};
|
|
|
|
|
|
- if(this->serializable != nullptr) {
|
|
|
|
|
|
+ if (this->serializable != nullptr)
|
|
|
|
+ {
|
|
data = this->serializable->marshal();
|
|
data = this->serializable->marshal();
|
|
}
|
|
}
|
|
|
|
|
|
return data;
|
|
return data;
|
|
}
|
|
}
|
|
|
|
|
|
-void ls_std::String::parse(std::string _parseText) {
|
|
|
|
|
|
+void ls_std::String::parse(std::string _parseText)
|
|
|
|
+{
|
|
this->value = std::move(_parseText);
|
|
this->value = std::move(_parseText);
|
|
}
|
|
}
|
|
|
|
|
|
-void ls_std::String::save(const ls_std::byte_field &_data) {
|
|
|
|
- if(this->serializable != nullptr) {
|
|
|
|
- if(_data.empty()) {
|
|
|
|
|
|
+void ls_std::String::save(const ls_std::byte_field &_data)
|
|
|
|
+{
|
|
|
|
+ if (this->serializable != nullptr)
|
|
|
|
+ {
|
|
|
|
+ if (_data.empty())
|
|
|
|
+ {
|
|
this->storable->save(this->serializable->marshal());
|
|
this->storable->save(this->serializable->marshal());
|
|
- } else {
|
|
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
this->storable->save(_data);
|
|
this->storable->save(_data);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-std::string ls_std::String::toString() {
|
|
|
|
|
|
+std::string ls_std::String::toString()
|
|
|
|
+{
|
|
return this->value;
|
|
return this->value;
|
|
}
|
|
}
|
|
|
|
|
|
-void ls_std::String::unmarshal(const ls_std::byte_field &_data) {
|
|
|
|
- if(this->serializable != nullptr) {
|
|
|
|
|
|
+void ls_std::String::unmarshal(const ls_std::byte_field &_data)
|
|
|
|
+{
|
|
|
|
+ if (this->serializable != nullptr)
|
|
|
|
+ {
|
|
this->serializable->unmarshal(_data);
|
|
this->serializable->unmarshal(_data);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-bool ls_std::String::contains(const std::string& _text) {
|
|
|
|
|
|
+bool ls_std::String::contains(const std::string &_text)
|
|
|
|
+{
|
|
return this->value.find(_text) != std::string::npos;
|
|
return this->value.find(_text) != std::string::npos;
|
|
}
|
|
}
|
|
|
|
|
|
-bool ls_std::String::endsWith(const std::string &_text) {
|
|
|
|
|
|
+bool ls_std::String::endsWith(const std::string &_text)
|
|
|
|
+{
|
|
return this->value.rfind(_text) == (this->value.size() - _text.size());
|
|
return this->value.rfind(_text) == (this->value.size() - _text.size());
|
|
}
|
|
}
|
|
|
|
|
|
-bool ls_std::String::equalsIgnoreCase(ls_std::String _string) {
|
|
|
|
|
|
+bool ls_std::String::equalsIgnoreCase(ls_std::String _string)
|
|
|
|
+{
|
|
return this->toLowerCase() == _string.toLowerCase();
|
|
return this->toLowerCase() == _string.toLowerCase();
|
|
}
|
|
}
|
|
|
|
|
|
-bool ls_std::String::equalsIgnoreCase(std::string _text) {
|
|
|
|
|
|
+bool ls_std::String::equalsIgnoreCase(std::string _text)
|
|
|
|
+{
|
|
return this->toLowerCase() == ls_std::String{std::move(_text)}.toLowerCase();
|
|
return this->toLowerCase() == ls_std::String{std::move(_text)}.toLowerCase();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -150,62 +183,74 @@ std::vector<ls_std::byte> ls_std::String::getByteData()
|
|
return byteData;
|
|
return byteData;
|
|
}
|
|
}
|
|
|
|
|
|
-std::string ls_std::String::padLeft(size_t _width, const char _fillCharacter) {
|
|
|
|
|
|
+std::string ls_std::String::padLeft(size_t _width, const char _fillCharacter)
|
|
|
|
+{
|
|
return ls_std::String::_createFillContent(this->value, _width, _fillCharacter) + this->value;
|
|
return ls_std::String::_createFillContent(this->value, _width, _fillCharacter) + this->value;
|
|
}
|
|
}
|
|
|
|
|
|
-std::string ls_std::String::padRight(size_t _width, const char _fillCharacter) {
|
|
|
|
|
|
+std::string ls_std::String::padRight(size_t _width, const char _fillCharacter)
|
|
|
|
+{
|
|
return this->value + ls_std::String::_createFillContent(this->value, _width, _fillCharacter);
|
|
return this->value + ls_std::String::_createFillContent(this->value, _width, _fillCharacter);
|
|
}
|
|
}
|
|
|
|
|
|
-std::string ls_std::String::reverse() {
|
|
|
|
|
|
+std::string ls_std::String::reverse()
|
|
|
|
+{
|
|
std::string copy = this->value;
|
|
std::string copy = this->value;
|
|
std::reverse(copy.begin(), copy.end());
|
|
std::reverse(copy.begin(), copy.end());
|
|
|
|
|
|
return copy;
|
|
return copy;
|
|
}
|
|
}
|
|
|
|
|
|
-void ls_std::String::setSerializable(std::shared_ptr<ISerializable> _serializable) {
|
|
|
|
|
|
+void ls_std::String::setSerializable(std::shared_ptr<ls_std::ISerializable> _serializable)
|
|
|
|
+{
|
|
this->serializable = std::move(_serializable);
|
|
this->serializable = std::move(_serializable);
|
|
}
|
|
}
|
|
|
|
|
|
-void ls_std::String::setStorable(std::shared_ptr<IStorable> _storable) {
|
|
|
|
|
|
+void ls_std::String::setStorable(std::shared_ptr<ls_std::IStorable> _storable)
|
|
|
|
+{
|
|
this->storable = std::move(_storable);
|
|
this->storable = std::move(_storable);
|
|
}
|
|
}
|
|
|
|
|
|
-bool ls_std::String::startsWith(const std::string &_text) {
|
|
|
|
|
|
+bool ls_std::String::startsWith(const std::string &_text)
|
|
|
|
+{
|
|
return this->value.rfind(_text, 0) == 0;
|
|
return this->value.rfind(_text, 0) == 0;
|
|
}
|
|
}
|
|
|
|
|
|
-std::string ls_std::String::toLowerCase() {
|
|
|
|
|
|
+std::string ls_std::String::toLowerCase()
|
|
|
|
+{
|
|
std::string copy = this->value;
|
|
std::string copy = this->value;
|
|
std::transform(copy.begin(), copy.end(), copy.begin(), ::tolower);
|
|
std::transform(copy.begin(), copy.end(), copy.begin(), ::tolower);
|
|
|
|
|
|
return copy;
|
|
return copy;
|
|
}
|
|
}
|
|
|
|
|
|
-std::string ls_std::String::toUpperCase() {
|
|
|
|
|
|
+std::string ls_std::String::toUpperCase()
|
|
|
|
+{
|
|
std::string copy = this->value;
|
|
std::string copy = this->value;
|
|
std::transform(copy.begin(), copy.end(), copy.begin(), ::toupper);
|
|
std::transform(copy.begin(), copy.end(), copy.begin(), ::toupper);
|
|
|
|
|
|
return copy;
|
|
return copy;
|
|
}
|
|
}
|
|
|
|
|
|
-std::string ls_std::String::_buildCharacterChain(size_t _amount, const char _fillCharacter) {
|
|
|
|
- std::string fillContent {};
|
|
|
|
|
|
+std::string ls_std::String::_buildCharacterChain(size_t _amount, const char _fillCharacter)
|
|
|
|
+{
|
|
|
|
+ std::string fillContent{};
|
|
|
|
|
|
- for(size_t iteration {} ; iteration < _amount ; iteration++) {
|
|
|
|
|
|
+ for (size_t iteration{}; iteration < _amount; iteration++)
|
|
|
|
+ {
|
|
fillContent += _fillCharacter;
|
|
fillContent += _fillCharacter;
|
|
}
|
|
}
|
|
|
|
|
|
return fillContent;
|
|
return fillContent;
|
|
}
|
|
}
|
|
|
|
|
|
-std::string ls_std::String::_createFillContent(const std::string& _text, size_t _width, const char _fillCharacter) {
|
|
|
|
|
|
+std::string ls_std::String::_createFillContent(const std::string &_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();
|
|
- std::string fillContent {};
|
|
|
|
|
|
+ std::string fillContent{};
|
|
|
|
|
|
- if(fillSize > 0) {
|
|
|
|
|
|
+ if (fillSize > 0)
|
|
|
|
+ {
|
|
fillContent = ls_std::String::_buildCharacterChain(fillSize, _fillCharacter);
|
|
fillContent = ls_std::String::_buildCharacterChain(fillSize, _fillCharacter);
|
|
}
|
|
}
|
|
|
|
|