libhatchet
Loading...
Searching...
No Matches
hxconsole.hpp
Go to the documentation of this file.
1#pragma once
2// SPDX-FileCopyrightText: © 2017-2026 Adrian Johnston.
3// SPDX-License-Identifier: MIT
4// This file is licensed under the MIT license found in the LICENSE.md file.
5
17
18#include "libhatchet.h"
19
20#if HX_USE_CONSOLE
21#if !(HX_USE_MACROS_WITH_MODULE)
22
23#include <limits.h>
24#include "hxutility.h"
25
26HX_NS_BEGIN_
27
28// Include internals
29#include "detail/hxconsole_detail.hpp"
30
34void hxconsole_deregister(const char* id_) hxattr_nonnull(1);
35
39bool hxconsole_exec_line(const char* command_) hxattr_nonnull(1);
40
42bool hxconsole_help(void);
43
44#if HX_USE_FILE_IO
45class hxfile;
52
56bool hxconsole_exec_filename(const char* filename_) hxattr_nonnull(1);
57#endif // HX_USE_FILE_IO
58
59HX_NS_END_
60#endif // !HX_USE_MACROS_WITH_MODULE
61
66#define hxconsole_command(x_) static HX_NS_PREFIX_ hxdetail_::hxconsole_constructor_ \
67 hxg_console_symbol_##x_(HX_NS_PREFIX_ hxdetail_::hxconsole_command_factory_(&(x_)), #x_)
68
74#define hxconsole_command_named(x_, name_) static HX_NS_PREFIX_ hxdetail_::hxconsole_constructor_ \
75 hxg_console_symbol_##name_(HX_NS_PREFIX_ hxdetail_::hxconsole_command_factory_(&(x_)), #name_)
76
84#define hxconsole_variable(x_) static HX_NS_PREFIX_ hxdetail_::hxconsole_constructor_ \
85 hxg_console_symbol_##x_(HX_NS_PREFIX_ hxdetail_::hxconsole_variable_factory_(&(x_)), #x_)
86
95#define hxconsole_variable_named(x_, name_) static HX_NS_PREFIX_ hxdetail_::hxconsole_constructor_ \
96 hxg_console_symbol_##name_(HX_NS_PREFIX_ hxdetail_::hxconsole_variable_factory_(&(x_)), #name_)
97
98#else // !HX_USE_CONSOLE
99
100// Avoid complaints about stray ; at global scope.
101#define hxconsole_command(x_) static_assert(true, "")
102#define hxconsole_command_named(x_, name_) static_assert(true, "")
103#define hxconsole_variable(x_) static_assert(true, "")
104#define hxconsole_variable_named(x_, name_) static_assert(true, "")
105
106#endif // !HX_USE_CONSOLE
hxfile - Single-ownership C++ RAII abstraction for file I/O.
Definition hxfile.hpp:66
bool hxconsole_exec_line(const char *command_)
hxconsole_exec_line - Evaluates a console command to either call a function or set a variable.
bool hxconsole_exec_filename(const char *filename_)
hxconsole_exec_filename - Opens a configuration file by name and executes it.
bool hxconsole_exec_file(hxfile &file_)
hxconsole_exec_file - Executes a configuration file that is opened for reading.
HX_NS_BEGIN_ void hxconsole_deregister(const char *id_)
hxconsole_deregister - Explicitly deregisters a console symbol.
bool hxconsole_help(void)
hxconsole_help - Logs every console symbol to the console log.
#define hxattr_nonnull(...)
hxattr_nonnull - Indicates that a function has args that should not be null.
Definition hxsettings.h:97
A few utility functions and most standard C++ meta programming functions.
Provides core macros, memory management and feature detection.