//
// Created by kikab on 04.06.2018.
//

#ifndef LOTRO_DAT_LIBRARY_DATPATCHER_H
#define LOTRO_DAT_LIBRARY_DATPATCHER_H

#include "yaml-cpp/yaml.h"
#include <DatOperationResult.h>

extern "C++"
{
namespace LOTRO_DAT {
    class DatFile;
    class SubfileData;
    class SubFile;
    class Database;
    class BinaryData;

    class DatPatcher {
    public:
        DatPatcher() = delete;
        DatPatcher(const DatPatcher &other) = delete;
        DatPatcher& operator=(const DatPatcher &other) = delete;
        ~DatPatcher() = default;

        explicit DatPatcher(DatFile *datFilePtr);

        void Init();

        DatOperationResult<> PatchFile(const SubfileData &data);

        DatOperationResult<> PatchFile(const char *filename, YAML::Node options);

        DatOperationResult<> PatchAllDatabase(Database *db);

        void DeInit();

    private:
        DatOperationResult<> ApplyFilePatch(std::shared_ptr<SubFile> file, BinaryData &data);

    private:
        DatFile *dat;
    };
}
}

#endif //LOTRO_DAT_LIBRARY_DATFILEPATCHER_H
