/*
{{copyright}} 
*/

/*
{{version}} 
*/

/*
{{license}} 
*/

#pragma once

#include <span>
#include <string>
#include <vector>

namespace sdi_toolBox::crypto
{
//--------------------------------------------------------------
class Data8
{
  public:
  Data8() = default;                                        // Default constructor
  explicit Data8(const std::string &data);                  // Constructor from string
  explicit Data8(const std::span<const uint8_t> &data);     // Constructor from byte span
  virtual ~Data8()                       = default;         // Default destructor
  Data8(const Data8 &obj)                = delete;          // Copy constructor
  Data8(Data8 &&obj) noexcept            = delete;          // Move constructor
  Data8 &operator=(const Data8 &obj)     = delete;          // Copy assignment operator
  Data8 &operator=(Data8 &&obj) noexcept = delete;          // Move assignment operator

  [[nodiscard]] std::string              getString() const;     // Get data as string
  [[nodiscard]] std::span<const uint8_t> getBytes() const;      // Get data as byte span
  [[nodiscard]] size_t                   getSize() const;       // Get data size

  protected:
  std::vector<uint8_t> m_data;     // Raw data storage
};
//--------------------------------------------------------------
/* Constructor from string */
inline Data8::Data8(const std::string &data)
{
  m_data = std::vector<uint8_t>(data.begin(), data.end());
}
//--------------------------------------------------------------
inline Data8::Data8(const std::span<const uint8_t> &data)
{
  m_data = std::vector<uint8_t>(data.begin(), data.end());
}
//--------------------------------------------------------------
/* Get data as string */
inline std::string Data8::getString() const
{
  return std::string(m_data.begin(), m_data.end());
}
//--------------------------------------------------------------
/* Get data as byte span */
inline std::span<const uint8_t> Data8::getBytes() const
{
  return m_data;
}
//--------------------------------------------------------------
/* Get data size */
inline size_t Data8::getSize() const
{
  return m_data.size();
}
//--------------------------------------------------------------
}     // namespace sdi_toolBox::crypto
