Browse Source

Address SonarLint findings in Version class

Patrick-Christopher Mattulat 1 year ago
parent
commit
e2b2619023

+ 3 - 2
include/ls-std/core/Version.hpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-09-27
- * Changed:         2023-02-22
+ * Changed:         2023-05-16
  *
  * */
 
@@ -14,6 +14,7 @@
 #include <ls-std/core/interface/ISerializable.hpp>
 #include <ls-std/core/type/Types.hpp>
 #include <ls-std/os/dynamic-goal.hpp>
+#include <string_view>
 
 namespace ls::std::core
 {
@@ -45,7 +46,7 @@ namespace ls::std::core
       ls::std::core::type::version_type minorVersion{};
       ls::std::core::type::version_type patchVersion{};
 
-      [[nodiscard]] static bool _isValid(const ::std::string &_versionString);
+      [[nodiscard]] static bool _isValid(::std::string_view _versionString);
   };
 }
 

+ 2 - 2
include/ls-std/core/type/Types.hpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-08-07
- * Changed:         2023-02-23
+ * Changed:         2023-05-16
  *
  * */
 
@@ -18,7 +18,7 @@ namespace ls::std::core::type
   using byte_type = char;
   using byte_field = ::std::string;
   using long_type = long long int;
-  using version_type = uint16_t;
+  using version_type = int;
   using json = nlohmann::json;
 }
 

+ 3 - 2
source/ls-std/core/Version.cpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-09-28
- * Changed:         2023-02-23
+ * Changed:         2023-05-16
  *
  * */
 
@@ -17,6 +17,7 @@ using std::regex;
 using std::regex_match;
 using std::stoi;
 using std::string;
+using std::string_view;
 using std::to_string;
 
 Version::Version(version_type _majorVersion, version_type _minorVersion, version_type _patchVersion) : majorVersion(_majorVersion), minorVersion(_minorVersion), patchVersion(_patchVersion)
@@ -90,7 +91,7 @@ void Version::setPatchVersion(version_type _patch)
   this->patchVersion = _patch;
 }
 
-bool Version::_isValid(const string &_versionString)
+bool Version::_isValid(string_view _versionString)
 {
   bool isValidVersionString{};
   static regex versionRegex{R"(\d+[.]\d+[.]\d+)"};