|
@@ -3,92 +3,101 @@
|
|
* Company: Lynar Studios
|
|
* Company: Lynar Studios
|
|
* E-Mail: webmaster@lynarstudios.com
|
|
* E-Mail: webmaster@lynarstudios.com
|
|
* Created: 2020-09-28
|
|
* Created: 2020-09-28
|
|
- * Changed: 2023-02-22
|
|
|
|
|
|
+ * Changed: 2023-02-23
|
|
*
|
|
*
|
|
* */
|
|
* */
|
|
|
|
|
|
#include <ls-std/core/Version.hpp>
|
|
#include <ls-std/core/Version.hpp>
|
|
#include <regex>
|
|
#include <regex>
|
|
|
|
|
|
-ls::std::core::Version::Version(ls::std::core::type::version_type _majorVersion, ls::std::core::type::version_type _minorVersion, ls::std::core::type::version_type _patchVersion) : majorVersion(_majorVersion), minorVersion(_minorVersion), patchVersion(_patchVersion)
|
|
|
|
|
|
+using ls::std::core::Version;
|
|
|
|
+using ls::std::core::type::byte_field;
|
|
|
|
+using ls::std::core::type::version_type;
|
|
|
|
+using std::regex;
|
|
|
|
+using std::regex_match;
|
|
|
|
+using std::stoi;
|
|
|
|
+using std::string;
|
|
|
|
+using std::to_string;
|
|
|
|
+
|
|
|
|
+Version::Version(version_type _majorVersion, version_type _minorVersion, version_type _patchVersion) : majorVersion(_majorVersion), minorVersion(_minorVersion), patchVersion(_patchVersion)
|
|
{}
|
|
{}
|
|
|
|
|
|
-ls::std::core::Version::~Version() noexcept = default;
|
|
|
|
|
|
+Version::~Version() noexcept = default;
|
|
|
|
|
|
-ls::std::core::type::byte_field ls::std::core::Version::marshal()
|
|
|
|
|
|
+byte_field Version::marshal()
|
|
{
|
|
{
|
|
- ls::std::core::type::byte_field data{};
|
|
|
|
|
|
+ byte_field data{};
|
|
|
|
|
|
- data += ::std::to_string(this->majorVersion) + ".";
|
|
|
|
- data += ::std::to_string(this->minorVersion) + ".";
|
|
|
|
- data += ::std::to_string(this->patchVersion);
|
|
|
|
|
|
+ data += to_string(this->majorVersion) + ".";
|
|
|
|
+ data += to_string(this->minorVersion) + ".";
|
|
|
|
+ data += to_string(this->patchVersion);
|
|
|
|
|
|
return data;
|
|
return data;
|
|
}
|
|
}
|
|
|
|
|
|
-void ls::std::core::Version::unmarshal(const ls::std::core::type::byte_field &_data)
|
|
|
|
|
|
+void Version::unmarshal(const byte_field &_data)
|
|
{
|
|
{
|
|
- ::std::string field = _data;
|
|
|
|
|
|
+ string field = _data;
|
|
|
|
|
|
- if (ls::std::core::Version::_isValid(_data))
|
|
|
|
|
|
+ if (Version::_isValid(_data))
|
|
{
|
|
{
|
|
size_t position = field.find('.');
|
|
size_t position = field.find('.');
|
|
- ::std::string subSequence = field.substr(0, position);
|
|
|
|
- this->majorVersion = ::std::stoi(subSequence);
|
|
|
|
|
|
+ string subSequence = field.substr(0, position);
|
|
|
|
+ this->majorVersion = stoi(subSequence);
|
|
field.erase(0, position + 1);
|
|
field.erase(0, position + 1);
|
|
|
|
|
|
position = field.find('.');
|
|
position = field.find('.');
|
|
subSequence = field.substr(0, position);
|
|
subSequence = field.substr(0, position);
|
|
- this->minorVersion = ::std::stoi(subSequence);
|
|
|
|
|
|
+ this->minorVersion = stoi(subSequence);
|
|
field.erase(0, position + 1);
|
|
field.erase(0, position + 1);
|
|
|
|
|
|
- this->patchVersion = ::std::stoi(field);
|
|
|
|
|
|
+ this->patchVersion = stoi(field);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-ls::std::core::type::version_type ls::std::core::Version::getMajorVersion() const
|
|
|
|
|
|
+version_type Version::getMajorVersion() const
|
|
{
|
|
{
|
|
return this->majorVersion;
|
|
return this->majorVersion;
|
|
}
|
|
}
|
|
|
|
|
|
-ls::std::core::type::version_type ls::std::core::Version::getMinorVersion() const
|
|
|
|
|
|
+version_type Version::getMinorVersion() const
|
|
{
|
|
{
|
|
return this->minorVersion;
|
|
return this->minorVersion;
|
|
}
|
|
}
|
|
|
|
|
|
-ls::std::core::type::version_type ls::std::core::Version::getPatchVersion() const
|
|
|
|
|
|
+version_type Version::getPatchVersion() const
|
|
{
|
|
{
|
|
return this->patchVersion;
|
|
return this->patchVersion;
|
|
}
|
|
}
|
|
|
|
|
|
-bool ls::std::core::Version::isValid(const ::std::string &_versionString)
|
|
|
|
|
|
+bool Version::isValid(const string &_versionString)
|
|
{
|
|
{
|
|
- return ls::std::core::Version::_isValid(_versionString);
|
|
|
|
|
|
+ return Version::_isValid(_versionString);
|
|
}
|
|
}
|
|
|
|
|
|
-void ls::std::core::Version::setMajorVersion(ls::std::core::type::version_type _major)
|
|
|
|
|
|
+void Version::setMajorVersion(version_type _major)
|
|
{
|
|
{
|
|
this->majorVersion = _major;
|
|
this->majorVersion = _major;
|
|
}
|
|
}
|
|
|
|
|
|
-void ls::std::core::Version::setMinorVersion(ls::std::core::type::version_type _minor)
|
|
|
|
|
|
+void Version::setMinorVersion(version_type _minor)
|
|
{
|
|
{
|
|
this->minorVersion = _minor;
|
|
this->minorVersion = _minor;
|
|
}
|
|
}
|
|
|
|
|
|
-void ls::std::core::Version::setPatchVersion(ls::std::core::type::version_type _patch)
|
|
|
|
|
|
+void Version::setPatchVersion(version_type _patch)
|
|
{
|
|
{
|
|
this->patchVersion = _patch;
|
|
this->patchVersion = _patch;
|
|
}
|
|
}
|
|
|
|
|
|
-bool ls::std::core::Version::_isValid(const ::std::string &_versionString)
|
|
|
|
|
|
+bool Version::_isValid(const string &_versionString)
|
|
{
|
|
{
|
|
bool isValidVersionString{};
|
|
bool isValidVersionString{};
|
|
- static ::std::regex versionRegex{R"(\d+[.]\d+[.]\d+)"};
|
|
|
|
|
|
+ static regex versionRegex{R"(\d+[.]\d+[.]\d+)"};
|
|
|
|
|
|
if (!_versionString.empty())
|
|
if (!_versionString.empty())
|
|
{
|
|
{
|
|
- isValidVersionString = ::std::regex_match(_versionString.begin(), _versionString.end(), versionRegex);
|
|
|
|
|
|
+ isValidVersionString = regex_match(_versionString.begin(), _versionString.end(), versionRegex);
|
|
}
|
|
}
|
|
|
|
|
|
return isValidVersionString;
|
|
return isValidVersionString;
|