- Timestamp:
- Apr 27, 2006, 4:49:31 PM (19 years ago)
- Location:
- trunk/src/lib
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/shell/shell_command.cc
r7399 r7401 90 90 std::vector<ShellCommand*>::iterator cmd; 91 91 for (cmd = cmdClass->commandList.begin(); cmd < cmdClass->commandList.end(); cmd++) 92 {93 92 if (commandName == (*cmd)->getName()) 94 {95 93 delete (*cmd); 96 }97 }98 94 } 99 95 } … … 166 162 return true; 167 163 } 168 /// TODO CHECK FOR STATIC functions.169 164 } 170 165 } … … 232 227 233 228 /** 234 * lets a command be described229 * @brief lets a command be described 235 230 * @param description the description of the Given command 236 231 */ … … 289 284 290 285 /** 291 * prints out nice information about the Shells Commands286 * @brief prints out nice information about the Shells Commands 292 287 */ 293 288 void ShellCommand::debug() … … 314 309 315 310 /** 316 * converts a Parameter to a String311 * @brief converts a Parameter to a String 317 312 * @param parameter the Parameter we have. 318 313 * @returns the Name of the Parameter at Hand 319 314 */ 320 const char*ShellCommand::paramToString(long parameter)315 const std::string& ShellCommand::paramToString(long parameter) 321 316 { 322 317 return MultiType::MultiTypeToString((MT_Type)parameter); -
trunk/src/lib/shell/shell_command.h
r7398 r7401 82 82 83 83 static bool isRegistered(const std::string& commandName, const std::string& className); 84 static const char*paramToString(long parameter);84 static const std::string& paramToString(long parameter); 85 85 86 86 private: -
trunk/src/lib/util/multi_type.cc
r7284 r7401 39 39 switch (this->type) 40 40 { 41 default:41 default: 42 42 this->value.Float = 0.0f; 43 43 break; 44 case MT_BOOL:44 case MT_BOOL: 45 45 this->value.Bool = false; 46 46 break; 47 case MT_INT:47 case MT_INT: 48 48 this->value.Int = 0; 49 49 break; 50 case MT_FLOAT:50 case MT_FLOAT: 51 51 this->value.Float = 0.0f; 52 52 break; 53 case MT_CHAR:53 case MT_CHAR: 54 54 this->value.Char = '\0'; 55 55 break; 56 case MT_STRING:56 case MT_STRING: 57 57 this->storedString = ""; 58 58 break; … … 148 148 switch (this->type) 149 149 { 150 case MT_NULL:150 case MT_NULL: 151 151 return true; 152 case MT_BOOL:152 case MT_BOOL: 153 153 return (this->value.Bool == mt.value.Bool); 154 case MT_INT:154 case MT_INT: 155 155 return (this->value.Int == mt.value.Int); 156 case MT_CHAR:156 case MT_CHAR: 157 157 return (this->value.Char == mt.value.Char); 158 case MT_FLOAT:158 case MT_FLOAT: 159 159 return (this->value.Float == mt.value.Float); 160 case MT_STRING:160 case MT_STRING: 161 161 return (this->storedString == mt.storedString); 162 162 } … … 175 175 switch (type) 176 176 { 177 case MT_BOOL:177 case MT_BOOL: 178 178 this->setBool(this->getBool()); 179 179 break; 180 case MT_INT:180 case MT_INT: 181 181 this->setInt(this->getInt()); 182 182 break; 183 case MT_FLOAT:183 case MT_FLOAT: 184 184 this->setFloat(this->getFloat()); 185 185 break; 186 case MT_CHAR:186 case MT_CHAR: 187 187 this->setChar(this->getChar()); 188 188 break; 189 case MT_STRING:189 case MT_STRING: 190 190 this->setString(this->getString()); 191 191 break; … … 405 405 #endif 406 406 ("MultiType of Type '%s' :: Values: BOOL: '%d', INT: '%d', FLOAT: '%f', CHAR: '%c', STRING '%s'\n", 407 MultiType::MultiTypeToString(this->type) ,407 MultiType::MultiTypeToString(this->type).c_str(), 408 408 this->getBool(), 409 409 this->getInt(), … … 422 422 switch ( this->type ) 423 423 { 424 case MT_BOOL:424 case MT_BOOL: 425 425 this->setBool(false); 426 426 break; 427 case MT_INT:427 case MT_INT: 428 428 this->setInt(0); 429 429 break; 430 case MT_FLOAT:430 case MT_FLOAT: 431 431 this->setFloat(0.0f); 432 432 break; 433 case MT_CHAR:433 case MT_CHAR: 434 434 this->setChar('\0'); 435 435 break; 436 case MT_STRING:436 case MT_STRING: 437 437 this->setString(""); 438 438 break; 439 default:439 default: 440 440 #ifdef DEBUG 441 441 PRINTF(2)("Unknown Type not reseting\n"); … … 450 450 * @returns: the Type as a constant String (do not delete) 451 451 */ 452 const char*MultiType::MultiTypeToString(MT_Type type)452 const std::string& MultiType::MultiTypeToString(MT_Type type) 453 453 { 454 454 switch ( type ) 455 455 { 456 case MT_BOOL:457 return "bool";458 case MT_INT:459 return "int";460 case MT_FLOAT:461 return "float";462 case MT_CHAR:463 return "char";464 case MT_STRING:465 return "string";466 } 467 return "NONE";456 case MT_BOOL: 457 return MultiType::typeNames[1]; 458 case MT_INT: 459 return MultiType::typeNames[2]; 460 case MT_FLOAT: 461 return MultiType::typeNames[3]; 462 case MT_CHAR: 463 return MultiType::typeNames[4]; 464 case MT_STRING: 465 return MultiType::typeNames[5]; 466 } 467 return MultiType::typeNames[0]; 468 468 } 469 469 … … 475 475 MT_Type MultiType::StringToMultiType(const std::string& type) 476 476 { 477 if (type == "bool")477 if (type == MultiType::typeNames[1]) 478 478 return MT_BOOL; 479 if (type == "int")479 if (type == MultiType::typeNames[2]) 480 480 return MT_INT; 481 if (type , "float")481 if (type == MultiType::typeNames[3]) 482 482 return MT_FLOAT; 483 if (type == "char")483 if (type == MultiType::typeNames[4]) 484 484 return MT_CHAR; 485 if (type == "string")485 if (type == MultiType::typeNames[5]) 486 486 return MT_STRING; 487 487 488 488 return MT_NULL; 489 489 } 490 491 492 const std::string MultiType::typeNames[] = 493 { 494 "NONE", //0 495 "bool", //1 496 "int", //2 497 "float", //3 498 "char", //4 499 "string" //5 500 }; -
trunk/src/lib/util/multi_type.h
r7225 r7401 92 92 void debug() const; 93 93 94 static const char*MultiTypeToString(MT_Type type);94 static const std::string& MultiTypeToString(MT_Type type); 95 95 static MT_Type StringToMultiType(const std::string& type); 96 96 97 97 private: 98 //! A union, that combines types into as little memory as possible. 98 99 union MultiTypeValue 99 100 { 100 bool Bool; 101 int Int; 102 float Float; 103 char Char; 104 // std::string* String; 105 } value; 106 std::string storedString; 107 MT_Type type; 101 bool Bool; //!< If it is a BOOL 102 int Int; //!< If it is an INT 103 float Float; //!< If it is a FLOAT 104 char Char; //!< If it is a CHAR 105 } value; //!< The Value. 106 std::string storedString; //!< The Stored String. 107 MT_Type type; //!< The Type stored in this MultiType 108 109 static const std::string typeNames[]; //!< List of TypeNames for conversion. 108 110 }; 109 111
Note: See TracChangeset
for help on using the changeset viewer.