This class is used to execute and evaluate command-strings.
More...
#include </home/jenkins/workspace/orxonox_doxygen_trunk/src/libraries/core/command/CommandExecutor.h>
|
static void | _autocomplete (const std::string &group, const std::string &name) |
| Pseudo console command used whenever no real command is available. In these cases this command provides auto-completion for console commands and groups. More...
|
|
static void | alias (const std::string &alias, const std::string &command) |
| This function is used as console command which saves a command and optionally also it's arguments as a new console command with a new name. More...
|
|
static CommandEvaluation | evaluate (const std::string &command) |
| Evaluates the given command. More...
|
|
static int | execute (const std::string &command, bool useTcl=true, bool printErrors=true) |
| Executes a command. More...
|
|
static std::string | getErrorDescription (int error) |
| Returns a description of the error code. More...
|
|
static std::string | query (const std::string &command, int *error=NULL, bool useTcl=true) |
| Executes a command and returns its return-value as string. More...
|
|
static MultiType | queryMT (const std::string &command, int *error=nullptr, bool useTcl=true) |
| Executes a command and returns its return-value. More...
|
|
static MultiType | unhide (const std::string &command) |
| This function is used as console command which executes commands that are usually hidden. More...
|
|
|
static constexpr int | Deactivated = 3 |
| Error code if the command is not active. More...
|
|
static constexpr int | Denied = 4 |
| Error code if the command needs a different access level. More...
|
|
static constexpr int | Error = 5 |
| Error code if the command returned an error. More...
|
|
static constexpr int | Incomplete = 2 |
| Error code if the command needs more arguments. More...
|
|
static constexpr int | Inexistent = 1 |
| Error code if the command doesn't exist. More...
|
|
static constexpr int | Success = 0 |
| Error code for "success" (or no error) More...
|
|
|
std::map< std::string, CacheEntry > | cache_ |
| A map that connects command strings and evaluated commands in the cache. More...
|
|
std::list< std::string > | cachelist_ |
| A list used to sort the elements in the cache by their age. More...
|
|
This class is used to execute and evaluate command-strings.
CommandExecutor executes command-strings and returns evaluated commands. It's also possible to execute Tcl commands if the corresponding argument of execute() is true.
- See also
- See this description for more information and some examples.
orxonox::CommandExecutor::CommandExecutor |
( |
| ) |
|
|
privatedefault |
orxonox::CommandExecutor::~CommandExecutor |
( |
| ) |
|
|
privatedefault |
static void orxonox::CommandExecutor::_autocomplete |
( |
const std::string & |
group, |
|
|
const std::string & |
name |
|
) |
| |
|
inlinestatic |
Pseudo console command used whenever no real command is available. In these cases this command provides auto-completion for console commands and groups.
void orxonox::CommandExecutor::alias |
( |
const std::string & |
alias, |
|
|
const std::string & |
command |
|
) |
| |
|
static |
This function is used as console command which saves a command and optionally also it's arguments as a new console command with a new name.
- Parameters
-
alias | The name of the new command alias |
command | The existing command and (optionally) its arguments |
void orxonox::CommandExecutor::cache |
( |
const std::string & |
command, |
|
|
const CommandEvaluation & |
evaluation |
|
) |
| |
|
private |
Writes a command evaluation for a given command to the cache.
Evaluates the given command.
- Parameters
-
command | A string containing the command |
- Returns
- Returns an instance of CommandEvaluation, which contains the evaluated ConsoleCommand, if the command is valid.
Evaluates the given command string and returns an instance of CommandEvaluation. If the command is valid, this contains the evaluated ConsoleCommand. Otherwise it can still be used to print hints or complete the command.
- Note
- Tcl commands can not be evaluated. You have to pass them to execute() or to TclBind directly.
int orxonox::CommandExecutor::execute |
( |
const std::string & |
command, |
|
|
bool |
useTcl = true , |
|
|
bool |
printErrors = true |
|
) |
| |
|
static |
Executes a command.
- Parameters
-
command | A string containing the command |
useTcl | If true, the command is passed to tcl (see TclBind) |
printErrors | If true, print an error when command failed |
- Returns
- Returns the error-code (see error codes)
bool orxonox::CommandExecutor::getCached |
( |
const std::string & |
command, |
|
|
CommandEvaluation & |
evaluation |
|
) |
| |
|
private |
Gets an evaluated command from the cache.
- Parameters
-
command | The command that should be looked up in the cache |
evaluation | Reference to a CommandEvaluation that will be used to return the cached evaluation. |
- Returns
- Returns true if the command was found in the cache
std::string orxonox::CommandExecutor::getErrorDescription |
( |
int |
error | ) |
|
|
static |
Returns a description of the error code.
- Parameters
-
std::string orxonox::CommandExecutor::query |
( |
const std::string & |
command, |
|
|
int * |
error = NULL , |
|
|
bool |
useTcl = true |
|
) |
| |
|
static |
Executes a command and returns its return-value as string.
- Parameters
-
command | A string containing the command |
error | A pointer to a value (or nullptr) where the error-code should be written to (see error codes) |
useTcl | If true, the command is passed to tcl (see TclBind) |
- Returns
- Returns the return-value of the command converted to a string (or "" if there's no return value)
MultiType orxonox::CommandExecutor::queryMT |
( |
const std::string & |
command, |
|
|
int * |
error = nullptr , |
|
|
bool |
useTcl = true |
|
) |
| |
|
static |
Executes a command and returns its return-value.
- Parameters
-
command | A string containing the command |
error | A pointer to a value (or nullptr) where the error-code should be written to (see error codes) |
useTcl | If true, the command is passed to tcl (see TclBind) |
- Returns
- Returns the return-value of the command (if any - MultiType::Null otherwise)
MultiType orxonox::CommandExecutor::unhide |
( |
const std::string & |
command | ) |
|
|
static |
This function is used as console command which executes commands that are usually hidden.
The argument completion function of this console commands is used to find and enter hidden commands and their arguments.
std::map<std::string, CacheEntry> orxonox::CommandExecutor::cache_ |
|
private |
A map that connects command strings and evaluated commands in the cache.
std::list<std::string> orxonox::CommandExecutor::cachelist_ |
|
private |
A list used to sort the elements in the cache by their age.
constexpr int orxonox::CommandExecutor::Deactivated = 3 |
|
static |
Error code if the command is not active.
constexpr int orxonox::CommandExecutor::Denied = 4 |
|
static |
Error code if the command needs a different access level.
constexpr int orxonox::CommandExecutor::Error = 5 |
|
static |
Error code if the command returned an error.
constexpr int orxonox::CommandExecutor::Incomplete = 2 |
|
static |
Error code if the command needs more arguments.
constexpr int orxonox::CommandExecutor::Inexistent = 1 |
|
static |
Error code if the command doesn't exist.
constexpr int orxonox::CommandExecutor::Success = 0 |
|
static |
Error code for "success" (or no error)
The documentation for this class was generated from the following files: