Archived
1
Fork 0
This repository has been archived on 2025-04-12. You can view files and clone it, but cannot push or open issues or pull requests.
prism/engine/core/include/console.hpp

34 lines
840 B
C++
Raw Normal View History

2020-09-20 22:37:15 -04:00
#pragma once
#include <string_view>
#include <functional>
#include <vector>
#include <variant>
namespace console {
using ConsoleArgument = std::variant<std::string, int, bool>;
enum class ArgType {
String,
Integer,
Boolean
};
struct Arguments {
std::vector<ConsoleArgument> arguments;
};
using FunctionPtr = std::function<void(console::Arguments)>;
struct ArgumentFormat {
ArgumentFormat(const int num_arguments) : num_arguments(num_arguments) {}
int num_arguments = 0;
std::vector<ArgType> argument_types;
};
void register_command(const std::string_view name, const ArgumentFormat expected_format, const FunctionPtr function);
void invoke_command(const std::string_view name, const Arguments arguments);
}