Version.hpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-09-27
  6. * Changed: 2024-09-11
  7. *
  8. * */
  9. #ifndef LS_STD_VERSION_HPP
  10. #define LS_STD_VERSION_HPP
  11. #include "Class.hpp"
  12. #include <ls-std/core/interface/ISerializable.hpp>
  13. #include <ls-std/core/type/Types.hpp>
  14. #include <ls-std/os/dynamic-goal.hpp>
  15. #include <string_view>
  16. /*
  17. * @doc: class(name: 'Version', package: 'core')
  18. * @doc: core.Version.description('This class represents a semantic versioning scheme.')
  19. * */
  20. namespace ls::std::core
  21. {
  22. class LS_STD_DYNAMIC_GOAL Version : public ls::std::core::interface_type::ISerializable
  23. {
  24. public:
  25. explicit Version(ls::std::core::type::version_type _majorVersion, ls::std::core::type::version_type _minorVersion, ls::std::core::type::version_type _patchVersion);
  26. ~Version() noexcept override;
  27. // implementation
  28. [[nodiscard]] ls::std::core::type::byte_field marshal() override;
  29. void unmarshal(const ls::std::core::type::byte_field &_data) override;
  30. // other functionality
  31. [[nodiscard]] ls::std::core::type::version_type getMajorVersion() const;
  32. [[nodiscard]] ls::std::core::type::version_type getMinorVersion() const;
  33. [[nodiscard]] ls::std::core::type::version_type getPatchVersion() const;
  34. [[nodiscard]] static bool isValid(const ::std::string &_versionString);
  35. void setMajorVersion(ls::std::core::type::version_type _major);
  36. void setMinorVersion(ls::std::core::type::version_type _minor);
  37. void setPatchVersion(ls::std::core::type::version_type _patch);
  38. private:
  39. ls::std::core::type::version_type majorVersion{};
  40. ls::std::core::type::version_type minorVersion{};
  41. ls::std::core::type::version_type patchVersion{};
  42. [[nodiscard]] static bool _isValid(::std::string_view _versionString);
  43. };
  44. }
  45. #endif