Changeset 7163 for code/trunk/src/libraries/core/Executor.cc
- Timestamp:
- Aug 11, 2010, 8:55:13 AM (15 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/libraries/core/Executor.cc
r6417 r7163 30 30 #include "Executor.h" 31 31 32 #include <algorithm> 33 32 34 #include "util/Convert.h" 35 #include "util/Debug.h" 36 #include "util/StringUtils.h" 37 #include "util/SubString.h" 33 38 #include "Language.h" 34 39 … … 63 68 bool Executor::parse(const std::string& params, const std::string& delimiter) const 64 69 { 65 EXECUTOR_PARSE(normal); 70 unsigned int paramCount = this->functor_->getParamCount(); 71 72 if (paramCount == 0) 73 { 74 COUT(5) << "Calling Executor " << this->name_ << " through parser without parameters." << std::endl; 75 (*this->functor_)(); 76 } 77 else if (paramCount == 1) 78 { 79 const std::string& temp = getStripped(params); 80 if (!temp.empty()) 81 { 82 COUT(5) << "Calling Executor " << this->name_ << " through parser with one parameter, using whole string: " << params << std::endl; 83 (*this->functor_)(MultiType(params)); 84 } 85 else if (this->bAddedDefaultValue_[0]) 86 { 87 COUT(5) << "Calling Executor " << this->name_ << " through parser with one parameter, using default value: " << this->defaultValue_[0] << std::endl; 88 (*this->functor_)(this->defaultValue_[0]); 89 } 90 else 91 { 92 COUT(2) << "Warning: Can't call executor " << this->name_ << " through parser: Not enough parameters or default values given (input: " << temp << ")." << std::endl; 93 return false; 94 } 95 } 96 else 97 { 98 SubString tokens(params, delimiter, SubString::WhiteSpaces, false, '\\', true, '"', true, '(', ')', true, '\0'); 99 100 for (unsigned int i = tokens.size(); i < this->functor_->getParamCount(); i++) 101 { 102 if (!this->bAddedDefaultValue_[i]) 103 { 104 COUT(2) << "Warning: Can't call executor " << this->name_ << " through parser: Not enough parameters or default values given (input:" << params << ")." << std::endl; 105 return false; 106 } 107 } 108 109 MultiType param[MAX_FUNCTOR_ARGUMENTS]; 110 COUT(5) << "Calling Executor " << this->name_ << " through parser with " << paramCount << " parameters, using " << tokens.size() << " tokens ("; 111 for (unsigned int i = 0; i < tokens.size() && i < MAX_FUNCTOR_ARGUMENTS; i++) 112 { 113 param[i] = tokens[i]; 114 if (i != 0) 115 { 116 COUT(5) << ", "; 117 } 118 COUT(5) << tokens[i]; 119 } 120 COUT(5) << ") and " << std::max((int)paramCount - (int)tokens.size(), 0) << " default values ("; 121 for (unsigned int i = tokens.size(); i < paramCount; i++) 122 { 123 param[i] = this->defaultValue_[i]; 124 if (i != 0) 125 { 126 COUT(5) << ", "; 127 } 128 COUT(5) << this->defaultValue_[i]; 129 } 130 COUT(5) << ")." << std::endl; 131 132 if ((tokens.size() > paramCount) && (this->functor_->getTypenameParam(paramCount - 1) == "string")) 133 param[paramCount - 1] = tokens.subSet(paramCount - 1).join(); 134 135 switch(paramCount) 136 { 137 case 2: 138 (*this->functor_)(param[0], param[1]); 139 break; 140 case 3: 141 (*this->functor_)(param[0], param[1], param[2]); 142 break; 143 case 4: 144 (*this->functor_)(param[0], param[1], param[2], param[3]); 145 break; 146 case 5: 147 (*this->functor_)(param[0], param[1], param[2], param[3], param[4]); 148 break; 149 } 150 } 151 152 return true; 66 153 } 67 154
Note: See TracChangeset
for help on using the changeset viewer.