Changeset 1402 for code/branches/console/src/core/CommandEvaluation.cc
- Timestamp:
- May 24, 2008, 2:51:31 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/console/src/core/CommandEvaluation.cc
r1390 r1402 45 45 this->originalCommand_ = command; 46 46 this->command_ = command; 47 this->originalCommandTokens_.split(command, " ", SubString::WhiteSpaces, false, '\\', false, '"', false, '(', ')', false, '\0');48 47 this->commandTokens_.split(command, " ", SubString::WhiteSpaces, false, '\\', false, '"', false, '(', ')', false, '\0'); 49 48 … … 79 78 } 80 79 81 COUT(4) << "CE_execute: " << this-> originalCommand_ << "\n";80 COUT(4) << "CE_execute: " << this->command_ << "\n"; 82 81 83 82 unsigned int startindex = this->getStartindex(); 84 if (this-> originalCommandTokens_.size() > startindex)85 return this->function_->parse(removeSlashes(this-> originalCommandTokens_.subSet(startindex).join() + this->getAdditionalParameter()));83 if (this->commandTokens_.size() > startindex) 84 return this->function_->parse(removeSlashes(this->commandTokens_.subSet(startindex).join() + this->getAdditionalParameter())); 86 85 else 87 86 return this->function_->parse(removeSlashes(this->additionalParameter_)); … … 93 92 { 94 93 case CS_Uninitialized: 94 std::cout << "complete: state: CS_Uninitialized" << std::endl; 95 case CS_Empty: 96 std::cout << "complete: state: CS_Empty" << std::endl; 97 case CS_ShortcutOrIdentifier: 98 std::cout << "complete: state: CS_ShortcutOrIdentifier" << std::endl; 99 { 100 std::list<std::pair<const std::string*, const std::string*> > temp; 101 temp.insert(temp.end(), this->listOfPossibleFunctions_.begin(), this->listOfPossibleFunctions_.end()); 102 temp.insert(temp.end(), this->listOfPossibleIdentifiers_.begin(), this->listOfPossibleIdentifiers_.end()); 103 if (temp.size() > 0) 104 { 105 std::cout << "complete: temp > 0" << std::endl; 106 return (CommandEvaluation::getCommonBegin(temp)); 107 } 108 } 109 break; 110 case CS_Shortcut_Params: 111 std::cout << "complete: state: CS_Shortcut_Params" << std::endl; 112 if (this->function_) 113 { 114 std::cout << "complete: function != 0" << std::endl; 115 if (this->commandTokens_.size() > 1) 116 return (this->function_->getName() + " " + this->commandTokens_.subSet(1, this->commandTokens_.size() - 1).join() + " " + CommandEvaluation::getCommonBegin(this->listOfPossibleArguments_)); 117 else 118 return (this->function_->getName() + " "); 119 } 120 break; 121 case CS_Shortcut_Finished: 122 std::cout << "complete: state: CS_Shortcut_Finished" << std::endl; 123 if (this->function_) 124 { 125 std::cout << "complete: function != 0" << std::endl; 126 if (this->commandTokens_.size() > 1) 127 return (this->function_->getName() + " " + this->commandTokens_.subSet(1, this->commandTokens_.size() - 1).join()); 128 else 129 return (this->function_->getName()); 130 } 131 break; 132 case CS_Function: 133 std::cout << "complete: state: CS_Function" << std::endl; 134 if (this->functionclass_) 135 { 136 std::cout << "complete: functionclass != 0" << std::endl; 137 return (this->functionclass_->getName() + " " + CommandEvaluation::getCommonBegin(this->listOfPossibleFunctions_)); 138 } 139 break; 140 case CS_Function_Params: 141 std::cout << "complete: state: CS_Function_Params" << std::endl; 142 if (this->functionclass_ && this->function_) 143 { 144 std::cout << "complete: function und functionclass != 0" << std::endl; 145 if (this->commandTokens_.size() > 2) 146 return (this->functionclass_->getName() + " " + this->function_->getName() + " " + this->commandTokens_.subSet(2, this->commandTokens_.size()).join() + " " + CommandEvaluation::getCommonBegin(this->listOfPossibleArguments_)); 147 else 148 return (this->functionclass_->getName() + " " + this->function_->getName() + " "); 149 } 150 break; 151 case CS_Function_Finished: 152 std::cout << "complete: state: CS_Function_Finished" << std::endl; 153 if (this->functionclass_ && this->function_) 154 { 155 std::cout << "complete: function und functionclass != 0" << std::endl; 156 if (this->commandTokens_.size() > 2) 157 return (this->functionclass_->getName() + " " + this->function_->getName() + " " + this->commandTokens_.subSet(2, this->commandTokens_.size()).join()); 158 else 159 return (this->functionclass_->getName() + " " + this->function_->getName()); 160 } 161 break; 162 case CS_Error: 163 std::cout << "complete: state: CS_Error" << std::endl; 164 break; 165 } 166 167 return this->originalCommand_; 168 } 169 170 std::string CommandEvaluation::hint() const 171 { 172 switch (this->state_) 173 { 174 case CS_Uninitialized: 175 break; 95 176 case CS_Empty: 96 177 case CS_ShortcutOrIdentifier: 97 { 98 std::list<std::pair<const std::string*, const std::string*> > temp; 99 if (this->state_ == CS_Empty) 100 { 101 temp.insert(temp.end(), this->listOfPossibleFunctions_.begin(), this->listOfPossibleFunctions_.end()); 102 temp.insert(temp.end(), this->listOfPossibleIdentifiers_.begin(), this->listOfPossibleIdentifiers_.end()); 103 } 104 return (CommandEvaluation::getCommonBegin(temp)); 105 } 106 break; 107 case CS_Shortcut_Params: 108 if (this->function_) 109 { 110 if (this->commandTokens_.size() > 1) 111 return (this->function_->getName() + " " + this->commandTokens_.subSet(1, this->commandTokens_.size() - 1).join() + " " + CommandEvaluation::getCommonBegin(this->listOfPossibleArguments_)); 112 else 113 return (this->function_->getName() + " "); 114 } 115 break; 116 case CS_Shortcut_Finished: 117 if (this->function_) 118 { 119 if (this->commandTokens_.size() > 1) 120 return (this->function_->getName() + " " + this->originalCommandTokens_.subSet(1, this->originalCommandTokens_.size() - 1).join()); 121 else 122 return (this->function_->getName()); 123 } 124 break; 125 case CS_Function: 126 if (this->functionclass_) 127 return (this->functionclass_->getName() + " " + CommandEvaluation::getCommonBegin(this->listOfPossibleFunctions_)); 128 break; 129 case CS_Function_Params: 130 if (this->functionclass_ && this->function_) 131 { 132 if (this->commandTokens_.size() > 2) 133 return (this->functionclass_->getName() + " " + this->function_->getName() + " " + this->commandTokens_.subSet(2, this->commandTokens_.size() - 1).join() + " " + CommandEvaluation::getCommonBegin(this->listOfPossibleArguments_)); 134 else 135 return (this->functionclass_->getName() + " " + this->function_->getName() + " "); 136 } 137 break; 138 case CS_Function_Finished: 139 if (this->functionclass_ && this->function_) 140 { 141 if (this->commandTokens_.size() > 2) 142 return (this->functionclass_->getName() + " " + this->function_->getName() + " " + this->originalCommandTokens_.subSet(2, this->originalCommandTokens_.size() - 1).join()); 143 else 144 return (this->functionclass_->getName() + " " + this->function_->getName()); 145 } 146 break; 147 case CS_Error: 148 break; 149 } 150 151 return this->originalCommand_; 152 } 153 154 std::string CommandEvaluation::hint() const 155 { 156 switch (this->state_) 157 { 158 case CS_Uninitialized: 159 break; 160 case CS_Empty: 161 case CS_ShortcutOrIdentifier: 162 return (CommandEvaluation::dump(this->listOfPossibleFunctions_) + "\n" + CommandEvaluation::dump(this->listOfPossibleIdentifiers_)); 178 if (this->listOfPossibleFunctions_.size() == 0) 179 return CommandEvaluation::dump(this->listOfPossibleIdentifiers_); 180 else if (this->listOfPossibleIdentifiers_.size() == 0) 181 return CommandEvaluation::dump(this->listOfPossibleFunctions_); 182 else 183 return (CommandEvaluation::dump(this->listOfPossibleFunctions_) + "\n" + CommandEvaluation::dump(this->listOfPossibleIdentifiers_)); 163 184 break; 164 185 case CS_Function: … … 167 188 case CS_Shortcut_Params: 168 189 case CS_Function_Params: 169 return CommandEvaluation::dump(this->listOfPossibleArguments_); 190 if (this->listOfPossibleArguments_.size() > 0) 191 return CommandEvaluation::dump(this->listOfPossibleArguments_); 192 else 193 return CommandEvaluation::dump(this->function_); 170 194 case CS_Shortcut_Finished: 171 195 case CS_Function_Finished: … … 193 217 unsigned int startindex = this->getStartindex(); 194 218 195 if (this-> originalCommandTokens_.size() <= startindex)219 if (this->commandTokens_.size() <= startindex) 196 220 { 197 221 if (this->function_->evaluate(this->getAdditionalParameter(), this->param_, " ")) 198 222 this->bEvaluatedParams_ = true; 199 223 } 200 else if (this-> originalCommandTokens_.size() > startindex)201 { 202 if (this->function_->evaluate(this-> originalCommandTokens_.subSet(startindex).join() + this->getAdditionalParameter(), this->param_, " "))224 else if (this->commandTokens_.size() > startindex) 225 { 226 if (this->function_->evaluate(this->commandTokens_.subSet(startindex).join() + this->getAdditionalParameter(), this->param_, " ")) 203 227 this->bEvaluatedParams_ = true; 204 228 }
Note: See TracChangeset
for help on using the changeset viewer.