#pragma once #include #include #include #include #include #include "path.hpp" namespace prism::console { enum class argument_type { String, Integer, Boolean, Float, Double }; struct console_argument { explicit console_argument(std::string_view string) : data(string.data()) {} explicit console_argument(bool data) : data(data) {} explicit console_argument(int data) : data(data) {} explicit console_argument(float data) : data(data) {} explicit console_argument(double data) : data(data) {} [[nodiscard]] argument_type query_type() const { if (std::holds_alternative(data)) return argument_type::String; else if (std::holds_alternative(data)) return argument_type::Integer; else if (std::holds_alternative(data)) return argument_type::Boolean; else if (std::holds_alternative(data)) return argument_type::Float; else if (std::holds_alternative(data)) return argument_type::Double; return argument_type::String; // fallback?? } std::variant data; }; using arguments = std::vector; using function_ptr = std::function; struct argument_format { explicit argument_format(const int num_arguments) : num_arguments(num_arguments) {} int num_arguments = 0; std::vector argument_types; }; void load_cfg(const prism::path& path); void register_command(std::string_view name, argument_format expected_format, function_ptr function); void invoke_command(std::string_view name, arguments arguments); void parse_and_invoke_command(std::string_view command); void register_variable(std::string_view name, bool& variable); void register_variable(std::string_view name, float& variable); void register_variable(std::string_view name, int& variable); void register_variable(std::string_view name, double& variable); } // namespace prism::console