mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-03 05:57:40 -05:00
feat: Added ability to query provider information from pattern language
This commit is contained in:
2
lib/external/libromfs
vendored
2
lib/external/libromfs
vendored
Submodule lib/external/libromfs updated: 59d8ceccb0...40cd303e92
@@ -64,7 +64,8 @@ namespace hex::prv {
|
||||
[[nodiscard]] virtual std::optional<u32> getPageOfAddress(u64 address) const;
|
||||
|
||||
[[nodiscard]] virtual std::string getName() const = 0;
|
||||
[[nodiscard]] virtual std::vector<std::pair<std::string, std::string>> getDataInformation() const = 0;
|
||||
[[nodiscard]] virtual std::vector<std::pair<std::string, std::string>> getDataDescription() const = 0;
|
||||
[[nodiscard]] virtual std::variant<std::string, i128> queryInformation(const std::string &category, const std::string &argument);
|
||||
|
||||
[[nodiscard]] virtual bool open() = 0;
|
||||
virtual void close() = 0;
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
#include <map>
|
||||
#include <optional>
|
||||
|
||||
#include <hex/helpers/magic.hpp>
|
||||
|
||||
namespace hex::prv {
|
||||
|
||||
u32 Provider::s_idCounter = 0;
|
||||
@@ -301,4 +303,16 @@ namespace hex::prv {
|
||||
s_idCounter = id + 1;
|
||||
}
|
||||
|
||||
|
||||
[[nodiscard]] std::variant<std::string, i128> Provider::queryInformation(const std::string &category, const std::string &) {
|
||||
if (category == "mime")
|
||||
return magic::getMIMEType(this);
|
||||
else if (category == "description")
|
||||
return magic::getDescription(this);
|
||||
else if (category == "provider_type")
|
||||
return this->getTypeName();
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user