Changeset 8836
- Timestamp:
- Aug 13, 2011, 7:30:04 PM (13 years ago)
- Location:
- code/branches/output/src/libraries/core/command
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/output/src/libraries/core/command/CommandEvaluation.cc
r8806 r8836 131 131 132 132 if (!this->execCommand_) 133 *error = CommandExecutor:: Error;133 *error = CommandExecutor::Inexistent; 134 134 else if (!this->execCommand_->isActive()) 135 135 *error = CommandExecutor::Deactivated; … … 187 187 if (bPrintError) 188 188 orxout(internal_error, context::commands) << "Can't evaluate arguments, no console command assigned." << endl; 189 return CommandExecutor:: Error;189 return CommandExecutor::Inexistent; 190 190 } 191 191 -
code/branches/output/src/libraries/core/command/CommandExecutor.cc
r8806 r8836 69 69 @return Returns the error-code (see @ref CommandExecutorErrorCodes "error codes") 70 70 */ 71 /* static */ int CommandExecutor::execute(const std::string& command, bool useTcl )71 /* static */ int CommandExecutor::execute(const std::string& command, bool useTcl, bool printErrors) 72 72 { 73 73 int error; 74 74 CommandExecutor::queryMT(command, &error, useTcl); 75 if (error) 76 orxout(user_error) << "Can't execute \"" << command << "\", " << CommandExecutor::getErrorDescription(error) << ". (execute)" << endl; 75 77 return error; 76 78 } … … 85 87 /* static */ MultiType CommandExecutor::queryMT(const std::string& command, int* error, bool useTcl) 86 88 { 89 MultiType result; 90 int error_internal; 91 87 92 if (useTcl) 88 93 { 89 94 // pass the command to tcl 90 re turn TclBind::eval(command, error);95 result = TclBind::eval(command, &error_internal); 91 96 } 92 97 else … … 108 113 109 114 // query the command and return its return-value 110 return evaluation.query(error); 111 } 115 result = evaluation.query(&error_internal); 116 } 117 118 if (error) 119 *error = error_internal; 120 else if (error_internal) 121 orxout(user_error) << "Can't execute \"" << command << "\", " << CommandExecutor::getErrorDescription(error_internal) << ". (query)" << endl; 122 123 return result; 112 124 } 113 125 … … 172 184 173 185 /** 186 @brief Returns a description of the error code. 187 @param error The error code 188 */ 189 /* static */ std::string CommandExecutor::getErrorDescription(int error) 190 { 191 switch (error) 192 { 193 case CommandExecutor::Inexistent: return "command doesn't exist"; 194 case CommandExecutor::Incomplete: return "not enough arguments given"; 195 case CommandExecutor::Deactivated: return "command is not active"; 196 case CommandExecutor::Denied: return "access denied"; 197 case CommandExecutor::Error: return "an error occurred"; 198 default: return ""; 199 } 200 } 201 202 /** 174 203 @brief Gets an evaluated command from the cache. 175 204 @param command The command that should be looked up in the cache -
code/branches/output/src/libraries/core/command/CommandExecutor.h
r7401 r8836 111 111 // tolua_end 112 112 public: 113 static int execute(const std::string& command, bool useTcl = true ); // tolua_export113 static int execute(const std::string& command, bool useTcl = true, bool printErrors = true); // tolua_export 114 114 115 115 static MultiType queryMT(const std::string& command, int* error = 0, bool useTcl = true); … … 119 119 120 120 static const int Success = 0; ///< Error code for "success" (or no error) 121 static const int Error = 1;///< Error code if the command doesn't exist121 static const int Inexistent = 1; ///< Error code if the command doesn't exist 122 122 static const int Incomplete = 2; ///< Error code if the command needs more arguments 123 123 static const int Deactivated = 3; ///< Error code if the command is not active 124 124 static const int Denied = 4; ///< Error code if the command needs a different access level 125 static const int Error = 5; ///< Error code if the command returned an error 126 127 static std::string getErrorDescription(int error); 125 128 126 129 static MultiType unhide(const std::string& command); -
code/branches/output/src/libraries/core/command/Shell.cc
r8834 r8836 389 389 const std::string& result = CommandExecutor::query(this->inputBuffer_->get(), &error); 390 390 if (error) 391 { 392 switch (error) 393 { 394 case CommandExecutor::Error: this->addOutput("Error: Can't execute \"" + this->inputBuffer_->get() + "\", command doesn't exist. (S)", UserError); break; 395 case CommandExecutor::Incomplete: this->addOutput("Error: Can't execute \"" + this->inputBuffer_->get() + "\", not enough arguments given. (S)", UserError); break; 396 case CommandExecutor::Deactivated: this->addOutput("Error: Can't execute \"" + this->inputBuffer_->get() + "\", command is not active. (S)", UserError); break; 397 case CommandExecutor::Denied: this->addOutput("Error: Can't execute \"" + this->inputBuffer_->get() + "\", access denied. (S)", UserError); break; 398 } 399 } 391 this->addOutput("Error: Can't execute \"" + this->inputBuffer_->get() + "\", " + CommandExecutor::getErrorDescription(error) + ". (Shell)", UserError); 400 392 else if (result != "") 401 {402 393 this->addOutput(result, Result); 403 }404 394 405 395 this->clearInput(); -
code/branches/output/src/libraries/core/command/TclBind.cc
r8806 r8836 187 187 error = evaluation.execute(); 188 188 189 switch (error) 190 { 191 case CommandExecutor::Error: orxout(user_error) << "Can't execute command \"" << command << "\", command doesn't exist. (B)" << endl; break; 192 case CommandExecutor::Incomplete: orxout(user_error) << "Can't execute command \"" << command << "\", not enough arguments given. (B)" << endl; break; 193 case CommandExecutor::Deactivated: orxout(user_error) << "Can't execute command \"" << command << "\", command is not active. (B)" << endl; break; 194 case CommandExecutor::Denied: orxout(user_error) << "Can't execute command \"" << command << "\", access denied. (B)" << endl; break; 195 } 196 197 if (error == CommandExecutor::Error) 198 orxout(user_info) << "Did you mean \"" << evaluation.getCommandSuggestion() << "\"?" << endl; 189 if (error) 190 { 191 orxout(user_error) << "Can't execute command \"" << command << "\", " + CommandExecutor::getErrorDescription(error) + ". (TclBind)" << endl; 192 if (error == CommandExecutor::Inexistent) 193 orxout(user_info) << "Did you mean \"" << evaluation.getCommandSuggestion() << "\"?" << endl; 194 } 199 195 200 196 return result; -
code/branches/output/src/libraries/core/command/TclThreadManager.cc
r8806 r8836 449 449 int error; 450 450 output = CommandExecutor::query(command, &error, false); 451 switch (error) 452 { 453 case CommandExecutor::Error: TclThreadManager::error("Can't execute command \"" + command + "\", command doesn't exist. (T)"); break; 454 case CommandExecutor::Incomplete: TclThreadManager::error("Can't execute command \"" + command + "\", not enough arguments given. (T)"); break; 455 case CommandExecutor::Deactivated: TclThreadManager::error("Can't execute command \"" + command + "\", command is not active. (T)"); break; 456 case CommandExecutor::Denied: TclThreadManager::error("Can't execute command \"" + command + "\", access denied. (T)"); break; 457 } 451 if (error) 452 TclThreadManager::error("Can't execute command \"" + command + "\", " + CommandExecutor::getErrorDescription(error) + ". (TclThreadManager)"); 458 453 } 459 454 else
Note: See TracChangeset
for help on using the changeset viewer.