/*
 * Author:          Patrick-Christopher Mattulat
 * Co-Author:       Claude Sonnet 4.6 (LLM)
 * Company:         Lynar Studios
 * E-Mail:          webmaster@lynarstudios.com
 * Created:         2020-09-27
 * Changed:         2026-06-23
 *
 * */

#ifndef LS_STD_VERSION_HPP
#define LS_STD_VERSION_HPP

#include "Class.hpp"
#include <ls-std/core/interface/ISerializable.hpp>
#include <ls-std/core/type/Types.hpp>
#include <ls-std/os/dynamic-goal.hpp>
#include <string_view>

/*
 * @doc: class(name: 'Version', package: 'core')
 * @doc: core.Version.description('This class represents a semantic versioning scheme.')
 * */

namespace ls::standard::core
{
  class LS_STD_DYNAMIC_GOAL Version : public ls::standard::core::interface_type::ISerializable
  {
    public:

      explicit Version(ls::standard::core::type::version_type _majorVersion, ls::standard::core::type::version_type _minorVersion, ls::standard::core::type::version_type _patchVersion);
      ~Version() noexcept override;

      // implementation

      [[nodiscard]] ls::standard::core::type::byte_field marshal() override;
      void unmarshal(const ls::standard::core::type::byte_field &_data) override;

      // other functionality

      [[nodiscard]] ls::standard::core::type::version_type getMajorVersion() const;
      [[nodiscard]] ls::standard::core::type::version_type getMinorVersion() const;
      [[nodiscard]] ls::standard::core::type::version_type getPatchVersion() const;
      [[nodiscard]] static bool isValid(const ::std::string &_versionString);
      void setMajorVersion(ls::standard::core::type::version_type _major);
      void setMinorVersion(ls::standard::core::type::version_type _minor);
      void setPatchVersion(ls::standard::core::type::version_type _patch);

    private:

      ls::standard::core::type::version_type majorVersion{};
      ls::standard::core::type::version_type minorVersion{};
      ls::standard::core::type::version_type patchVersion{};

      [[nodiscard]] static bool _isValid(::std::string_view _versionString);
  };
}

#endif
