QcCommandRegistry Class
All commands of a server, by name and alias. More...
| Header: | #include <server/commands/QcCommandRegistry.h> |
Public Functions
| QcStatus | add(QcCommandSpec spec) |
| void | addBuiltIn(QcCommandSpec spec) |
| QList<const QcCommandSpec *> | commands() const |
| const QcCommandSpec * | find(QStringView name) const |
Static Public Members
| bool | isValidName(QStringView name) |
| const qsizetype | maxNameLength |
Detailed Description
The game's commands register here like any later C++ extension would (docs/Modding.md); data-only mods add macros instead (decision E-248).
Member Function Documentation
QcStatus QcCommandRegistry::add(QcCommandSpec spec)
Adds the command spec. Returns an error for invalid names, a missing handler or texts, and names or aliases that are taken. Pointers from find() and commands() stay valid until the next add.
void QcCommandRegistry::addBuiltIn(QcCommandSpec spec)
Adds spec, one of the game's own commands, whose names are known to be free: a failure is a programming error and only logged.
QList<const QcCommandSpec *> QcCommandRegistry::commands() const
Returns every command, sorted by name.
const QcCommandSpec *QcCommandRegistry::find(QStringView name) const
Returns the command named name by name or alias (lower case); nullptr when there is none.
[static] bool QcCommandRegistry::isValidName(QStringView name)
Returns whether name is a valid command name: lower-case letters, digits and '_', at most maxNameLength.
Member Variable Documentation
const qsizetype QcCommandRegistry::maxNameLength
The longest command name.