#ifndef TILE_BASE_CONFIG_TOML_CONFIGURATION_H
#define TILE_BASE_CONFIG_TOML_CONFIGURATION_H

#pragma once

#include "tile/base/config/configuration.h"
#include <map>

namespace tile {
class TomlConfiguration : public Configuration {
public:
    using Ptr = RefPtr<TomlConfiguration>;

    TomlConfiguration();
    ~TomlConfiguration() override;

    bool load(std::istream &istr);
    bool load(const std::string &path);

    void SetInt(const Slice &key, int value) override;
    void SetBool(const Slice &key, bool value) override;
    void SetDouble(const Slice &key, double value) override;
    void SetString(const Slice &key, const std::string &value) override;

    void RemoveRaw(const Slice &key) override;
    std::string Dump() const;

protected:
    bool GetRaw(const Slice &key, std::string *value) const override;
    bool SetRaw(const Slice &key, const Slice &value) override;
    Keys Enumerate(const Slice &range) const override;

private:
    class Impl;

    std::unique_ptr<Impl> impl_;
};
}// namespace tile

#endif// TILE_BASE_CONFIG_TOML_CONFIGURATION_H
