Jelajahi Sumber

Added Version class (incomplete)

Patrick 4 tahun lalu
induk
melakukan
fa164f7c78
2 mengubah file dengan 84 tambahan dan 0 penghapusan
  1. 42 0
      source/base/Version.cpp
  2. 42 0
      source/base/Version.hpp

+ 42 - 0
source/base/Version.cpp

@@ -0,0 +1,42 @@
+/*
+ * Author:          Patrick-Christopher Mattulat
+ * Company:         Lynar Studios
+ * E-Mail:          webmaster@lynarstudios.com
+ * Created:         2020-09-28
+ * Changed:         2020-09-28
+ *
+ * */
+
+#include "Version.hpp"
+
+ls_std::Version::Version(version_type _major, version_type _minor, version_type _patch) :
+major(_major),
+minor(_minor),
+patch(_patch)
+{}
+
+ls_std::byte_field ls_std::Version::marshal()
+{
+  ls_std::byte_field data {};
+
+  data += std::to_string(this->major) + ".";
+  data += std::to_string(this->minor) + ".";
+  data += std::to_string(this->patch);
+
+  return data;
+}
+
+void ls_std::Version::unmarshal(const ls_std::byte_field &_data)
+{
+
+}
+
+ls_std::version_type ls_std::Version::getMajor() const
+{
+  return this->major;
+}
+
+ls_std::version_type ls_std::Version::getMinor() const
+{
+  return this->minor;
+}

+ 42 - 0
source/base/Version.hpp

@@ -0,0 +1,42 @@
+/*
+ * Author:          Patrick-Christopher Mattulat
+ * Company:         Lynar Studios
+ * E-Mail:          webmaster@lynarstudios.com
+ * Created:         2020-09-27
+ * Changed:         2020-09-27
+ *
+ * */
+
+#ifndef LS_STD_VERSION_HPP
+#define LS_STD_VERSION_HPP
+
+#include "Class.hpp"
+#include "../serialization/ISerializable.hpp"
+#include "../base/Types.hpp"
+
+namespace ls_std {
+  class Version : public ISerializable {
+      explicit Version(version_type _major, version_type _minor, version_type _patch);
+      ~Version() = default;
+
+      ls_std::byte_field marshal() override;
+      void unmarshal(const ls_std::byte_field& _data) override;
+
+      version_type getMajor() const;
+      version_type getMinor() const;
+      version_type getPatch();
+      void setMajor(version_type _major);
+      void setMinor(version_type _minor);
+      void setPatch(version_type _patch);
+
+    private:
+
+      version_type major {};
+      version_type minor {};
+      version_type patch {};
+
+      bool _isValidVersionString(const std::string& _versionString);
+  };
+}
+
+#endif