mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-02 21:47:40 -05:00
api: Move copy-as data formatting code to builtin-plugin, add api for it
This commit is contained in:
@@ -253,6 +253,24 @@ namespace hex {
|
||||
const std::vector<std::string>& getEntries();
|
||||
|
||||
}
|
||||
|
||||
namespace DataFormatter {
|
||||
|
||||
namespace impl {
|
||||
|
||||
using Callback = std::function<std::string(prv::Provider *provider, u64 address, size_t size)>;
|
||||
struct Entry {
|
||||
std::string unlocalizedName;
|
||||
Callback callback;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
void add(const std::string &unlocalizedName, const impl::Callback &callback);
|
||||
|
||||
std::vector<impl::Entry>& getEntries();
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
@@ -91,6 +91,8 @@ namespace hex {
|
||||
static u32 dataProcessorLinkIdCounter;
|
||||
static u32 dataProcessorAttrIdCounter;
|
||||
|
||||
static std::vector<ContentRegistry::DataFormatter::impl::Entry> dataFormatters;
|
||||
|
||||
static std::list<std::string> recentFilePaths;
|
||||
|
||||
static int mainArgc;
|
||||
|
||||
@@ -288,4 +288,19 @@ namespace hex {
|
||||
const std::vector<std::string> &ContentRegistry::Provider::getEntries() {
|
||||
return SharedData::providerNames;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Data Formatters */
|
||||
|
||||
void ContentRegistry::DataFormatter::add(const std::string &unlocalizedName, const impl::Callback &callback) {
|
||||
ContentRegistry::DataFormatter::getEntries().push_back({
|
||||
unlocalizedName,
|
||||
callback
|
||||
});
|
||||
}
|
||||
|
||||
std::vector<ContentRegistry::DataFormatter::impl::Entry> &ContentRegistry::DataFormatter::getEntries() {
|
||||
return SharedData::dataFormatters;
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,8 @@ namespace hex {
|
||||
u32 SharedData::dataProcessorLinkIdCounter = 1;
|
||||
u32 SharedData::dataProcessorAttrIdCounter = 1;
|
||||
|
||||
std::vector<ContentRegistry::DataFormatter::impl::Entry> SharedData::dataFormatters;
|
||||
|
||||
std::list<std::string> SharedData::recentFilePaths;
|
||||
|
||||
int SharedData::mainArgc;
|
||||
|
||||
Reference in New Issue
Block a user