#pragma once #include #include #include #include #include #include namespace hex::plugin::builtin { class ProviderExtraData { public: struct Data { bool dataDirty = false; struct PatternLanguage { struct PatternVariable { bool inVariable; bool outVariable; pl::core::Token::ValueType type; pl::core::Token::Literal value; }; enum class EnvVarType { Integer, Float, String, Bool }; struct EnvVar { u64 id; std::string name; pl::core::Token::Literal value; EnvVarType type; bool operator==(const EnvVar &other) const { return this->id == other.id; } }; std::string sourceCode; std::mutex runtimeMutex; std::unique_ptr runtime; std::vector> console; bool executionDone = true; std::optional lastEvaluationError; std::vector> lastEvaluationLog; std::map lastEvaluationOutVars; std::map patternVariables; std::list envVarEntries; } patternLanguage; std::list bookmarks; struct DataProcessor { std::list endNodes; std::list> nodes; std::list links; std::vector dataOverlays; std::optional currNodeError; } dataProcessor; struct HexEditor { std::optional selectionStart, selectionEnd; float scrollPosition = 0.0F; } editor; }; static Data& getCurrent() { return get(ImHexApi::Provider::get()); } static Data& get(hex::prv::Provider *provider) { return s_data[provider]; } static void erase(hex::prv::Provider *provider) { s_data.erase(provider); } static bool markDirty() { return getCurrent().dataDirty = true; } private: ProviderExtraData() = default; static inline std::map s_data = {}; }; }