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 "hxkey.hpp"
25#include "hxhash_table.hpp"
26
27HX_NS_BEGIN_
28
29// Include internals
30#include "detail/hxconsole_detail.hpp"
31
35void hxconsole_deregister(const char* id_) hxattr_nonnull(1);
36
40bool hxconsole_exec_line(const char* command_) hxattr_nonnull(1);
41
44bool hxconsole_help(void);
45
46#if HX_USE_FILE_IO
47class hxfile;
53
57bool hxconsole_exec_filename(const char* filename_) hxattr_nonnull(1);
58#endif // HX_USE_FILE_IO
59
60HX_NS_END_
61#endif // !HX_USE_MACROS_WITH_MODULE
62
67#define hxconsole_command(x_) static HX_NS_PREFIX_ hxdetail_::hxconsole_constructor_ \
68 hxg_console_symbol_##x_(HX_NS_PREFIX_ hxdetail_::hxconsole_command_factory_(&(x_)), #x_)
69
75#define hxconsole_command_named(x_, name_) static HX_NS_PREFIX_ hxdetail_::hxconsole_constructor_ \
76 hxg_console_symbol_##name_(HX_NS_PREFIX_ hxdetail_::hxconsole_command_factory_(&(x_)), #name_)
77
85#define hxconsole_variable(x_) static HX_NS_PREFIX_ hxdetail_::hxconsole_constructor_ \
86 hxg_console_symbol_##x_(HX_NS_PREFIX_ hxdetail_::hxconsole_variable_factory_(&(x_)), #x_)
87
96#define hxconsole_variable_named(x_, name_) static HX_NS_PREFIX_ hxdetail_::hxconsole_constructor_ \
97 hxg_console_symbol_##name_(HX_NS_PREFIX_ hxdetail_::hxconsole_variable_factory_(&(x_)), #name_)
98
99#else // !HX_USE_CONSOLE
100
101// Avoid complaints about stray ; at global scope.
102#define hxconsole_command(x_) static_assert(true, "")
103#define hxconsole_command_named(x_, name_) static_assert(true, "")
104#define hxconsole_variable(x_) static_assert(true, "")
105#define hxconsole_variable_named(x_, name_) static_assert(true, "")
106
107#endif // !HX_USE_CONSOLE
hxfile - Single-ownership C++ RAII abstraction for file I/O.
Definition hxfile.hpp:70
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 except internal test symbols to the console log.
A fixed-size hash table with embedded singly-linked list buckets.
User-specializable key-equal, key-less, and key-hash callables.
#define hxattr_nonnull(...)
hxattr_nonnull - Indicates that a function has args that should not be null.
Definition hxsettings.h:106
Provides core macros, memory management and feature detection.