///
/// HybridMMKVSpec.hpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © Marc Rousavy @ Margelo
///

#pragma once

#if __has_include(<NitroModules/HybridObject.hpp>)
#include <NitroModules/HybridObject.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif

// Forward declaration of `EncryptionType` to properly resolve imports.
namespace margelo::nitro::mmkv { enum class EncryptionType; }
// Forward declaration of `Listener` to properly resolve imports.
namespace margelo::nitro::mmkv { struct Listener; }
// Forward declaration of `HybridMMKVSpec` to properly resolve imports.
namespace margelo::nitro::mmkv { class HybridMMKVSpec; }

#include <string>
#include <NitroModules/ArrayBuffer.hpp>
#include <variant>
#include <optional>
#include <vector>
#include "EncryptionType.hpp"
#include "Listener.hpp"
#include <functional>
#include <memory>
#include "HybridMMKVSpec.hpp"

namespace margelo::nitro::mmkv {

  using namespace margelo::nitro;

  /**
   * An abstract base class for `MMKV`
   * Inherit this class to create instances of `HybridMMKVSpec` in C++.
   * You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
   * @example
   * ```cpp
   * class HybridMMKV: public HybridMMKVSpec {
   * public:
   *   HybridMMKV(...): HybridObject(TAG) { ... }
   *   // ...
   * };
   * ```
   */
  class HybridMMKVSpec: public virtual HybridObject {
    public:
      // Constructor
      explicit HybridMMKVSpec(): HybridObject(TAG) { }

      // Destructor
      ~HybridMMKVSpec() override = default;

    public:
      // Properties
      virtual std::string getId() = 0;
      virtual double getLength() = 0;
      virtual double getSize() = 0;
      virtual double getByteSize() = 0;
      virtual bool getIsReadOnly() = 0;
      virtual bool getIsEncrypted() = 0;

    public:
      // Methods
      virtual void set(const std::string& key, const std::variant<bool, std::shared_ptr<ArrayBuffer>, std::string, double>& value) = 0;
      virtual std::optional<bool> getBoolean(const std::string& key) = 0;
      virtual std::optional<std::string> getString(const std::string& key) = 0;
      virtual std::optional<double> getNumber(const std::string& key) = 0;
      virtual std::optional<std::shared_ptr<ArrayBuffer>> getBuffer(const std::string& key) = 0;
      virtual bool contains(const std::string& key) = 0;
      virtual bool remove(const std::string& key) = 0;
      virtual std::vector<std::string> getAllKeys() = 0;
      virtual void clearAll() = 0;
      virtual void recrypt(const std::optional<std::string>& key) = 0;
      virtual void encrypt(const std::string& key, std::optional<EncryptionType> encryptionType) = 0;
      virtual void decrypt() = 0;
      virtual void trim() = 0;
      virtual Listener addOnValueChangedListener(const std::function<void(const std::string& /* key */)>& onValueChanged) = 0;
      virtual double importAllFrom(const std::shared_ptr<HybridMMKVSpec>& other) = 0;

    protected:
      // Hybrid Setup
      void loadHybridMethods() override;

    protected:
      // Tag for logging
      static constexpr auto TAG = "MMKV";
  };

} // namespace margelo::nitro::mmkv
