Changeset 5141 in orxonox.OLD for trunk/src/util
- Timestamp:
- Aug 26, 2005, 4:04:53 PM (19 years ago)
- Location:
- trunk/src/util
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/util/loading/load_param.cc
r5115 r5141 112 112 } 113 113 } 114 115 /**116 * checks if the input was a Bool117 * @param BOOL a String that holds a bool: must be one of those: 1,0,true,false,TRUE,FALSE118 * @param defaultValue a default value that is set, if BOOL is corrupt119 * @return returns the bool, if BOOL was correct otherwise defaultValue120 */121 bool isBool(const char* BOOL, bool defaultValue)122 {123 if(!strcmp(BOOL, "1") || !strcmp( BOOL,"true") || !strcmp(BOOL,"TRUE"))124 return true;125 else if (!strcmp(BOOL, "0") || !strcmp( BOOL,"false") || !strcmp(BOOL,"FALSE"))126 return false;127 else128 return defaultValue;129 130 }131 132 int isInt(const char* INT, int defaultValue)133 {134 char* endPtr = NULL;135 int result = strtol(INT, &endPtr, 10);136 137 if ( endPtr >= INT && endPtr < INT + strlen(INT))138 return defaultValue;139 else140 return result;141 }142 143 float isFloat(const char* FLOAT, float defaultValue)144 {145 char* endPtr = NULL;146 double result = strtod(FLOAT, &endPtr);147 148 if ( endPtr >= FLOAT && endPtr < FLOAT + strlen(FLOAT))149 return defaultValue;150 else151 return result;152 }153 154 const Vector& isVector(const char* VECTOR, const Vector& defaultValue)155 {156 157 158 }159 160 const char* isString(const char* STRING, const char* defaultValue)161 {162 if (STRING != NULL)163 return STRING;164 else165 return defaultValue;166 }167 168 114 169 115 /** -
trunk/src/util/loading/load_param.h
r5137 r5141 28 28 #include "substring.h" 29 29 #include "tinyxml.h" 30 #include "helper_functions.h" 30 31 31 32 // Forward Declaration // … … 216 217 PRINTF(4)("Not loaded parameter %s of %s\n", paramName, pt2Object->getClassName()); \ 217 218 } 218 219 220 /***********************221 *** HELPER FUNCTIONS ***222 ***********************/223 bool isBool(const char* BOOL, bool defaultValue);224 int isInt(const char* INT, int defaultValue);225 float isFloat(const char* FLOAT, float defaultValue);226 //const Vector& isVector(const char* VECTOR, const Vector& defaultValue);227 const char* isString(const char* STRING, const char* defaultValue);228 229 //TiXmlEmlemnt* isXmlElem(const)230 231 219 232 220 /************************ -
trunk/src/util/shell.cc
r5137 r5141 494 494 if (event.bPressed) 495 495 { 496 PRINTF( 4)("Shell received command %s\n", SDLKToKeyname(event.type));496 PRINTF(5)("Shell received command %s\n", SDLKToKeyname(event.type)); 497 497 if (event.type == SDLK_BACKQUOTE) 498 498 { -
trunk/src/util/shell.h
r5130 r5141 16 16 // FORWARD DECLARATION 17 17 class Text; 18 class ShellCommandBase; 18 19 template<class T> class tList; 19 20 template<class T> class tIterator; … … 85 86 const tList<const char>* createCompleteList(const tList<const char>* inputList, const char* classNameBegin); 86 87 const tList<const char>* createCompleteList(const tList<BaseObject>* inputList, const char* classNameBegin); 88 const tList<const char>* createCompleteList(const tList<ShellCommandBase>* inputList, const char* classNameBegin); 87 89 88 90 // helpers // -
trunk/src/util/shell_command.cc
r5140 r5141 30 30 ShellCommandBase::ShellCommandBase(const char* commandName, ClassID classID, unsigned int paramCount, ...) 31 31 { 32 this->setClassID(CL_SHELL_COMMAND, "ShellCommand"); 33 this->setName(commandName); 34 32 35 va_list parameters; 33 36 va_start(parameters, paramCount); 34 37 35 38 this->classID = classID; 39 this->className = ClassList::IDToString(classID); 40 36 41 if (classID & CL_MASK_SINGLETON == CL_MASK_SINGLETON) 37 42 this->isSingleton = true; 38 43 else 39 44 this->isSingleton = false; 40 41 this->commandName = new char[strlen(commandName)+1];42 strcpy(this->commandName, commandName);43 45 44 46 // handling parameters, and storing them: … … 55 57 ShellCommandBase::~ShellCommandBase() 56 58 { 57 delete[] this->commandName;58 59 delete[] this->parameters; 59 60 } … … 78 79 while(elem != NULL) 79 80 { 80 if (classID == elem->classID && !strcmp(commandName, elem-> commandName))81 if (classID == elem->classID && !strcmp(commandName, elem->getName())) 81 82 { 82 83 PRINTF(2)("Command already registered\n"); … … 104 105 while(elem != NULL) 105 106 { 106 printf("%s\n", elem-> commandName);107 if (!strncmp(executionString, elem-> commandName, strlen(elem->commandName)))107 printf("%s\n", elem->getName()); 108 if (!strncmp(executionString, elem->getName(), strlen(elem->getName()))) 108 109 { 109 110 elem->executeCommand(commandEnd); … … 116 117 return true; 117 118 } 118 -
trunk/src/util/shell_command.h
r5140 r5141 8 8 9 9 #include "base_object.h" 10 11 #include "helper_functions.h" 10 12 11 13 #include <stdarg.h> … … 44 46 45 47 48 46 49 //////////////// 47 50 // BASE CLASS // … … 53 56 static bool execute (const char* executionString); 54 57 55 virtual void executeCommand (const char* parameters) = NULL; 58 static const tList<ShellCommandBase>* getCommandList() { return ShellCommandBase::commandList; }; 59 56 60 57 61 protected: … … 60 64 61 65 static bool isRegistered(const char* commandName, ClassID classID, unsigned int paramCount, ...); 66 67 private: 68 virtual void executeCommand (const char* parameters) = NULL; 62 69 63 70 protected: … … 68 75 69 76 private: 70 char* commandName; //!< The name of the Command when executed71 long classID; //!< The ID of the Class asociated to this Command77 long classID; //!< The ID of the Class associated to this Command 78 const char* className; //!< The Name of the Class associated to this Command 72 79 73 80 // STATIC MEMBERS … … 133 140 #define FUNCTOR_LIST(x) ShellCommand ## x 134 141 //#include "functor_list.h" 135 // ShellCommand2(l_INT, l_INT);142 //FUNCTOR_LIST(2)(l_INT, l_INT); 136 143 #undef FUNCTOR_LIST 137 144 138 private:139 // T* objectPointer; //!< The pointer to the object to apply this function to (NULL if classID == CL_NULL )140 145 }; 141 146
Note: See TracChangeset
for help on using the changeset viewer.