7e660450ed
This PR aims to implement a more complete undo/redo stack that, unlike the old one, also supports undoing insertions, deletions and resize operations
42 lines
1.1 KiB
C++
42 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <hex.hpp>
|
|
|
|
#include <map>
|
|
#include <vector>
|
|
|
|
#include <wolv/utils/expected.hpp>
|
|
|
|
namespace hex {
|
|
|
|
namespace prv {
|
|
class Provider;
|
|
}
|
|
|
|
enum class IPSError {
|
|
AddressOutOfRange,
|
|
PatchTooLarge,
|
|
InvalidPatchHeader,
|
|
InvalidPatchFormat,
|
|
MissingEOF
|
|
};
|
|
|
|
class Patches {
|
|
public:
|
|
Patches() = default;
|
|
Patches(std::map<u64, u8> &&patches) : m_patches(std::move(patches)) {}
|
|
|
|
static wolv::util::Expected<Patches, IPSError> fromProvider(hex::prv::Provider *provider);
|
|
static wolv::util::Expected<Patches, IPSError> fromIPSPatch(const std::vector<u8> &ipsPatch);
|
|
static wolv::util::Expected<Patches, IPSError> fromIPS32Patch(const std::vector<u8> &ipsPatch);
|
|
|
|
wolv::util::Expected<std::vector<u8>, IPSError> toIPSPatch() const;
|
|
wolv::util::Expected<std::vector<u8>, IPSError> toIPS32Patch() const;
|
|
|
|
const auto& get() const { return this->m_patches; }
|
|
auto& get() { return this->m_patches; }
|
|
|
|
private:
|
|
std::map<u64, u8> m_patches;
|
|
};
|
|
} |