Changeset 7319 in orxonox.OLD for trunk/src/lib
- Timestamp:
- Apr 17, 2006, 1:00:09 PM (19 years ago)
- Location:
- trunk/src/lib
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/graphics_engine.cc
r7256 r7319 317 317 PRINT(4)("Running on : vendor: %s, renderer: %s, version:%s\n", vendor, renderer, version); 318 318 PRINT(4)("Extensions:\n"); 319 for (unsigned int i = 0; i < this->hwExtensions. getCount(); i++)320 PRINT(4)("%d: %s\n", i, this->hwExtensions .getString(i).c_str());319 for (unsigned int i = 0; i < this->hwExtensions.size(); i++) 320 PRINT(4)("%d: %s\n", i, this->hwExtensions[i].c_str()); 321 321 322 322 … … 514 514 bool GraphicsEngine::hwSupportsEXT(const std::string& extension) 515 515 { 516 for (unsigned int i = 0; i < this->hwExtensions. getCount(); i++)516 for (unsigned int i = 0; i < this->hwExtensions.size(); i++) 517 517 if ( this->hwExtensions.getString(i) == extension) 518 518 return true; -
trunk/src/lib/parser/cmdline_parser/cmdline_parser.cc
r7260 r7319 11 11 ### File Specific: 12 12 main-programmer: Christoph Renner 13 co-programmer: 13 co-programmer: 14 14 */ 15 15 … … 40 40 { 41 41 ArgTableEntry entry; 42 42 43 43 entry.id = id; 44 44 entry.longOption = longOption; … … 47 47 entry.argNames = argNames; 48 48 entry.help = help; 49 49 50 50 if ( back ) 51 51 argTable.push_back( entry ); … … 58 58 { 59 59 this->exeName = argv[0]; 60 60 61 61 //put all args in vector 62 62 std::vector<std::string> args; 63 63 64 64 for ( int i = 1; i<argc; i++ ) 65 65 { 66 66 std::string s = argv[i]; 67 67 68 68 if ( s.find( "=" ) == std::string::npos ) 69 69 { … … 88 88 op.erase( op.find("=") ); 89 89 ar.erase( 0, ar.find("=")+1); 90 90 91 91 //PRINTF(0)("'%s' '%s'\n", op.c_str(), ar.c_str()); 92 92 args.push_back( op ); … … 94 94 } 95 95 } 96 96 97 97 int i = 0; 98 98 99 99 ArgTable::iterator it; 100 100 bool finish; 101 101 bool found; 102 102 103 103 while ( i < args.size() ) 104 104 { … … 109 109 { 110 110 found = true; 111 111 112 112 int posArgs = 1; 113 113 114 114 while ( i + posArgs < args.size() ) 115 115 { … … 119 119 posArgs++; 120 120 } 121 121 122 122 posArgs--; 123 123 124 124 if ( it->numArgs > posArgs ) 125 125 { … … 127 127 return false; 128 128 } 129 129 130 130 std::vector<MultiType> argArgs; 131 131 132 132 for ( int j = 1; j <= it->numArgs; j++ ) 133 133 argArgs.push_back( args[i+j] ); 134 134 135 135 if ( !cb( *it, data, args[i], argArgs ) ) 136 136 return false; 137 137 138 138 i += it->numArgs; 139 139 140 140 if ( finish ) 141 141 { … … 143 143 break; 144 144 } 145 else 146 { 145 else 146 { 147 147 assert( it->numArgs == 0 ); 148 148 } 149 149 } 150 150 } 151 151 152 152 if ( !found ) 153 153 { … … 156 156 } 157 157 } 158 158 159 159 return true; 160 160 } … … 163 163 { 164 164 finish = true; 165 165 166 166 if ( arg.length() < 2 ) 167 167 return false; 168 168 169 169 if ( arg[0] == '-' ) 170 170 { … … 172 172 { 173 173 arg.erase( 0, 2 ); 174 174 175 175 if ( entry.longOption.find('%') != std::string::npos ) 176 176 { … … 208 208 printf("Usage: %s [options]\n", exeName.c_str()); 209 209 printf("\n"); 210 210 211 211 std::list<std::vector<std::string> > output; 212 212 213 213 for ( ArgTable::iterator it = argTable.begin(); it != argTable.end(); it++ ) 214 214 { 215 215 output.push_back( std::vector<std::string>() ); 216 216 217 217 SubString substr( it->argNames ); 218 218 std::string args; 219 assert( it->numArgs == substr. getCount() );220 219 assert( it->numArgs == substr.size() ); 220 221 221 for ( int i = 0; i<it->numArgs; i++ ) 222 222 { 223 223 args += " [" + substr[i] + "]"; 224 224 } 225 225 226 226 if ( it->shortOption != '\0' ) 227 227 { … … 231 231 else 232 232 output.back().push_back( "" ); 233 233 234 234 if ( it->longOption != "" ) 235 235 { 236 236 output.back().push_back( "--" + it->longOption ); 237 237 238 238 output.back().back() += args; 239 239 } 240 240 else 241 241 output.back().push_back( "" ); 242 242 243 243 output.back().push_back( it->help ); 244 244 } 245 245 246 246 output.push_back( std::vector<std::string>() ); 247 247 output.back().push_back( "Option" ); 248 248 output.back().push_back( "Long option" ); 249 249 output.back().push_back( "Description" ); 250 250 251 251 output.reverse(); 252 252 253 253 int maxShort = 0; 254 254 int maxLong = 0; 255 255 256 256 std::list<std::vector<std::string> >::const_iterator it; 257 257 258 258 for ( it = output.begin(); it != output.end(); it++ ) 259 259 { 260 260 if ( (*it)[0].length() > maxShort ) 261 261 maxShort = (*it)[0].length(); 262 262 263 263 if ( (*it)[1].length() > maxLong ) 264 264 maxLong = (*it)[1].length(); 265 265 } 266 266 267 267 for ( it = output.begin(); it != output.end(); it++ ) 268 268 { 269 269 printf("%s ", (*it)[0].c_str()); 270 270 271 271 for ( int i = 0; i<maxShort-(*it)[0].length(); i++ ) 272 272 printf(" "); 273 273 274 274 printf("%s ", (*it)[1].c_str()); 275 275 276 276 for ( int i = 0; i<maxLong-(*it)[1].length(); i++ ) 277 277 printf(" "); 278 278 279 279 printf("%s\n", (*it)[2].c_str()); 280 280 } 281 281 282 282 exit(0); 283 283 } -
trunk/src/lib/shell/shell_command.cc
r7225 r7319 165 165 SubString inputSplits(executionString, " \t\n,"); 166 166 167 if (inputSplits. getCount() == 0)167 if (inputSplits.size() == 0) 168 168 return false; 169 if (inputSplits. getCount() >= 1)169 if (inputSplits.size() >= 1) 170 170 { 171 171 // CHECK FOR ALIAS … … 181 181 if (objectList != NULL) 182 182 { 183 if (inputSplits. getCount() > 1)183 if (inputSplits.size() > 1) 184 184 { 185 185 … … 210 210 } 211 211 212 if (commandClass != NULL && inputSplits. getCount() >= 2)212 if (commandClass != NULL && inputSplits.size() >= 2) 213 213 { 214 214 if (objectList != NULL) … … 231 231 } 232 232 // match a function. 233 if (commandClass != NULL && (fktPos == 1 || (fktPos == 2 && inputSplits. getCount() >= 3)))233 if (commandClass != NULL && (fktPos == 1 || (fktPos == 2 && inputSplits.size() >= 3))) 234 234 { 235 235 list<ShellCommand*>::iterator cmdIT; … … 240 240 if (objectPointer == NULL && (*cmdIT)->executor->getType() & Executor_Objective) 241 241 return false; 242 if (inputSplits. getCount() > fktPos+1)242 if (inputSplits.size() > fktPos+1) 243 243 (*cmdIT)->executor->execute(objectPointer, executionString.substr(inputSplits.getOffset(fktPos +1))); /// TODO CHECK IF OK 244 244 else -
trunk/src/lib/shell/shell_completion.cc
r7225 r7319 88 88 completeString = ""; 89 89 else 90 completeString = inputSplits.getString(inputSplits. getCount()-1).c_str();90 completeString = inputSplits.getString(inputSplits.size()-1).c_str(); 91 91 92 92 // CLASS COMPLETION 93 if (inputSplits. getCount() == 0)93 if (inputSplits.size() == 0) 94 94 { 95 95 completeType |= SHELLC_CLASS; 96 96 completeType |= SHELLC_ALIAS; 97 97 } 98 else if (inputSplits. getCount() == 1 && emptyComplete == false)98 else if (inputSplits.size() == 1 && emptyComplete == false) 99 99 { 100 100 completeType |= SHELLC_CLASS; … … 103 103 104 104 // OBJECT/FUNCTION COMPLETIONS 105 else if ((inputSplits. getCount() == 1 && emptyComplete == true) ||106 (inputSplits. getCount() == 2 && emptyComplete == false))105 else if ((inputSplits.size() == 1 && emptyComplete == true) || 106 (inputSplits.size() == 2 && emptyComplete == false)) 107 107 { 108 108 classID = ClassList::StringToID(inputSplits.getString(0).c_str()); //FIXME … … 113 113 completeType |= SHELLC_FUNCTION; 114 114 } 115 else if ((inputSplits. getCount() == 2 && emptyComplete == true) ||116 (inputSplits. getCount() == 3 && emptyComplete == false))115 else if ((inputSplits.size() == 2 && emptyComplete == true) || 116 (inputSplits.size() == 3 && emptyComplete == false)) 117 117 { 118 118 classID = ClassList::StringToID(inputSplits.getString(0) .c_str()); // FIXME -
trunk/src/lib/util/substring.cc
r7221 r7319 26 26 */ 27 27 28 29 /**30 * breaks a string into parts that were initially seperated by comma31 * @param string the string to break into substrings32 */33 34 28 #include "substring.h" 35 29 … … 37 31 #include <cassert> 38 32 33 /** 34 * @brief create a SubString from 35 * @param string the String to Spilit 36 * @param splitter the Character at which to split string (delimiter) 37 */ 39 38 SubString::SubString(const std::string& string, char splitter) 40 39 { … … 47 46 48 47 /** 49 * Splits a String into a Substring removing all whiteSpaces48 * @brief Splits a String into a SubString removing all whiteSpaces 50 49 * @param string the String to Split 51 * @param whiteSpaces MUST BE __TRUE__ 52 * 50 * @param whiteSpaces MUST BE __TRUE__ or __FALSE__ (will be ignored) 53 51 */ 54 52 SubString::SubString(const std::string& string, bool whiteSpaces) 55 53 { 56 54 SubString::splitLine(this->strings, this->offsets, 57 string); 58 } 55 string); 56 } 57 58 /** 59 * @brief Splits a String into multiple splitters. 60 * @param string the String to split 61 * @param splitters multiple set of characters at what to split. (delimiters) 62 * @param escapeChar The Escape Character that overrides splitters commends and so on... 63 * @param safemode_char within these characters splitting won't happen 64 * @param comment_char the Comment character. 65 */ 59 66 SubString::SubString(const std::string& string, const std::string& splitters, char escapeChar,char safemode_char, char comment_char) 60 67 { 61 68 SubString::splitLine(this->strings, this->offsets, 62 string, splitters, escapeChar, safemode_char); 63 } 64 65 /** 66 * An empty String 69 string, splitters, escapeChar, safemode_char, comment_char); 70 } 71 72 /** 73 * @brief creates a SubSet of a SubString. 74 * @param subString the SubString to take a set from. 75 * @param subSetBegin the beginning to the end 76 */ 77 SubString::SubString(const SubString& subString, unsigned int subSetBegin) 78 { 79 for (unsigned int i = subSetBegin; i < subString.size(); i++) 80 this->strings.push_back(subString[i]); 81 } 82 83 84 /** 85 * @brief creates a SubSet of a SubString. 86 * @param subString the SubString to take a Set from 87 * @param subSetBegin the beginning to the end 88 * @param subSetEnd the end of the SubSet (max subString.size() will be checked internaly) 89 */ 90 SubString::SubString(const SubString& subString, unsigned int subSetBegin, unsigned int subSetEnd) 91 { 92 for (unsigned int i = subSetBegin; i < subString.size() || i < subSetEnd; i++) 93 this->strings.push_back(subString[i]); 94 } 95 96 97 /** 98 * @brief removes the object from memory 99 */ 100 SubString::~SubString() 101 { } 102 103 /** 104 * @brief An empty String 67 105 */ 68 106 const std::string SubString::emptyString = ""; 69 107 70 71 108 /** 109 * @brief stores the Value of subString in this SubString 110 * @param subString will be copied into this String. 111 * @returns this SubString. 112 */ 113 SubString& SubString::operator=(const SubString& subString) 114 { 115 this->offsets = subString.offsets; 116 this->strings = subString.strings; 117 return *this; 118 } 119 120 121 /** 122 * @brief comparator. 123 * @param subString the SubString to compare against this one. 124 * @returns true if the Stored Strings match 125 */ 126 bool SubString::operator==(const SubString& subString) 127 { 128 return (this->strings == subString.strings); 129 } 130 131 132 /** 133 * @brief append operator 134 * @param subString the String to append. 135 * @returns a SubString where this and subString are appended. 136 */ 137 SubString SubString::operator+(const SubString& subString) const 138 { 139 return SubString(subString) += subString; 140 } 141 142 143 /** 144 * @brief append operator. 145 * @param subString append subString to this SubString. 146 * @returns this substring appended with subString 147 */ 148 SubString& SubString::operator+=(const SubString& subString) 149 { 150 for (unsigned int i = 0; i < subString.size(); i++) 151 this->strings.push_back(subString[i]); 152 } 153 154 155 /** 156 * @brief Split the String at 157 * @param string where to split 158 * @param splitter delimiter. 159 */ 72 160 unsigned int SubString::split(const std::string& string, char splitter) 73 161 { … … 83 171 84 172 /** 85 * Splits a String into a Substring removing all whiteSpaces173 * @brief Splits a String into a Substring removing all whiteSpaces 86 174 * @param string the String to Split 87 175 * @param whiteSpaces MUST BE __TRUE__ … … 96 184 } 97 185 186 187 /** 188 * @brief Splits a String into multiple splitters. 189 * @param string the String to split 190 * @param splitters multiple set of characters at what to split. (delimiters) 191 * @param escapeChar The Escape Character that overrides splitters commends and so on... 192 * @param safemode_char within these characters splitting won't happen 193 * @param comment_char the Comment character. 194 */ 98 195 unsigned int SubString::split(const std::string& string, const std::string& splitters, char escapeChar,char safemode_char, char comment_char) 99 196 { … … 103 200 string, splitters, escapeChar, safemode_char); 104 201 return strings.size(); 202 } 203 204 205 /** 206 * @brief joins together all Strings of this Substring. 207 * @param delimiter the String between the subStrings. 208 * @returns the joined String. 209 */ 210 std::string SubString::join(const std::string& delimiter) const 211 { 212 if (!this->strings.empty()) 213 { 214 std::string retVal = this->strings[0]; 215 for (unsigned int i = 0; i < this->strings.size(); i++) 216 retVal += delimiter + this->strings[i]; 217 return retVal; 218 } 219 else 220 return SubString::emptyString; 221 } 222 223 224 /** 225 * @brief creates a SubSet of a SubString. 226 * @param subSetBegin the beginning to the end 227 * @returns the SubSet 228 * 229 * This function is added for your convenience, and does the same as 230 * SubString::SubString(const SubString& subString, unsigned int subSetBegin) 231 */ 232 SubString SubString::getSubSet(unsigned int subSetBegin) const 233 { 234 return SubString(*this, subSetBegin); 235 } 236 237 238 /** 239 * @brief creates a SubSet of a SubString. 240 * @param subSetBegin the beginning to 241 * @param subSetEnd the end of the SubSet to select (if bigger than subString.size() it will be downset.) 242 * @returns the SubSet 243 * 244 * This function is added for your convenience, and does the same as 245 * SubString::SubString(const SubString& subString, unsigned int subSetBegin) 246 */ 247 SubString SubString::getSubSet(unsigned int subSetBegin, unsigned int subSetEnd) const 248 { 249 return SubString(*this, subSetBegin, subSetEnd); 250 } 251 252 253 /** 254 * @brief get a particular substring's offset 255 * @param i the ID of the substring to get the offset from 256 * @returns the offset or NULL if an invalid ID was given 257 */ 258 unsigned int SubString::getOffset(unsigned int i) const 259 { 260 if( i < this->offsets.size() && i >= 0) 261 return this->offsets[i]; 262 else 263 return 0; 105 264 } 106 265 … … 119 278 * @returns SPLIT_LINE_STATE the parser was in when returning 120 279 * 280 * This is the Actual Splitting Algorithm from Clemens Wacha 121 281 * Supports delimiters, escape characters, 122 282 * ignores special characters between safemode_char and between comment_char and linend '\n'. … … 142 302 switch(state) 143 303 { 144 case SL_NORMAL: 145 if(line[i] == escape_char) 146 { 147 state = SL_ESCAPE; 148 } 149 else if(line[i] == safemode_char) 150 { 304 case SL_NORMAL: 305 if(line[i] == escape_char) 306 { 307 state = SL_ESCAPE; 308 } 309 else if(line[i] == safemode_char) 310 { 311 state = SL_SAFEMODE; 312 } 313 else if(line[i] == comment_char) 314 { 315 /// FINISH 316 if(token.size() > 0) 317 { 318 ret.push_back(token); 319 offsets.push_back(i); 320 token.clear(); 321 } 322 token += line[i]; // EAT 323 state = SL_COMMENT; 324 } 325 else if(delimiters.find(line[i]) != std::string::npos) 326 { 327 // line[i] is a delimiter 328 /// FINISH 329 if(token.size() > 0) 330 { 331 ret.push_back(token); 332 offsets.push_back(i); 333 token.clear(); 334 } 335 } 336 else 337 { 338 token += line[i]; // EAT 339 } 340 break; 341 case SL_ESCAPE: 342 if(line[i] == 'n') token += '\n'; 343 else if(line[i] == 't') token += '\t'; 344 else if(line[i] == 'v') token += '\v'; 345 else if(line[i] == 'b') token += '\b'; 346 else if(line[i] == 'r') token += '\r'; 347 else if(line[i] == 'f') token += '\f'; 348 else if(line[i] == 'a') token += '\a'; 349 else if(line[i] == '?') token += '\?'; 350 else token += line[i]; // EAT 351 state = SL_NORMAL; 352 break; 353 case SL_SAFEMODE: 354 if(line[i] == safemode_char) 355 { 356 state = SL_NORMAL; 357 } 358 else if(line[i] == escape_char) 359 { 360 state = SL_SAFEESCAPE; 361 } 362 else 363 { 364 token += line[i]; // EAT 365 } 366 break; 367 case SL_SAFEESCAPE: 368 if(line[i] == 'n') token += '\n'; 369 else if(line[i] == 't') token += '\t'; 370 else if(line[i] == 'v') token += '\v'; 371 else if(line[i] == 'b') token += '\b'; 372 else if(line[i] == 'r') token += '\r'; 373 else if(line[i] == 'f') token += '\f'; 374 else if(line[i] == 'a') token += '\a'; 375 else if(line[i] == '?') token += '\?'; 376 else token += line[i]; // EAT 151 377 state = SL_SAFEMODE; 152 } 153 else if(line[i] == comment_char) 154 { 155 /// FINISH 156 if(token.size() > 0) 157 { 158 ret.push_back(token); 159 offsets.push_back(i); 160 token.clear(); 161 } 162 token += line[i]; // EAT 163 state = SL_COMMENT; 164 } 165 else if(delimiters.find(line[i]) != std::string::npos) 166 { 167 // line[i] is a delimiter 168 /// FINISH 169 if(token.size() > 0) 170 { 171 ret.push_back(token); 172 offsets.push_back(i); 173 token.clear(); 174 } 175 } 176 else 177 { 178 token += line[i]; // EAT 179 } 180 break; 181 case SL_ESCAPE: 182 if(line[i] == 'n') token += '\n'; 183 else if(line[i] == 't') token += '\t'; 184 else if(line[i] == 'v') token += '\v'; 185 else if(line[i] == 'b') token += '\b'; 186 else if(line[i] == 'r') token += '\r'; 187 else if(line[i] == 'f') token += '\f'; 188 else if(line[i] == 'a') token += '\a'; 189 else if(line[i] == '?') token += '\?'; 190 else token += line[i]; // EAT 191 state = SL_NORMAL; 192 break; 193 case SL_SAFEMODE: 194 if(line[i] == safemode_char) 195 { 196 state = SL_NORMAL; 197 } 198 else if(line[i] == escape_char) 199 { 200 state = SL_SAFEESCAPE; 201 } 202 else 203 { 204 token += line[i]; // EAT 205 } 206 break; 207 case SL_SAFEESCAPE: 208 if(line[i] == 'n') token += '\n'; 209 else if(line[i] == 't') token += '\t'; 210 else if(line[i] == 'v') token += '\v'; 211 else if(line[i] == 'b') token += '\b'; 212 else if(line[i] == 'r') token += '\r'; 213 else if(line[i] == 'f') token += '\f'; 214 else if(line[i] == 'a') token += '\a'; 215 else if(line[i] == '?') token += '\?'; 216 else token += line[i]; // EAT 217 state = SL_SAFEMODE; 218 break; 219 case SL_COMMENT: 220 if(line[i] == '\n') 221 { 222 /// FINISH 223 if(token.size() > 0) 224 { 225 ret.push_back(token); 226 offsets.push_back(i); 227 token.clear(); 228 } 229 state = SL_NORMAL; 230 } 231 else 232 { 233 token += line[i]; // EAT 234 } 235 break; 236 default: 237 // nothing 238 break; 378 break; 379 case SL_COMMENT: 380 if(line[i] == '\n') 381 { 382 /// FINISH 383 if(token.size() > 0) 384 { 385 ret.push_back(token); 386 offsets.push_back(i); 387 token.clear(); 388 } 389 state = SL_NORMAL; 390 } 391 else 392 { 393 token += line[i]; // EAT 394 } 395 break; 396 default: 397 // nothing 398 break; 239 399 } 240 400 i++; … … 251 411 } 252 412 253 /** 254 * removes the object from memory 255 */ 256 SubString::~SubString() 257 { } 258 259 /** 260 * get a particular substring's offset 261 * @param i the ID of the substring to get the offset from 262 * @returns the offset or NULL if an invalid ID was given 263 */ 264 unsigned int SubString::getOffset(unsigned int i) 265 { 266 if( i < this->offsets.size() && i >= 0) 267 return this->offsets[i]; 268 else 269 return 0; 270 } 271 272 /** 273 * Some nice debug information about this SubString 413 414 /** 415 * @brief Some nice debug information about this SubString 274 416 */ 275 417 void SubString::debug() const -
trunk/src/lib/util/substring.h
r7300 r7319 10 10 #include <string> 11 11 12 13 14 15 16 17 18 12 typedef enum { 13 SL_NORMAL, 14 SL_ESCAPE, 15 SL_SAFEMODE, 16 SL_SAFEESCAPE, 17 SL_COMMENT, 18 } SPLIT_LINE_STATE; 19 19 20 20 //! A class that can load one string and split it in multipe ones 21 /** 22 * SubString is a very Powerfull way to create a SubSet from a String 23 * It can be used, to Split strings append them and join them again. 24 */ 21 25 class SubString 22 26 { 23 27 public: 24 28 SubString(const std::string& string = "", char splitter = ','); 25 29 SubString(const std::string& string, bool whiteSpaces); 26 30 SubString(const std::string& string, const std::string& splitters, char escapeChar ='\\', char safemode_char = '"', char comment_char = '\0'); 31 /** @brief create a Substring as a copy of another one. @param subString the SubString to copy. */ 32 SubString(const SubString& subString) { *this = subString; }; 33 SubString(const SubString& subString, unsigned int subSetBegin); 34 SubString(const SubString& subString, unsigned int subSetBegin, unsigned int subSetEnd); 27 35 ~SubString(); 28 36 37 // operate on the SubString 38 SubString& operator=(const SubString& subString); 39 bool operator==(const SubString& subString); 40 SubString operator+(const SubString& subString) const; 41 SubString& operator+=(const SubString& subString); 42 /** @param subString the String to append @returns appended String. @brief added for convenience */ 43 SubString& append(const SubString subString) { return (*this += subString); }; 44 45 ///////////////////////////////////////// 46 // Split and Join the any String. /////// 29 47 unsigned int split(const std::string& string = "", char splitter = ','); 30 48 unsigned int split(const std::string& string, bool whiteSpaces); 31 49 unsigned int split(const std::string& string, const std::string& splitters, char escapeChar ='\\', char safemode_char = '"', char comment_char = '\0'); 50 std::string join(const std::string& delimiter) const; 51 //////////////////////////////////////// 32 52 33 inline unsigned int getCount() { return this->strings.size(); }; 34 const std::string& getString(unsigned int i) { return (i < this->strings.size()) ? this->strings[i] : emptyString; }; // safety-precaution 35 const std::string& operator[](unsigned int i) { return this->getString(i); }; 36 unsigned int getOffset(unsigned int i); 53 // retrieve a SubSet from the String 54 SubString getSubSet(unsigned int subSetBegin) const; 55 SubString getSubSet(unsigned int subSetBegin, unsigned int subSetEnd) const; 37 56 57 // retrieve Information from within 58 inline unsigned int size() const { return this->strings.size(); }; 59 const std::string& getString(unsigned int i) const { return (i < this->strings.size()) ? this->strings[i] : emptyString; } 60 ; // safety-precaution 61 const std::string& operator[](unsigned int i) const { return this->getString(i); }; 62 unsigned int getOffset(unsigned int i) const; 63 64 // the almighty algorithm. 38 65 static SPLIT_LINE_STATE splitLine(std::vector<std::string>& ret,std::vector<unsigned int>& offsets, 39 66 const std::string& line, const std::string& delimiters = " \t\r\n", 40 67 char escape_char = '\\', char safemode_char = '"', char comment_char = '\0', 41 68 SPLIT_LINE_STATE start_state = SL_NORMAL); 42 69 // debugging. 43 70 void debug() const; 44 71 45 46 47 72 private: 73 std::vector<std::string> strings; //!< strings produced from a single string splitted in multiple strings 74 std::vector<unsigned int> offsets; //!< offsets of the beginning of the input-string to the beginning of each substring. 48 75 49 76 static const std::string emptyString; 50 77 }; 51 78
Note: See TracChangeset
for help on using the changeset viewer.