MCPcopy Create free account
hub / github.com/codereader/DarkRadiant / canExecute

Method canExecute

radiantcore/commandsystem/CommandSystem.cpp:335–355  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

333}
334
335bool CommandSystem::canExecute(const std::string& input) const
336{
337 // Check the first command, ignoring arguments or subsequent commands.
338 // For now we discount the possibility that the specific arguments could
339 // change whether a command can be run, although in theory this could be possible.
340
341 // Parsing the whole command string is rather expensive, so extract just the first token
342 CommandTokeniser tokeniser(input);
343
344 if (tokeniser.hasMoreTokens())
345 {
346 if (auto cmd = _commands.find(tokeniser.nextToken()); cmd != _commands.end())
347 {
348 return cmd->second->canExecute();
349 }
350 }
351
352 // We only return false if we know that a command cannot run; if the command
353 // was not found at all, return true by default.
354 return true;
355}
356
357void CommandSystem::execute(const std::string& input)
358{

Callers 2

aboutToOpenMenuMethod · 0.45
TEST_FFunction · 0.45

Calls 4

hasMoreTokensMethod · 0.45
findMethod · 0.45
nextTokenMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected