Changeset 5656 in orxonox.OLD for trunk/src/lib
- Timestamp:
- Nov 20, 2005, 9:45:28 PM (19 years ago)
- Location:
- trunk/src/lib
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/event/command_chain.cc
r5461 r5656 430 430 unsigned int fktPos = 1; //< the position of the function (needed for finding it) 431 431 // long completeType = SHELLC_NONE; //< the Type we'd like to complete. 432 SubString inputSplits(executionString, true);432 SubString inputSplits(executionString, " \n\t,"); 433 433 434 434 if (inputSplits.getCount() == 0) -
trunk/src/lib/event/command_chain.h
r5461 r5656 360 360 virtual void executeCommand (BaseObject* object, const char* parameters) 361 361 { 362 SubString sub(parameters, true);362 SubString sub(parameters, " \n\t,"); 363 363 //! FUNCTOR_LIST is the List of Executive Functions 364 364 #define FUNCTOR_LIST(x) CommandChainExecute ## x -
trunk/src/lib/graphics/graphics_engine.cc
r5509 r5656 259 259 260 260 if (this->hwExtensions == NULL && extensions != NULL) 261 this->hwExtensions = new SubString((char*)glGetString(GL_EXTENSIONS), true);261 this->hwExtensions = new SubString((char*)glGetString(GL_EXTENSIONS), " \n\t,"); 262 262 263 263 PRINT(4)("Running on : %s %s %s\n", vendor, renderer, version); -
trunk/src/lib/shell/shell_command.cc
r5652 r5656 170 170 unsigned int fktPos = 1; //< the position of the function (needed for finding it) 171 171 // long completeType = SHELLC_NONE; //< the Type we'd like to complete. 172 SubString inputSplits(executionString, true);172 SubString inputSplits(executionString, " \t\n,"); 173 173 174 174 if (inputSplits.getCount() == 0) -
trunk/src/lib/shell/shell_completion.cc
r5639 r5656 95 95 else 96 96 completionLine = this->input->getInput() + strspn(this->input->getInput(), " \t\n"); 97 SubString inputSplits(completionLine, true);97 SubString inputSplits(completionLine, " \t\n,"); 98 98 99 99 // What String will be completed -
trunk/src/lib/util/executor/executor.h
r5652 r5656 38 38 virtual Executor* clone () const = 0; 39 39 40 Executor* defaultValues(unsigned int count, va_list values); 40 41 Executor* defaultValues(unsigned int count, ...); 41 Executor* defaultValues(unsigned int count, va_list values);42 42 43 43 /** executes a Command @param object the object to apply this to @param parameters the parameters the command takes */ … … 56 56 57 57 void cloning(Executor* executor) const; 58 59 // const SubString& getSubString(const char* string) const { return SubString(string); }; 58 60 59 61 protected: … … 261 263 virtual void execute (BaseObject* object, const char* parameters) 262 264 { 263 SubString sub(parameters, ','); /// FIXME ///265 SubString sub(parameters, " \n\t,", '\\'); 264 266 //! FUNCTOR_LIST is the List of Executive Functions 265 267 #define FUNCTOR_LIST(x) ExecutorExecute ## x … … 323 325 virtual void execute (BaseObject* object, const char* parameters) 324 326 { 325 SubString sub(parameters, true);327 SubString sub(parameters, " \n\t,"); 326 328 //! FUNCTOR_LIST is the List of Executive Functions 327 329 #define FUNCTOR_LIST(x) ExecutorExecute ## x -
trunk/src/lib/util/substring.cc
r5209 r5656 123 123 assert (this->strings != NULL && this->offsets != NULL); 124 124 125 125 126 // split the String into substrings 126 127 int l = 0; … … 154 155 } 155 156 157 SubString::SubString(const char* string, const char* splitters, char escapeChar) 158 { 159 this->splittersCount = 0; 160 if (string == NULL || splitters == NULL) 161 { 162 this->strings = NULL; 163 this->offsets = NULL; 164 return; 165 } 166 167 // chop the input to the beginning of something usefull 168 if (strlen(string) > 0) 169 string = string + strspn(string, splitters); 170 171 // count the Splitters 172 bool lastWasSplitter = false; 173 for(unsigned int i = 0; i < strlen(string); i++) 174 { 175 176 if( strchr(splitters, string[i] )) 177 lastWasSplitter = true; 178 else 179 { 180 if (lastWasSplitter) 181 { 182 this->splittersCount ++; 183 lastWasSplitter = false; 184 } 185 } 186 } 187 this->splittersCount += 1; 188 189 // allocate memory 190 this->strings = new char*[this->splittersCount]; 191 this->offsets = new unsigned int[this->splittersCount]; 192 assert (this->strings != NULL && this->offsets != NULL); 193 194 195 // split the String into substrings 196 int l = 0; 197 unsigned int i = 0; 198 if( this->splittersCount > 1) 199 { 200 const char* offset = string; 201 const char* end = offset + strcspn(offset, splitters); 202 for (i = 0; i < this->splittersCount; i++) 203 { 204 assert( i < this->splittersCount); 205 l = end - offset; 206 this->strings[i] = new char[l + 1]; 207 assert( strings[i] != NULL); 208 strncpy( strings[i], offset, l); 209 strings[i][l] = '\0'; 210 this->offsets[i] = offset - string; 211 end += strspn(end, splitters); 212 offset = end; 213 end = offset + strcspn(offset, splitters); 214 } 215 } 216 else 217 { 218 unsigned int length = strcspn(string, splitters); 219 this->strings[0] = new char[length+1]; 220 strncpy(this->strings[0], string, length); 221 this->strings[0][length] = '\0'; 222 offsets[0] = 0; 223 } 224 } 225 226 156 227 /** 157 228 * removes the object from memory -
trunk/src/lib/util/substring.h
r5200 r5656 13 13 SubString(const char* string, char splitter = ','); 14 14 SubString(const char* string, bool whiteSpaces); 15 SubString(const char* string, const char* splitters, char escapeChar ='\\'); 15 16 ~SubString(); 16 17
Note: See TracChangeset
for help on using the changeset viewer.