impr: Replace hex::unused with std::ignore

This commit is contained in:
WerWolv
2024-12-14 21:35:54 +01:00
parent 3f316e42f2
commit 7f75706584
43 changed files with 173 additions and 139 deletions

View File

@@ -1,4 +1,3 @@
#pragma once
#include <hex/helpers/types.hpp>
#include <hex/helpers/intrinsics.hpp>

View File

@@ -3,7 +3,6 @@
#include <hex.hpp>
#include <hex/api/localization_manager.hpp>
#include <hex/helpers/intrinsics.hpp>
#include <hex/data_processor/attribute.hpp>
#include <set>
@@ -47,8 +46,8 @@ namespace hex::dp {
virtual void process() = 0;
virtual void reset() { }
virtual void store(nlohmann::json &j) const { hex::unused(j); }
virtual void load(const nlohmann::json &j) { hex::unused(j); }
virtual void store(nlohmann::json &j) const { std::ignore = j; }
virtual void load(const nlohmann::json &j) { std::ignore = j; }
struct NodeError {
Node *node;

View File

@@ -25,13 +25,16 @@
template<typename T>
std::future<HttpRequest::Result<T>> HttpRequest::uploadFile(const std::fs::path &path, const std::string &mimeName) {
hex::unused(path, mimeName);
std::ignore = path;
std::ignore = mimeName;
throw std::logic_error("Not implemented");
}
template<typename T>
std::future<HttpRequest::Result<T>> HttpRequest::uploadFile(std::vector<u8> data, const std::string &mimeName, const std::fs::path &fileName) {
hex::unused(data, mimeName, fileName);
std::ignore = data;
std::ignore = mimeName;
std::ignore = fileName;
throw std::logic_error("Not implemented");
}

View File

@@ -1,9 +0,0 @@
#pragma once
namespace hex {
void unused(auto && ... x) {
((void)x, ...);
}
}

View File

@@ -70,7 +70,7 @@ void* PluginSubCommandsFunctionHelper<T>::getSubCommands() {
#define IMHEX_LIBRARY_SETUP(name) IMHEX_LIBRARY_SETUP_IMPL(name)
#define IMHEX_LIBRARY_SETUP_IMPL(name) \
namespace { static struct EXIT_HANDLER { ~EXIT_HANDLER() { hex::log::debug("Unloaded library '{}'", name); } } HANDLER; } \
namespace { static struct EXIT_HANDLER { ~EXIT_HANDLER() { hex::log::info("Unloaded library '{}'", name); } } HANDLER; } \
IMHEX_PLUGIN_VISIBILITY_PREFIX void WOLV_TOKEN_CONCAT(initializeLibrary_, IMHEX_PLUGIN_NAME)(); \
IMHEX_PLUGIN_VISIBILITY_PREFIX const char *WOLV_TOKEN_CONCAT(getLibraryName_, IMHEX_PLUGIN_NAME)() { return name; } \
IMHEX_PLUGIN_VISIBILITY_PREFIX void WOLV_TOKEN_CONCAT(setImGuiContext_, IMHEX_PLUGIN_NAME)(ImGuiContext *ctx) { \

View File

@@ -165,7 +165,7 @@ namespace hex::prv {
void insert(u64 offset, u64 size);
void remove(u64 offset, u64 size);
virtual void resizeRaw(u64 newSize) { hex::unused(newSize); }
virtual void resizeRaw(u64 newSize) { std::ignore = newSize; }
virtual void insertRaw(u64 offset, u64 size);
virtual void removeRaw(u64 offset, u64 size);

View File

@@ -815,7 +815,7 @@ namespace hex {
return std::string(GIT_COMMIT_HASH_LONG).substr(0, 7);
}
#else
hex::unused(longHash);
std::ignore = longHash;
return "Unknown";
#endif
}

View File

@@ -112,10 +112,6 @@ namespace hex {
}
Plugin::~Plugin() {
if (isLoaded()) {
log::info("Trying to unload plugin '{}'", getPluginName());
}
unloadLibrary(m_handle, m_path);
}
@@ -335,7 +331,7 @@ namespace hex {
void PluginManager::initializeNewPlugins() {
for (const auto &plugin : getPlugins()) {
if (!plugin.isLoaded())
hex::unused(plugin.initializePlugin());
std::ignore = plugin.initializePlugin();
}
}

View File

@@ -490,7 +490,7 @@ namespace hex {
#elif defined(OS_LINUX)
pthread_setname_np(pthread_self(), name.c_str());
#elif defined(OS_WEB)
hex::unused(name);
std::ignore = name;
#elif defined(OS_MACOS)
pthread_setname_np(name.c_str());
#endif

View File

@@ -79,7 +79,7 @@ namespace hex::paths {
#elif defined(OS_MACOS)
return getDataPaths(includeSystemFolders);
#elif defined(OS_LINUX) || defined(OS_WEB)
hex::unused(includeSystemFolders);
std::ignore = includeSystemFolders;
return {xdg::ConfigHomeDir() / "imhex"};
#endif
}

View File

@@ -51,13 +51,11 @@ namespace hex::fs {
}
#if defined(OS_WINDOWS)
hex::unused(
ShellExecuteW(nullptr, L"open", filePath.c_str(), nullptr, nullptr, SW_SHOWNORMAL)
);
std::ignore = ShellExecuteW(nullptr, L"open", filePath.c_str(), nullptr, nullptr, SW_SHOWNORMAL);
#elif defined(OS_MACOS)
hex::unused(system(
std::ignore = system(
hex::format("open {}", wolv::util::toUTF8String(filePath)).c_str()
));
);
#elif defined(OS_LINUX)
executeCmd({"xdg-open", wolv::util::toUTF8String(filePath)});
#endif
@@ -73,9 +71,9 @@ namespace hex::fs {
auto args = fmt::format(L"\"{}\"", dirPath.c_str());
ShellExecuteW(nullptr, L"open", L"explorer.exe", args.c_str(), nullptr, SW_SHOWNORMAL);
#elif defined(OS_MACOS)
hex::unused(system(
std::ignore = system(
hex::format("open {}", wolv::util::toUTF8String(dirPath)).c_str()
));
);
#elif defined(OS_LINUX)
executeCmd({"xdg-open", wolv::util::toUTF8String(dirPath)});
#endif
@@ -91,12 +89,12 @@ namespace hex::fs {
auto args = fmt::format(L"/select,\"{}\"", selectedFilePath.c_str());
ShellExecuteW(nullptr, L"open", L"explorer.exe", args.c_str(), nullptr, SW_SHOWNORMAL);
#elif defined(OS_MACOS)
hex::unused(system(
std::ignore = system(
hex::format(
R"(osascript -e 'tell application "Finder" to reveal POSIX file "{}"')",
wolv::util::toUTF8String(selectedFilePath)
).c_str()
));
);
system(R"(osascript -e 'tell application "Finder" to activate')");
#elif defined(OS_LINUX)
// Fallback to only opening the folder for now

View File

@@ -41,17 +41,21 @@ namespace hex {
}
void HttpRequest::setProxyUrl(std::string proxy) {
hex::unused(proxy);
std::ignore = proxy;
}
void HttpRequest::setProxyState(bool state) {
hex::unused(state);
std::ignore = state;
}
void HttpRequest::checkProxyErrors() { }
int HttpRequest::progressCallback(void *contents, curl_off_t dlTotal, curl_off_t dlNow, curl_off_t ulTotal, curl_off_t ulNow) {
hex::unused(contents, dlTotal, dlNow, ulTotal, ulNow);
std::ignore = contents;
std::ignore = dlTotal;
std::ignore = dlNow;
std::ignore = ulTotal;
std::ignore = ulNow;
return -1;
}
}

View File

@@ -28,7 +28,9 @@ namespace hex {
void close() override { }
void readRaw(u64 offset, void *buffer, size_t size) override {
hex::unused(offset, buffer, size);
std::ignore = offset;
std::ignore = buffer;
std::ignore = size;
}
void writeRaw(u64 offset, const void *buffer, size_t size) override {
@@ -44,7 +46,7 @@ namespace hex {
}
void resizeRaw(u64 newSize) override {
hex::unused(newSize);
std::ignore = newSize;
}
void insertRaw(u64 offset, u64 size) override {

View File

@@ -336,13 +336,13 @@ namespace hex {
void startProgram(const std::string &command) {
#if defined(OS_WINDOWS)
hex::unused(system(hex::format("start {0}", command).c_str()));
std::ignore = system(hex::format("start {0}", command).c_str());
#elif defined(OS_MACOS)
hex::unused(system(hex::format("open {0}", command).c_str()));
std::ignore = system(hex::format("open {0}", command).c_str());
#elif defined(OS_LINUX)
executeCmd({"xdg-open", command});
#elif defined(OS_WEB)
hex::unused(command);
std::ignore = command;
#endif
}
@@ -839,7 +839,7 @@ namespace hex {
return dlopen(info.dli_fname, RTLD_LAZY);
#else
hex::unused(symbol);
std::ignore = symbol;
return nullptr;
#endif
}

View File

@@ -35,7 +35,7 @@ namespace hex::init {
std::vector<std::string> args;
#if defined (OS_WINDOWS)
hex::unused(argv);
std::ignore = argv;
// On Windows, argv contains UTF-16 encoded strings, so we need to convert them to UTF-8
auto convertedCommandLine = ::CommandLineToArgvW(::GetCommandLineW(), &argc);

View File

@@ -43,7 +43,9 @@
// Clean up everything after the main window is closed
emscripten_set_beforeunload_callback(nullptr, [](int eventType, const void *reserved, void *userData) {
hex::unused(eventType, reserved, userData);
std::ignore = eventType;
std::ignore = reserved;
std::ignore = userData;
emscripten_cancel_main_loop();

View File

@@ -2,7 +2,6 @@
#include <stdexcept>
#include <hex/helpers/intrinsics.hpp>
#include <hex/helpers/logger.hpp>
#include "messaging.hpp"
@@ -10,8 +9,8 @@
namespace hex::messaging {
void sendToOtherInstance(const std::string &eventName, const std::vector<u8> &args) {
hex::unused(eventName);
hex::unused(args);
std::ignore = eventName;
std::ignore = args;
log::error("Unimplemented function 'sendToOtherInstance()' called");
}

View File

@@ -2,7 +2,6 @@
#include <stdexcept>
#include <hex/helpers/intrinsics.hpp>
#include <hex/helpers/logger.hpp>
#include "messaging.hpp"
@@ -10,8 +9,8 @@
namespace hex::messaging {
void sendToOtherInstance(const std::string &eventName, const std::vector<u8> &args) {
hex::unused(eventName);
hex::unused(args);
std::ignore = eventName;
std::ignore = args;
log::error("Unimplemented function 'sendToOtherInstance()' called");
}

View File

@@ -2,7 +2,6 @@
#include <stdexcept>
#include <hex/helpers/intrinsics.hpp>
#include <hex/helpers/logger.hpp>
#include "messaging.hpp"
@@ -10,8 +9,8 @@
namespace hex::messaging {
void sendToOtherInstance(const std::string &eventName, const std::vector<u8> &args) {
hex::unused(eventName);
hex::unused(args);
std::ignore = eventName;
std::ignore = args;
log::error("Unimplemented function 'sendToOtherInstance()' called");
}

View File

@@ -883,7 +883,7 @@ namespace hex {
// Register key press callback
glfwSetInputMode(m_window, GLFW_LOCK_KEY_MODS, GLFW_TRUE);
glfwSetKeyCallback(m_window, [](GLFWwindow *window, int key, int scanCode, int action, int mods) {
hex::unused(mods);
std::ignore = mods;
// Handle A-Z keys using their ASCII value instead of the keycode

View File

@@ -29,14 +29,22 @@ namespace hex::plugin::builtin {
[[nodiscard]] bool open() override { return true; }
void close() override { }
void readRaw(u64 offset, void *buffer, size_t size) override { hex::unused(offset, buffer, size); }
void writeRaw(u64 offset, const void *buffer, size_t size) override { hex::unused(offset, buffer, size); }
void readRaw(u64 offset, void *buffer, size_t size) override {
std::ignore = offset;
std::ignore = buffer;
std::ignore = size;
}
void writeRaw(u64 offset, const void *buffer, size_t size) override {
std::ignore = offset;
std::ignore = buffer;
std::ignore = size;
}
[[nodiscard]] u64 getActualSize() const override { return 0x00; }
[[nodiscard]] std::string getName() const override { return "None"; }
[[nodiscard]] std::vector<Description> getDataDescription() const override { return { }; }
void loadSettings(const nlohmann::json &settings) override { hex::unused(settings); }
void loadSettings(const nlohmann::json &settings) override { std::ignore = settings; }
[[nodiscard]] nlohmann::json storeSettings(nlohmann::json settings) const override { return settings; }
[[nodiscard]] std::string getTypeName() const override {

View File

@@ -12,13 +12,13 @@ namespace hex::plugin::builtin::undo {
m_entry(std::move(entry)) { }
void undo(prv::Provider *provider) override {
hex::unused(provider);
std::ignore = provider;
ImHexApi::Bookmarks::remove(m_entry.id);
}
void redo(prv::Provider *provider) override {
hex::unused(provider);
std::ignore = provider;
auto &[region, name, comment, color, locked, id] = m_entry;

View File

@@ -363,7 +363,7 @@ namespace hex::plugin::builtin {
});
wolv::io::File file(path, wolv::io::File::Mode::Read);
hex::unused(runtime.preprocessString(file.readString(), pl::api::Source::DefaultSource));
std::ignore = runtime.preprocessString(file.readString(), pl::api::Source::DefaultSource);
return m_patternNames[path];
},

View File

@@ -212,7 +212,7 @@ namespace hex::plugin::builtin {
// Clear temporary achievements when the last provider is closed
EventProviderChanged::subscribe([](hex::prv::Provider *oldProvider, const hex::prv::Provider *newProvider) {
hex::unused(oldProvider);
std::ignore = oldProvider;
if (newProvider == nullptr) {
AchievementManager::clearTemporary();
}

View File

@@ -28,7 +28,7 @@ namespace hex::plugin::builtin {
using namespace hex::literals;
void handleVersionCommand(const std::vector<std::string> &args) {
hex::unused(args);
std::ignore = args;
hex::log::print(std::string(romfs::get("logo.ans").string()),
ImHexApi::System::getImHexVersion(),
@@ -40,7 +40,7 @@ namespace hex::plugin::builtin {
}
void handleHelpCommand(const std::vector<std::string> &args) {
hex::unused(args);
std::ignore = args;
hex::log::print(
"ImHex - A Hex Editor for Reverse Engineers, Programmers and people who value their retinas when working at 3 AM.\n"

View File

@@ -19,7 +19,7 @@ namespace hex::plugin::builtin {
~InformationProvider() override = default;
void process(Task &task, prv::Provider *provider, Region region) override {
hex::unused(task);
std::ignore = task;
m_provider = provider;
m_region = region;

View File

@@ -129,7 +129,8 @@ namespace hex::plugin::builtin {
ContentRegistry::DataInspector::add("hex.builtin.inspector.binary", sizeof(u8),
[](auto buffer, auto endian, auto style) {
hex::unused(endian, style);
std::ignore = endian;
std::ignore = style;
std::string binary = hex::format("0b{:08b}", buffer[0]);
@@ -138,7 +139,7 @@ namespace hex::plugin::builtin {
return binary;
};
}, [](const std::string &value, std::endian endian) -> std::vector<u8> {
hex::unused(endian);
std::ignore = endian;
std::string binary = value;
if (binary.starts_with("0b"))
@@ -269,7 +270,7 @@ namespace hex::plugin::builtin {
ContentRegistry::DataInspector::add("hex.builtin.inspector.sleb128", 1, (sizeof(i128) * 8 / 7) + 1,
[](auto buffer, auto endian, auto style) {
hex::unused(endian);
std::ignore = endian;
auto format = (style == Style::Decimal) ? "{0}{1:d}" : ((style == Style::Hexadecimal) ? "{0}0x{1:X}" : "{0}0o{1:o}");
@@ -281,7 +282,7 @@ namespace hex::plugin::builtin {
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };
},
[](const std::string &value, std::endian endian) -> std::vector<u8> {
hex::unused(endian);
std::ignore = endian;
return hex::crypt::encodeSleb128(std::strtoll(value.c_str(), nullptr, 0));
}
@@ -289,7 +290,7 @@ namespace hex::plugin::builtin {
ContentRegistry::DataInspector::add("hex.builtin.inspector.uleb128", 1, (sizeof(u128) * 8 / 7) + 1,
[](auto buffer, auto endian, auto style) {
hex::unused(endian);
std::ignore = endian;
auto format = (style == Style::Decimal) ? "{0:d}" : ((style == Style::Hexadecimal) ? "0x{0:X}" : "0o{0:o}");
@@ -298,7 +299,7 @@ namespace hex::plugin::builtin {
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };
},
[](const std::string &value, std::endian endian) -> std::vector<u8> {
hex::unused(endian);
std::ignore = endian;
return hex::crypt::encodeUleb128(std::strtoull(value.c_str(), nullptr, 0));
}
@@ -306,7 +307,8 @@ namespace hex::plugin::builtin {
ContentRegistry::DataInspector::add("hex.builtin.inspector.bool", sizeof(bool),
[](auto buffer, auto endian, auto style) {
hex::unused(endian, style);
std::ignore = endian;
std::ignore = style;
std::string value = [buffer] {
switch (buffer[0]) {
@@ -325,13 +327,14 @@ namespace hex::plugin::builtin {
ContentRegistry::DataInspector::add("hex.builtin.inspector.ascii", sizeof(char8_t),
[](auto buffer, auto endian, auto style) {
hex::unused(endian, style);
std::ignore = endian;
std::ignore = style;
auto value = makePrintable(*reinterpret_cast<char8_t *>(buffer.data()));
return [value] { ImGuiExt::TextFormatted("'{0}'", value.c_str()); return value; };
},
[](const std::string &value, std::endian endian) -> std::vector<u8> {
hex::unused(endian);
std::ignore = endian;
if (value.length() > 1) return { };
@@ -341,7 +344,7 @@ namespace hex::plugin::builtin {
ContentRegistry::DataInspector::add("hex.builtin.inspector.wide", sizeof(wchar_t),
[](auto buffer, auto endian, auto style) {
hex::unused(style);
std::ignore = style;
wchar_t wideChar = '\x00';
std::memcpy(&wideChar, buffer.data(), std::min(sizeof(wchar_t), buffer.size()));
@@ -369,7 +372,8 @@ namespace hex::plugin::builtin {
ContentRegistry::DataInspector::add("hex.builtin.inspector.utf8", sizeof(char8_t) * 4,
[](auto buffer, auto endian, auto style) {
hex::unused(endian, style);
std::ignore = endian;
std::ignore = style;
char utf8Buffer[5] = { 0 };
char codepointString[5] = { 0 };
@@ -391,7 +395,9 @@ namespace hex::plugin::builtin {
ContentRegistry::DataInspector::add("hex.builtin.inspector.string", 1,
[](auto buffer, auto endian, auto style) {
hex::unused(buffer, endian, style);
std::ignore = buffer;
std::ignore = endian;
std::ignore = style;
auto currSelection = ImHexApi::HexEditor::getSelection();
@@ -416,7 +422,7 @@ namespace hex::plugin::builtin {
return [value, copyValue] { ImGuiExt::TextFormatted("\"{0}\"", value.c_str()); return copyValue; };
},
[](const std::string &value, std::endian endian) -> std::vector<u8> {
hex::unused(endian);
std::ignore = endian;
return hex::decodeByteString(value);
}
@@ -424,7 +430,9 @@ namespace hex::plugin::builtin {
ContentRegistry::DataInspector::add("hex.builtin.inspector.string16", 2,
[](auto buffer, auto endian, auto style) {
hex::unused(buffer, endian, style);
std::ignore = buffer;
std::ignore = endian;
std::ignore = style;
auto currSelection = ImHexApi::HexEditor::getSelection();
@@ -456,7 +464,7 @@ namespace hex::plugin::builtin {
return [value, copyValue] { ImGuiExt::TextFormatted("L\"{0}\"", value.c_str()); return copyValue; };
},
[](const std::string &value, std::endian endian) -> std::vector<u8> {
hex::unused(endian);
std::ignore = endian;
return hex::decodeByteString(value);
}
@@ -465,7 +473,7 @@ namespace hex::plugin::builtin {
#if defined(OS_WINDOWS)
ContentRegistry::DataInspector::add("hex.builtin.inspector.time32", sizeof(u32), [](auto buffer, auto endian, auto style) {
hex::unused(style);
std::ignore = style;
auto endianAdjustedTime = hex::changeEndianness(*reinterpret_cast<u32 *>(buffer.data()), endian);
@@ -480,7 +488,7 @@ namespace hex::plugin::builtin {
});
ContentRegistry::DataInspector::add("hex.builtin.inspector.time64", sizeof(u64), [](auto buffer, auto endian, auto style) {
hex::unused(style);
std::ignore = style;
auto endianAdjustedTime = hex::changeEndianness(*reinterpret_cast<u64 *>(buffer.data()), endian);
@@ -497,7 +505,7 @@ namespace hex::plugin::builtin {
#else
ContentRegistry::DataInspector::add("hex.builtin.inspector.time", sizeof(time_t), [](auto buffer, auto endian, auto style) {
hex::unused(style);
std::ignore = style;
auto endianAdjustedTime = hex::changeEndianness(*reinterpret_cast<time_t *>(buffer.data()), endian);
@@ -526,7 +534,7 @@ namespace hex::plugin::builtin {
};
ContentRegistry::DataInspector::add("hex.builtin.inspector.dos_date", sizeof(DOSDate), [](auto buffer, auto endian, auto style) {
hex::unused(style);
std::ignore = style;
DOSDate date = { };
std::memcpy(&date, buffer.data(), sizeof(DOSDate));
@@ -538,7 +546,7 @@ namespace hex::plugin::builtin {
});
ContentRegistry::DataInspector::add("hex.builtin.inspector.dos_time", sizeof(DOSTime), [](auto buffer, auto endian, auto style) {
hex::unused(style);
std::ignore = style;
DOSTime time = { };
std::memcpy(&time, buffer.data(), sizeof(DOSTime));
@@ -550,7 +558,7 @@ namespace hex::plugin::builtin {
});
ContentRegistry::DataInspector::add("hex.builtin.inspector.guid", sizeof(GUID), [](auto buffer, auto endian, auto style) {
hex::unused(style);
std::ignore = style;
GUID guid = { };
std::memcpy(&guid, buffer.data(), sizeof(GUID));
@@ -572,7 +580,7 @@ namespace hex::plugin::builtin {
});
ContentRegistry::DataInspector::add("hex.builtin.inspector.rgba8", sizeof(u32), [](auto buffer, auto endian, auto style) {
hex::unused(style);
std::ignore = style;
ImColor value(hex::changeEndianness(*reinterpret_cast<u32 *>(buffer.data()), endian));
@@ -585,7 +593,7 @@ namespace hex::plugin::builtin {
});
ContentRegistry::DataInspector::add("hex.builtin.inspector.rgb565", sizeof(u16), [](auto buffer, auto endian, auto style) {
hex::unused(style);
std::ignore = style;
auto value = hex::changeEndianness(*reinterpret_cast<u16 *>(buffer.data()), endian);
ImColor color((value & 0x1F) << 3, ((value >> 5) & 0x3F) << 2, ((value >> 11) & 0x1F) << 3, 0xFF);

View File

@@ -16,7 +16,7 @@ namespace hex::plugin::builtin {
explicit DataVisualizerHexadecimal(const std::string &name) : DataVisualizer(name, ByteCount, CharCount) { }
void draw(u64 address, const u8 *data, size_t size, bool upperCase) override {
hex::unused(address);
std::ignore = address;
if (size == ByteCount)
ImGuiExt::TextFormatted(upperCase ? "{:0{}X}" : "{:0{}x}", *reinterpret_cast<const T*>(data), sizeof(T) * 2);
@@ -25,7 +25,8 @@ namespace hex::plugin::builtin {
}
bool drawEditing(u64 address, u8 *data, size_t size, bool upperCase, bool startedEditing) override {
hex::unused(address, startedEditing);
std::ignore = address;
std::ignore = startedEditing;
if (size == ByteCount) {
return drawDefaultScalarEditingTextBox(address, getFormatString(upperCase), ImGuiExt::getImGuiDataType<T>(), data, ImGuiInputTextFlags_CharsHexadecimal);
@@ -35,8 +36,8 @@ namespace hex::plugin::builtin {
}
private:
constexpr static inline auto ByteCount = sizeof(T);
constexpr static inline auto CharCount = ByteCount * 2;
constexpr static auto ByteCount = sizeof(T);
constexpr static auto CharCount = ByteCount * 2;
const static inline auto FormattingUpperCase = hex::format("%0{}{}X", CharCount, ImGuiExt::getFormatLengthSpecifier<T>());
const static inline auto FormattingLowerCase = hex::format("%0{}{}x", CharCount, ImGuiExt::getFormatLengthSpecifier<T>());
@@ -54,7 +55,7 @@ namespace hex::plugin::builtin {
DataVisualizerHexii() : DataVisualizer("hex.builtin.visualizer.hexii", ByteCount, CharCount) { }
void draw(u64 address, const u8 *data, size_t size, bool upperCase) override {
hex::unused(address);
std::ignore = address;
if (size == ByteCount) {
const u8 c = data[0];
@@ -78,7 +79,8 @@ namespace hex::plugin::builtin {
}
bool drawEditing(u64 address, u8 *data, size_t size, bool upperCase, bool startedEditing) override {
hex::unused(address, startedEditing);
std::ignore = address;
std::ignore = startedEditing;
if (size == ByteCount) {
return drawDefaultScalarEditingTextBox(address, getFormatString(upperCase), ImGuiExt::getImGuiDataType<u8>(), data, ImGuiInputTextFlags_CharsHexadecimal);
@@ -108,7 +110,8 @@ namespace hex::plugin::builtin {
explicit DataVisualizerDecimal(const std::string &name) : DataVisualizer(name, ByteCount, CharCount) { }
void draw(u64 address, const u8 *data, size_t size, bool upperCase) override {
hex::unused(address, upperCase);
std::ignore = address;
std::ignore = upperCase;
if (size == ByteCount) {
if (std::is_signed_v<T>)
@@ -121,7 +124,9 @@ namespace hex::plugin::builtin {
}
bool drawEditing(u64 address, u8 *data, size_t size, bool upperCase, bool startedEditing) override {
hex::unused(address, upperCase, startedEditing);
std::ignore = address;
std::ignore = upperCase;
std::ignore = startedEditing;
if (size == ByteCount) {
return drawDefaultScalarEditingTextBox(address, FormatString.c_str(), ImGuiExt::getImGuiDataType<T>(), data, ImGuiInputTextFlags_None);
@@ -131,8 +136,8 @@ namespace hex::plugin::builtin {
}
private:
constexpr static inline auto ByteCount = sizeof(T);
constexpr static inline auto CharCount = std::numeric_limits<T>::digits10 + 2;
constexpr static auto ByteCount = sizeof(T);
constexpr static auto CharCount = std::numeric_limits<T>::digits10 + 2;
const static inline auto FormatString = hex::format("%{}{}{}", CharCount, ImGuiExt::getFormatLengthSpecifier<T>(), std::is_signed_v<T> ? "d" : "u");
@@ -149,7 +154,7 @@ namespace hex::plugin::builtin {
explicit DataVisualizerFloatingPoint(const std::string &name) : DataVisualizer(name, ByteCount, CharCount) { }
void draw(u64 address, const u8 *data, size_t size, bool upperCase) override {
hex::unused(address);
std::ignore = address;
if (size == ByteCount)
ImGui::Text(getFormatString(upperCase), *reinterpret_cast<const T*>(data));
@@ -158,7 +163,9 @@ namespace hex::plugin::builtin {
}
bool drawEditing(u64 address, u8 *data, size_t size, bool upperCase, bool startedEditing) override {
hex::unused(address, upperCase, startedEditing);
std::ignore = address;
std::ignore = upperCase;
std::ignore = startedEditing;
if (size == ByteCount) {
return drawDefaultScalarEditingTextBox(address, getFormatString(upperCase), ImGuiExt::getImGuiDataType<T>(), data, ImGuiInputTextFlags_CharsScientific);
@@ -188,7 +195,7 @@ namespace hex::plugin::builtin {
explicit DataVisualizerFloatingPoint(const std::string &name) : DataVisualizer(name, ByteCount, CharCount) { }
void draw(u64 address, const u8 *data, size_t size, bool upperCase) override {
hex::unused(address);
std::ignore = address;
if (size == ByteCount)
ImGui::Text(getFormatString(upperCase), hex::float16ToFloat32(*reinterpret_cast<const u16*>(data)));
@@ -197,15 +204,15 @@ namespace hex::plugin::builtin {
}
bool drawEditing(u64 address, u8 *data, size_t size, bool upperCase, bool startedEditing) override {
hex::unused(startedEditing);
std::ignore = startedEditing;
this->draw(address, data, size, upperCase);
return false;
}
private:
constexpr static inline auto ByteCount = sizeof(Float16);
constexpr static inline auto CharCount = 14;
constexpr static auto ByteCount = sizeof(Float16);
constexpr static auto CharCount = 14;
const static inline auto FormatStringUpperCase = hex::format("%{}G", CharCount);
const static inline auto FormatStringLowerCase = hex::format("%{}g", CharCount);
@@ -223,7 +230,8 @@ namespace hex::plugin::builtin {
DataVisualizerRGBA8() : DataVisualizer("hex.builtin.visualizer.rgba8", 4, 2) { }
void draw(u64 address, const u8 *data, size_t size, bool upperCase) override {
hex::unused(address, upperCase);
std::ignore = address;
std::ignore = upperCase;
if (size == 4)
ImGui::ColorButton("##color", ImColor(data[0], data[1], data[2], data[3]), ImGuiColorEditFlags_AlphaPreview | ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_NoDragDrop, ImVec2(ImGui::GetColumnWidth(), ImGui::GetTextLineHeight()));
@@ -232,7 +240,10 @@ namespace hex::plugin::builtin {
}
bool drawEditing(u64 address, u8 *data, size_t size, bool upperCase, bool startedEditing) override {
hex::unused(address, data, size, upperCase);
std::ignore = address;
std::ignore = data;
std::ignore = size;
std::ignore = upperCase;
m_currColor = { float(data[0]) / 0xFF, float(data[1]) / 0xFF, float(data[2]) / 0xFF, float(data[3]) / 0xFF };
if (startedEditing) {
@@ -254,8 +265,8 @@ namespace hex::plugin::builtin {
return false;
}
std::array<float, 4> m_currColor = { 0 };
private:
std::array<float, 4> m_currColor = { };
};
class DataVisualizerBinary : public hex::ContentRegistry::HexEditor::DataVisualizer {
@@ -263,14 +274,15 @@ namespace hex::plugin::builtin {
DataVisualizerBinary() : DataVisualizer("hex.builtin.visualizer.binary", 1, 8) { }
void draw(u64 address, const u8 *data, size_t size, bool) override {
hex::unused(address);
std::ignore = address;
if (size == 1)
ImGuiExt::TextFormatted("{:08b}", *data);
}
bool drawEditing(u64 address, u8 *data, size_t, bool, bool startedEditing) override {
hex::unused(address, startedEditing);
std::ignore = address;
std::ignore = startedEditing;
if (startedEditing) {
m_inputBuffer = hex::format("{:08b}", *data);

View File

@@ -110,8 +110,8 @@ namespace hex::plugin::builtin {
});
EventProviderChanged::subscribe([](hex::prv::Provider *oldProvider, hex::prv::Provider *newProvider) {
hex::unused(oldProvider);
hex::unused(newProvider);
std::ignore = oldProvider;
std::ignore = newProvider;
RequestUpdateWindowTitle::post();
});

View File

@@ -185,7 +185,9 @@ namespace hex::plugin::builtin {
}
void IntelHexProvider::writeRaw(u64 offset, const void *buffer, size_t size) {
hex::unused(offset, buffer, size);
std::ignore = offset;
std::ignore = buffer;
std::ignore = size;
}
u64 IntelHexProvider::getActualSize() const {

View File

@@ -81,7 +81,7 @@ namespace hex::plugin::builtin {
};
auto read = process_vm_readv(m_processId, &local, 1, &remote, 1, 0);
hex::unused(read);
std::ignore = read;
#endif
}
void ProcessMemoryProvider::writeRaw(u64 address, const void *buffer, size_t size) {
@@ -107,7 +107,7 @@ namespace hex::plugin::builtin {
};
auto write = process_vm_writev(m_processId, &local, 1, &remote, 1, 0);
hex::unused(write);
std::ignore = write;
#endif
}

View File

@@ -28,7 +28,7 @@ namespace hex::plugin::builtin {
evaluator.setFunction(
"clear", [&](auto args) -> std::optional<long double> {
hex::unused(args);
std::ignore = args;
mathHistory.clear();
lastMathError.clear();

View File

@@ -60,7 +60,7 @@ namespace hex::plugin::builtin {
// Draw hex editor background highlights for bookmarks
ImHexApi::HexEditor::addBackgroundHighlightingProvider([this](u64 address, const u8* data, size_t size, bool) -> std::optional<color_t> {
hex::unused(data);
std::ignore = data;
// Check all bookmarks for potential overlaps with the current address
for (const auto &bookmark : *m_bookmarks) {
@@ -73,7 +73,7 @@ namespace hex::plugin::builtin {
// Draw hex editor tooltips for bookmarks
ImHexApi::HexEditor::addTooltipProvider([this](u64 address, const u8 *data, size_t size) {
hex::unused(data);
std::ignore = data;
// Loop over all bookmarks
for (const auto &[bookmark, editor] : *m_bookmarks) {

View File

@@ -21,7 +21,8 @@ namespace hex::plugin::builtin {
const static auto HighlightColor = [] { return (ImGuiExt::GetCustomColorU32(ImGuiCustomCol_FindHighlight) & 0x00FFFFFF) | 0x70000000; };
ImHexApi::HexEditor::addBackgroundHighlightingProvider([this](u64 address, const u8* data, size_t size, bool) -> std::optional<color_t> {
hex::unused(data, size);
std::ignore = data;
std::ignore = size;
if (m_searchTask.isRunning())
return { };
@@ -33,7 +34,8 @@ namespace hex::plugin::builtin {
});
ImHexApi::HexEditor::addTooltipProvider([this](u64 address, const u8* data, size_t size) {
hex::unused(data, size);
std::ignore = data;
std::ignore = size;
if (m_searchTask.isRunning())
return;

View File

@@ -44,7 +44,7 @@ namespace hex::plugin::builtin {
});
ImHexApi::HexEditor::addForegroundHighlightingProvider([this](u64 offset, const u8* buffer, size_t, bool) -> std::optional<color_t> {
hex::unused(buffer);
std::ignore = buffer;
if (!ImHexApi::Provider::isValid())
return std::nullopt;

View File

@@ -1535,7 +1535,7 @@ namespace hex::plugin::builtin {
auto mimeType = magic::getMIMEType(provider, 0, 100_KiB, true);
runtime.addPragma("MIME", [&mimeType, &foundCorrectType](const pl::PatternLanguage &runtime, const std::string &value) {
hex::unused(runtime);
std::ignore = runtime;
if (!magic::isValidMIMEType(value))
return false;
@@ -2191,7 +2191,8 @@ namespace hex::plugin::builtin {
});
ImHexApi::HexEditor::addBackgroundHighlightingProvider([this](u64 address, const u8 *data, size_t size, bool) -> std::optional<color_t> {
hex::unused(data, size);
std::ignore = data;
std::ignore = size;
if (m_runningEvaluators != 0)
return std::nullopt;
@@ -2232,7 +2233,8 @@ namespace hex::plugin::builtin {
});
ImHexApi::HexEditor::addTooltipProvider([this](u64 address, const u8 *data, size_t size) {
hex::unused(data, size);
std::ignore = data;
std::ignore = size;
if (TRY_LOCK(ContentRegistry::PatternLanguage::getRuntimeLock())) {
const auto &runtime = ContentRegistry::PatternLanguage::getRuntime();

View File

@@ -538,7 +538,7 @@ namespace hex::plugin::builtin {
// Clear project context if we go back to the welcome screen
EventProviderChanged::subscribe([](const hex::prv::Provider *oldProvider, const hex::prv::Provider *newProvider) {
hex::unused(oldProvider);
std::ignore = oldProvider;
if (newProvider == nullptr) {
ProjectFile::clearPath();
RequestUpdateWindowTitle::post();

View File

@@ -93,7 +93,8 @@ namespace hex::plugin::decompress {
return true;
#else
hex::unused(evaluator, params);
std::ignore = evaluator;
std::ignore = params;
err::E0012.throwError("hex::dec::zlib_decompress is not available. Please recompile ImHex with zlib support.");
#endif
});
@@ -140,7 +141,8 @@ namespace hex::plugin::decompress {
return true;
#else
hex::unused(evaluator, params);
std::ignore = evaluator;
std::ignore = params;
err::E0012.throwError("hex::dec::bzlib_decompress is not available. Please recompile ImHex with bzip2 support.");
#endif
@@ -195,7 +197,8 @@ namespace hex::plugin::decompress {
return true;
#else
hex::unused(evaluator, params);
std::ignore = evaluator;
std::ignore = params;
err::E0012.throwError("hex::dec::lzma_decompress is not available. Please recompile ImHex with liblzma support.");
#endif
});
@@ -263,7 +266,8 @@ namespace hex::plugin::decompress {
return true;
#else
hex::unused(evaluator, params);
std::ignore = evaluator;
std::ignore = params;
err::E0012.throwError("hex::dec::zstd_decompress is not available. Please recompile ImHex with zstd support.");
#endif
});
@@ -324,7 +328,8 @@ namespace hex::plugin::decompress {
return true;
#else
hex::unused(evaluator, params);
std::ignore = evaluator;
std::ignore = params;
err::E0012.throwError("hex::dec::lz4_decompress is not available. Please recompile ImHex with liblz4 support.");
#endif
});

View File

@@ -63,7 +63,7 @@ namespace hex::plugin::hashes {
});
ImHexApi::HexEditor::addTooltipProvider([this](u64 address, const u8 *data, size_t size) {
hex::unused(data);
std::ignore = data;
auto selection = ImHexApi::HexEditor::getSelection();

View File

@@ -21,7 +21,8 @@ namespace hex::ui {
DataVisualizerAscii() : DataVisualizer("ASCII", 1, 1) { }
void draw(u64 address, const u8 *data, size_t size, bool upperCase) override {
hex::unused(address, upperCase);
std::ignore = address;
std::ignore = upperCase;
if (size == 1) {
const char c = char(data[0]);
@@ -37,7 +38,9 @@ namespace hex::ui {
}
bool drawEditing(u64 address, u8 *data, size_t size, bool upperCase, bool startedEditing) override {
hex::unused(address, startedEditing, upperCase);
std::ignore = address;
std::ignore = startedEditing;
std::ignore = upperCase;
if (size == 1) {
struct UserData {

View File

@@ -747,7 +747,7 @@ namespace hex::ui {
void PatternDrawer::visit(pl::ptrn::PatternPadding& pattern) {
// Do nothing
hex::unused(pattern);
std::ignore = pattern;
}
void PatternDrawer::visit(pl::ptrn::PatternPointer& pattern) {

View File

@@ -43,7 +43,7 @@ namespace hex::plugin::windows {
ImGui::Combo(
"hex.windows.view.tty_console.baud"_lang, &m_selectedBaudRate, [](void *data, int idx) {
hex::unused(data);
std::ignore = data;
return ViewTTYConsole::BaudRates[idx];
},
@@ -52,7 +52,7 @@ namespace hex::plugin::windows {
ImGui::Combo(
"hex.windows.view.tty_console.num_bits"_lang, &m_selectedNumBits, [](void *data, int idx) {
hex::unused(data);
std::ignore = data;
return ViewTTYConsole::NumBits[idx];
},
@@ -61,7 +61,7 @@ namespace hex::plugin::windows {
ImGui::Combo(
"hex.windows.view.tty_console.stop_bits"_lang, &m_selectedStopBits, [](void *data, int idx) {
hex::unused(data);
std::ignore = data;
return ViewTTYConsole::StopBits[idx];
},
@@ -70,7 +70,7 @@ namespace hex::plugin::windows {
ImGui::Combo(
"hex.windows.view.tty_console.parity_bits"_lang, &m_selectedParityBits, [](void *data, int idx) {
hex::unused(data);
std::ignore = data;
return ViewTTYConsole::ParityBits[idx];
},

View File

@@ -115,7 +115,8 @@ namespace hex::plugin::yara {
return context->includeBuffer.c_str();
},
[](const char *ptr, void *userData) {
hex::unused(ptr, userData);
std::ignore = ptr;
std::ignore = userData;
},
&resultContext
);