Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

CommandEvaluation

Description

A CommandEvaluation is returned by CommandExecutor::evaluate(string). A CommandEvaluation is a container, storing a parsed ConsoleCommand. It's in fact just a function-pointer and a set of prepared arguments. This allows very efficient calls of the parsed command which is important if the same command gets called over and over (for example if it's bound to a key).

Usage

  • getOriginalCommand(): Returns the original command string as it was typed by the user
  • getCommand(): Returns the final command string, modified by the CommandExecutor
  • isValid(): Returns true if the command exists and all needed arguments are given
  • getConsoleCommand(): Returns a pointer to the parsed ConsoleCommand
  • hasReturnvalue(): Returns true if the command returns a value
  • getReturnvalue(): Returns the returnvalue (if any)
  • evaluateParams(): Prepares the given arguments (by converting them to the desired types)
  • setEvaluatedParameter(param-index (0-4), value): Changes an already evaluated parameter (value is a MultiType so you can assign everything, but the exact type is better for performance)
  • getEvaluatedParameter(param-index (0-4)): Returns an evaluated parameter
  • setAdditionalParameter(parameter): Adds additional parameters (as a string). Warning: This destroys the evaluation of the parameters!
  • getAdditionalParameter(): Returns the additional parameters (if any)

Example

// Get the evaluation:
CommandEvaluation myevaluation =   \
              CommandExecutor::evaluate("MyClass myfunction 10");

// Call MyClass::myfunction(10) a hundred times:
for (int i = 0; i < 100; i++)
    myevaluation.execute();

// Change the evaluated parameter from 10 to 33:
myevaluation.setEvaluatedParameter(33);

// Call MyClass::myfunction(33) once:
myevaluation.execute();
Last modified 8 years ago Last modified on Apr 12, 2017, 10:39:10 PM