Changeset 1049 for code/branches/core2
- Timestamp:
- Apr 14, 2008, 12:48:25 AM (17 years ago)
- Location:
- code/branches/core2/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core2/src/orxonox/core/CommandExecutor.cc
r1030 r1049 335 335 bool CommandExecutor::execute(const std::string& command) 336 336 { 337 std::string strippedCommand = getStrippedEnclosingQuotes(command);337 std::string strippedCommand = stripEnclosingQuotes(command); 338 338 339 339 SubString tokensIO(strippedCommand, " ", SubString::WhiteSpaces, false, '\\', false, '"', false, '(', ')', false, '\0'); -
code/branches/core2/src/orxonox/core/ConfigFileManager.cc
r1030 r1049 66 66 // ConfigFileEntryValue // 67 67 ////////////////////////// 68 69 void ConfigFileEntryValue::setValue(const std::string& value) 70 { 71 if (!this->bString_) 72 this->value_ = value; 73 else 74 this->value_ = "\"" + addSlashes(value) + "\""; 75 } 76 77 std::string ConfigFileEntryValue::getValue() const 78 { 79 if (!this->bString_) 80 return this->value_; 81 else 82 return removeSlashes(stripEnclosingQuotes(this->value_)); 83 } 84 68 85 std::string ConfigFileEntryValue::getFileEntry() const 69 86 { … … 130 147 } 131 148 132 std::list<ConfigFileEntry*>::iterator ConfigFileSection::getEntryIterator(const std::string& name, const std::string& fallback )149 std::list<ConfigFileEntry*>::iterator ConfigFileSection::getEntryIterator(const std::string& name, const std::string& fallback, bool bString) 133 150 { 134 151 for (std::list<ConfigFileEntry*>::iterator it = this->entries_.begin(); it != this->entries_.end(); ++it) 152 { 135 153 if ((*it)->getName() == name) 154 { 155 (*it)->setString(bString); 136 156 return it; 157 } 158 } 137 159 138 160 this->bUpdated_ = true; 139 161 140 return this->entries_.insert(this->entries_.end(), (ConfigFileEntry*)(new ConfigFileEntryValue(name, fallback )));141 } 142 143 std::list<ConfigFileEntry*>::iterator ConfigFileSection::getEntryIterator(const std::string& name, unsigned int index, const std::string& fallback )162 return this->entries_.insert(this->entries_.end(), (ConfigFileEntry*)(new ConfigFileEntryValue(name, fallback, bString))); 163 } 164 165 std::list<ConfigFileEntry*>::iterator ConfigFileSection::getEntryIterator(const std::string& name, unsigned int index, const std::string& fallback, bool bString) 144 166 { 145 167 for (std::list<ConfigFileEntry*>::iterator it = this->entries_.begin(); it != this->entries_.end(); ++it) 168 { 146 169 if (((*it)->getName() == name) && ((*it)->getIndex() == index)) 170 { 171 (*it)->setString(bString); 147 172 return it; 173 } 174 } 148 175 149 176 this->bUpdated_ = true; 150 177 151 178 if (index == 0) 152 return this->entries_.insert(this->entries_.end(), (ConfigFileEntry*)(new ConfigFileEntryVectorValue(name, index, fallback )));153 else 154 return this->entries_.insert(++this->getEntryIterator(name, index - 1 ), (ConfigFileEntry*)(new ConfigFileEntryVectorValue(name, index, fallback)));179 return this->entries_.insert(this->entries_.end(), (ConfigFileEntry*)(new ConfigFileEntryVectorValue(name, index, fallback, bString))); 180 else 181 return this->entries_.insert(++this->getEntryIterator(name, index - 1, "", bString), (ConfigFileEntry*)(new ConfigFileEntryVectorValue(name, index, fallback, bString))); 155 182 } 156 183 … … 233 260 unsigned int pos2 = line.find('['); 234 261 unsigned int pos3 = line.find(']'); 235 236 std::string value = removeTrailingWhitespaces(line.substr(pos1 + 1)); 237 std::string comment = ""; 238 239 std::string betweenQuotes = getStringBetweenQuotes(value); 240 if (value.size() > 0 && value[0] == '"' && betweenQuotes != "" && betweenQuotes.size() > 0) 262 unsigned int commentposition = getNextCommentPosition(line, pos1 + 1); 263 while (isBetweenQuotes(line, commentposition)) 241 264 { 242 value = betweenQuotes; 243 if (line.size() > pos1 + 1 + betweenQuotes.size() + 2) 244 comment = removeTrailingWhitespaces(getComment(line.substr(pos1 + 1 + betweenQuotes.size() + 2))); 265 commentposition = getNextCommentPosition(line, commentposition + 1); 266 } 267 std::string value = "", comment = ""; 268 if (commentposition == std::string::npos) 269 { 270 value = removeTrailingWhitespaces(line.substr(pos1 + 1)); 245 271 } 246 272 else 247 273 { 248 unsigned int pos4 = getCommentPosition(line); 249 value = removeTrailingWhitespaces(line.substr(pos1 + 1, pos4 - pos1 - 1)); 250 if (pos4 != std::string::npos) 251 comment = removeTrailingWhitespaces(line.substr(pos4)); 274 value = removeTrailingWhitespaces(line.substr(pos1 + 1, commentposition - pos1 - 1)); 275 comment = removeTrailingWhitespaces(line.substr(commentposition)); 252 276 } 253 277 … … 259 283 { 260 284 // New array 261 std::list<ConfigFileEntry*>::iterator it = newsection->getEntryIterator(getStripped(line.substr(0, pos2)), index, value );285 std::list<ConfigFileEntry*>::iterator it = newsection->getEntryIterator(getStripped(line.substr(0, pos2)), index, value, false); 262 286 (*it)->setValue(value); 263 287 (*it)->setComment(comment); … … 267 291 268 292 // New value 269 newsection->getEntries().insert(newsection->getEntries().end(), new ConfigFileEntryValue(getStripped(line.substr(0, pos1)), value, comment));293 newsection->getEntries().insert(newsection->getEntries().end(), new ConfigFileEntryValue(getStripped(line.substr(0, pos1)), value, false, comment)); 270 294 continue; 271 295 } -
code/branches/core2/src/orxonox/core/ConfigFileManager.h
r1030 r1049 63 63 public: 64 64 virtual void setValue(const std::string& value) = 0; 65 virtual const std::string&getValue() const = 0;65 virtual std::string getValue() const = 0; 66 66 virtual const std::string& getName() const = 0; 67 67 virtual void setComment(const std::string& comment) = 0; 68 68 virtual unsigned int getIndex() const { return 0; } 69 virtual void setString(bool bString) = 0; 69 70 virtual std::string getFileEntry() const = 0; 70 71 }; … … 77 78 { 78 79 public: 79 inline ConfigFileEntryValue(const std::string& name, const std::string& value = "", const std::string& additionalComment = "") : name_(name), value_(value), additionalComment_(additionalComment), bString_(false) {}80 inline ConfigFileEntryValue(const std::string& name, const std::string& value = "", bool bString = false, const std::string& additionalComment = "") : name_(name), value_(value), bString_(bString), additionalComment_(additionalComment) {} 80 81 inline virtual ~ConfigFileEntryValue() {} 81 82 … … 86 87 { this->additionalComment_ = comment; } 87 88 88 inline virtual void setValue(const std::string& value) 89 { this->value_ = value; } 90 inline virtual const std::string& getValue() const 91 { return this->value_; } 89 virtual void setValue(const std::string& value); 90 virtual std::string getValue() const; 92 91 93 92 inline bool isString() const … … 101 100 std::string name_; 102 101 std::string value_; 102 bool bString_; 103 103 std::string additionalComment_; 104 bool bString_;105 104 }; 106 105 … … 112 111 { 113 112 public: 114 inline ConfigFileEntryVectorValue(const std::string& name, unsigned int index, const std::string& value = "", const std::string& additionalComment = "") : ConfigFileEntryValue(name, value, additionalComment), index_(index) {}113 inline ConfigFileEntryVectorValue(const std::string& name, unsigned int index, const std::string& value = "", bool bString = false, const std::string& additionalComment = "") : ConfigFileEntryValue(name, value, bString, additionalComment), index_(index) {} 115 114 inline virtual ~ConfigFileEntryVectorValue() {} 116 115 … … 142 141 inline virtual void setValue(const std::string& value) 143 142 {} 144 inline virtual const std::string&getValue() const143 inline virtual std::string getValue() const 145 144 { return this->comment_; } 145 146 inline void setString(bool bString) {} 146 147 147 148 inline virtual std::string getFileEntry() const … … 170 171 { this->additionalComment_ = comment; } 171 172 172 inline void setValue(const std::string& name, const std::string& value )173 { this->getEntry(name, value )->setValue(value); }174 inline const std::string& getValue(const std::string& name, const std::string& fallback)175 { return this->getEntry(name, fallback )->getValue(); }176 177 inline void setValue(const std::string& name, unsigned int index, const std::string& value )178 { this->getEntry(name, index, value )->setValue(value); }179 inline const std::string& getValue(const std::string& name, unsigned int index, const std::string& fallback)180 { return this->getEntry(name, index, fallback )->getValue(); }173 inline void setValue(const std::string& name, const std::string& value, bool bString) 174 { this->getEntry(name, value, bString)->setValue(value); } 175 inline std::string getValue(const std::string& name, const std::string& fallback, bool bString) 176 { return this->getEntry(name, fallback, bString)->getValue(); } 177 178 inline void setValue(const std::string& name, unsigned int index, const std::string& value, bool bString) 179 { this->getEntry(name, index, value, bString)->setValue(value); } 180 inline std::string getValue(const std::string& name, unsigned int index, const std::string& fallback, bool bString) 181 { return this->getEntry(name, index, fallback, bString)->getValue(); } 181 182 182 183 void deleteVectorEntries(const std::string& name, unsigned int startindex = 0); … … 193 194 { return this->entries_.end(); } 194 195 195 std::list<ConfigFileEntry*>::iterator getEntryIterator(const std::string& name, const std::string& fallback = "");196 std::list<ConfigFileEntry*>::iterator getEntryIterator(const std::string& name, unsigned int index, const std::string& fallback = "");197 198 inline ConfigFileEntry* getEntry(const std::string& name, const std::string& fallback )199 { return (*this->getEntryIterator(name, fallback )); }200 inline ConfigFileEntry* getEntry(const std::string& name, unsigned int index, const std::string& fallback )201 { return (*this->getEntryIterator(name, index, fallback )); }196 std::list<ConfigFileEntry*>::iterator getEntryIterator(const std::string& name, const std::string& fallback, bool bString); 197 std::list<ConfigFileEntry*>::iterator getEntryIterator(const std::string& name, unsigned int index, const std::string& fallback, bool bString); 198 199 inline ConfigFileEntry* getEntry(const std::string& name, const std::string& fallback, bool bString) 200 { return (*this->getEntryIterator(name, fallback, bString)); } 201 inline ConfigFileEntry* getEntry(const std::string& name, unsigned int index, const std::string& fallback, bool bString) 202 { return (*this->getEntryIterator(name, index, fallback, bString)); } 202 203 203 204 std::string name_; … … 221 222 void clean(bool bCleanComments = false); 222 223 223 inline void setValue(const std::string& section, const std::string& name, const std::string& value )224 { this->getSection(section)->setValue(name, value ); this->save(); }225 inline const std::string& getValue(const std::string& section, const std::string& name, const std::string& fallback)226 { const std::string& output = this->getSection(section)->getValue(name, fallback); this->saveIfUpdated(); return output; }227 228 inline void setValue(const std::string& section, const std::string& name, unsigned int index, const std::string& value )229 { this->getSection(section)->setValue(name, index, value ); this->save(); }230 inline const std::string& getValue(const std::string& section, const std::string& name, unsigned int index, const std::string& fallback)231 { const std::string& output = this->getSection(section)->getValue(name, index, fallback); this->saveIfUpdated(); return output; }224 inline void setValue(const std::string& section, const std::string& name, const std::string& value, bool bString) 225 { this->getSection(section)->setValue(name, value, bString); this->save(); } 226 inline std::string getValue(const std::string& section, const std::string& name, const std::string& fallback, bool bString) 227 { std::string output = this->getSection(section)->getValue(name, fallback, bString); this->saveIfUpdated(); return output; } 228 229 inline void setValue(const std::string& section, const std::string& name, unsigned int index, const std::string& value, bool bString) 230 { this->getSection(section)->setValue(name, index, value, bString); this->save(); } 231 inline std::string getValue(const std::string& section, const std::string& name, unsigned int index, const std::string& fallback, bool bString) 232 { std::string output = this->getSection(section)->getValue(name, index, fallback, bString); this->saveIfUpdated(); return output; } 232 233 233 234 inline void deleteVectorEntries(const std::string& section, const std::string& name, unsigned int startindex = 0) … … 264 265 void clean(ConfigFileType type, bool bCleanComments = false); 265 266 266 inline void setValue(ConfigFileType type, const std::string& section, const std::string& name, const std::string& value )267 { this->getFile(type)->setValue(section, name, value ); }268 inline const std::string& getValue(ConfigFileType type, const std::string& section, const std::string& name, const std::string& fallback)269 { return this->getFile(type)->getValue(section, name, fallback ); }270 271 inline void setValue(ConfigFileType type, const std::string& section, const std::string& name, unsigned int index, const std::string& value )272 { this->getFile(type)->setValue(section, name, index, value ); }273 inline const std::string& getValue(ConfigFileType type, const std::string& section, const std::string& name, unsigned int index, const std::string& fallback)274 { return this->getFile(type)->getValue(section, name, index, fallback ); }267 inline void setValue(ConfigFileType type, const std::string& section, const std::string& name, const std::string& value, bool bString) 268 { this->getFile(type)->setValue(section, name, value, bString); } 269 inline std::string getValue(ConfigFileType type, const std::string& section, const std::string& name, const std::string& fallback, bool bString) 270 { return this->getFile(type)->getValue(section, name, fallback, bString); } 271 272 inline void setValue(ConfigFileType type, const std::string& section, const std::string& name, unsigned int index, const std::string& value, bool bString) 273 { this->getFile(type)->setValue(section, name, index, value, bString); } 274 inline std::string getValue(ConfigFileType type, const std::string& section, const std::string& name, unsigned int index, const std::string& fallback, bool bString) 275 { return this->getFile(type)->getValue(section, name, index, fallback, bString); } 275 276 276 277 inline void deleteVectorEntries(ConfigFileType type, const std::string& section, const std::string& name, unsigned int startindex = 0) -
code/branches/core2/src/orxonox/core/ConfigValueContainer.cc
r1036 r1049 88 88 89 89 for (unsigned int i = 0; i < defvalue.size(); i++) 90 ConfigFileManager::getSingleton()->getValue(this->type_, this->sectionname_, this->varname_, i, defvalue[i].toString() );90 ConfigFileManager::getSingleton()->getValue(this->type_, this->sectionname_, this->varname_, i, defvalue[i].toString(), this->value_.isA(MT_string)); 91 91 92 92 for (unsigned int i = 0; i < defvalue.size(); i++) … … 123 123 this->valueVector_.erase(this->valueVector_.begin() + index); 124 124 for (unsigned int i = index; i < this->valueVector_.size(); i++) 125 ConfigFileManager::getSingleton()->setValue(this->type_, this->sectionname_, this->varname_, i, this->valueVector_[i] );125 ConfigFileManager::getSingleton()->setValue(this->type_, this->sectionname_, this->varname_, i, this->valueVector_[i], this->value_.isA(MT_string)); 126 126 ConfigFileManager::getSingleton()->deleteVectorEntries(this->type_, this->sectionname_, this->varname_, this->valueVector_.size()); 127 127 … … 171 171 172 172 bool success = this->tset(input); 173 ConfigFileManager::getSingleton()->setValue(this->type_, this->sectionname_, this->varname_, input );173 ConfigFileManager::getSingleton()->setValue(this->type_, this->sectionname_, this->varname_, input, this->value_.isA(MT_string)); 174 174 return success; 175 175 } … … 186 186 { 187 187 bool success = this->tset(index, input); 188 ConfigFileManager::getSingleton()->setValue(this->type_, this->sectionname_, this->varname_, index, input );188 ConfigFileManager::getSingleton()->setValue(this->type_, this->sectionname_, this->varname_, index, input, this->value_.isA(MT_string)); 189 189 return success; 190 190 } … … 251 251 { 252 252 if (!this->bIsVector_) 253 this->value_.fromString(ConfigFileManager::getSingleton()->getValue(this->type_, this->sectionname_, this->varname_, this->defvalueString_ ));253 this->value_.fromString(ConfigFileManager::getSingleton()->getValue(this->type_, this->sectionname_, this->varname_, this->defvalueString_, this->value_.isA(MT_string))); 254 254 else 255 255 { … … 257 257 for (unsigned int i = 0; i < ConfigFileManager::getSingleton()->getVectorSize(this->type_, this->sectionname_, this->varname_); i++) 258 258 { 259 this->value_.fromString(ConfigFileManager::getSingleton()->getValue(this->type_, this->sectionname_, this->varname_, i, this->defvalueStringVector_[i] ));259 this->value_.fromString(ConfigFileManager::getSingleton()->getValue(this->type_, this->sectionname_, this->varname_, i, this->defvalueStringVector_[i], this->value_.isA(MT_string))); 260 260 this->valueVector_.push_back(this->value_); 261 261 } … … 322 322 { 323 323 this->valueVector_.push_back(MultiTypeMath()); 324 ConfigFileManager::getSingleton()->setValue(this->type_, this->sectionname_, this->varname_, i, this->valueVector_[i] );324 ConfigFileManager::getSingleton()->setValue(this->type_, this->sectionname_, this->varname_, i, this->valueVector_[i], this->value_.isA(MT_string)); 325 325 } 326 326 } -
code/branches/core2/src/orxonox/core/InputBuffer.cc
r994 r1049 36 36 { 37 37 this->bActivated_ = false; 38 this->allowedChars_ = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZäöüÄÖÜ0123456789 \ "().:,;_-+*/=!?<>[|]";38 this->allowedChars_ = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZäöüÄÖÜ0123456789 \\\"().:,;_-+*/=!?<>[|]"; 39 39 this->keyboard_ = keyboard; 40 40 this->buffer_ = ""; -
code/branches/core2/src/orxonox/objects/test3.cc
r1033 r1049 84 84 std::cout << "vector<int>: " << i << ": " << this->vector_int_[i] << std::endl; 85 85 for (unsigned int i = 0; i < this->vector_string_.size(); i++) 86 std::cout << "vector<string>: " << i << ": " << this->vector_string_[i]<< std::endl;86 std::cout << "vector<string>: " << i << ":>" << this->vector_string_[i] << "<" << std::endl; 87 87 for (unsigned int i = 0; i < this->vector_vector3_.size(); i++) 88 88 std::cout << "vector<vector3>: " << i << ": " << this->vector_vector3_[i] << std::endl; -
code/branches/core2/src/util/String.cc
r1020 r1049 27 27 28 28 #include <cctype> 29 29 #include <iostream> 30 30 #include "String.h" 31 31 … … 92 92 93 93 return quote; 94 } 95 96 /** 97 @brief Returns true if pos is between two quotes. 98 @param str The string 99 @param pos The position to check 100 @return True if pos is between two quotes 101 */ 102 bool isBetweenQuotes(const std::string& str, unsigned int pos) 103 { 104 if (pos == std::string::npos) 105 return false; 106 107 unsigned int quotecount = 0; 108 unsigned int quote = 0; 109 while ((quote = getNextQuote(str, quote)) < pos) 110 { 111 quotecount++; 112 } 113 114 if (quote == std::string::npos) 115 return false; 116 117 return ((quotecount % 2) == 1); 94 118 } 95 119 … … 124 148 @brief Removes enclosing quotes if available. 125 149 @brief str The string to strip 126 */ 127 void stripEnclosingQuotes(std::string* str) 150 @return The string with removed quotes 151 */ 152 std::string stripEnclosingQuotes(const std::string& str) 128 153 { 129 154 unsigned int start = std::string::npos; 130 155 unsigned int end = 0; 131 156 132 for (unsigned int pos = 0; (pos < (*str).size()) && (pos < std::string::npos); pos++)133 { 134 if ( (*str)[pos] == '"')157 for (unsigned int pos = 0; (pos < str.size()) && (pos < std::string::npos); pos++) 158 { 159 if (str[pos] == '"') 135 160 { 136 161 start = pos; … … 138 163 } 139 164 140 if (( (*str)[pos] != ' ') && ((*str)[pos] != '\t') && ((*str)[pos] != '\n'))141 return ;142 } 143 144 for (unsigned int pos = (*str).size() - 1; pos < std::string::npos; pos--)145 { 146 if ( (*str)[pos] == '"')165 if ((str[pos] != ' ') && (str[pos] != '\t') && (str[pos] != '\n')) 166 return str; 167 } 168 169 for (unsigned int pos = str.size() - 1; pos < std::string::npos; pos--) 170 { 171 if (str[pos] == '"') 147 172 { 148 173 end = pos; … … 150 175 } 151 176 152 if (( (*str)[pos] != ' ') && ((*str)[pos] != '\t') && ((*str)[pos] != '\n'))153 return ;177 if ((str[pos] != ' ') && (str[pos] != '\t') && (str[pos] != '\n')) 178 return str; 154 179 } 155 180 156 181 if ((start != std::string::npos) && (end != 0)) 157 (*str) = (*str).substr(start + 1, end - start - 1); 158 } 159 160 /** 161 @brief Returns a copy of the string with removed enclosing quotes (if available). 162 @brief str The string to strip 163 @return The striped copy of the string 164 */ 165 std::string getStrippedEnclosingQuotes(const std::string& str) 166 { 167 std::string output = std::string(str); 168 stripEnclosingQuotes(&output); 169 return output; 182 return str.substr(start + 1, end - start - 1); 183 else 184 return str; 170 185 } 171 186 … … 235 250 } 236 251 252 std::string addSlashes(const std::string& str) 253 { 254 std::string output = str; 255 256 for (unsigned int pos = 0; (pos = output.find('\\', pos)) < std::string::npos; pos += 2) { output.replace(pos, 2, "\\\\"); } 257 for (unsigned int pos = 0; (pos = output.find('\n', pos)) < std::string::npos; pos += 2) { output.replace(pos, 2, "\\n"); } 258 for (unsigned int pos = 0; (pos = output.find('\t', pos)) < std::string::npos; pos += 2) { output.replace(pos, 2, "\\t"); } 259 for (unsigned int pos = 0; (pos = output.find('\v', pos)) < std::string::npos; pos += 2) { output.replace(pos, 2, "\\v"); } 260 for (unsigned int pos = 0; (pos = output.find('\b', pos)) < std::string::npos; pos += 2) { output.replace(pos, 2, "\\b"); } 261 for (unsigned int pos = 0; (pos = output.find('\r', pos)) < std::string::npos; pos += 2) { output.replace(pos, 2, "\\r"); } 262 for (unsigned int pos = 0; (pos = output.find('\f', pos)) < std::string::npos; pos += 2) { output.replace(pos, 2, "\\f"); } 263 for (unsigned int pos = 0; (pos = output.find('\a', pos)) < std::string::npos; pos += 2) { output.replace(pos, 2, "\\a"); } 264 for (unsigned int pos = 0; (pos = output.find('"', pos)) < std::string::npos; pos += 2) { output.replace(pos, 2, "\\\""); } 265 for (unsigned int pos = 0; (pos = output.find('\0', pos)) < std::string::npos; pos += 2) { output.replace(pos, 2, "\\0"); } 266 267 return output; 268 } 269 270 std::string removeSlashes(const std::string& str) 271 { 272 if (str.size() == 0) 273 return str; 274 275 std::string output = ""; 276 for (unsigned int pos = 0; pos < str.size() - 1; ) 277 { 278 if (str[pos] == '\\') 279 { 280 if (str[pos + 1] == '\\') { output += '\\'; pos += 2; continue; } 281 else if (str[pos + 1] == 'n') { output += '\n'; pos += 2; continue; } 282 else if (str[pos + 1] == 't') { output += '\t'; pos += 2; continue; } 283 else if (str[pos + 1] == 'v') { output += '\v'; pos += 2; continue; } 284 else if (str[pos + 1] == 'b') { output += '\b'; pos += 2; continue; } 285 else if (str[pos + 1] == 'r') { output += '\r'; pos += 2; continue; } 286 else if (str[pos + 1] == 'f') { output += '\f'; pos += 2; continue; } 287 else if (str[pos + 1] == 'a') { output += '\a'; pos += 2; continue; } 288 else if (str[pos + 1] == '"') { output += '"'; pos += 2; continue; } 289 else if (str[pos + 1] == '0') { output += '\0'; pos += 2; continue; } 290 } 291 output += str[pos]; 292 pos++; 293 } 294 output += str[str.size() - 1]; 295 296 return output; 297 } 298 237 299 /** 238 300 @brief Replaces each char between A and Z with its lowercase equivalent. … … 364 426 unsigned int getCommentPosition(const std::string& str) 365 427 { 366 for (unsigned int i = 0; i < str.size(); i++) 428 return getNextCommentPosition(str, 0); 429 } 430 431 /** 432 @brief Returns the position of the next comment-symbol, starting with start. 433 @param str The string 434 @param start The startposition 435 @return The position 436 */ 437 unsigned int getNextCommentPosition(const std::string& str, unsigned int start) 438 { 439 for (unsigned int i = start; i < str.size(); i++) 367 440 if (isComment(str.substr(i))) 368 441 return i; -
code/branches/core2/src/util/String.h
r1020 r1049 40 40 41 41 _UtilExport unsigned int getNextQuote(const std::string& str, unsigned int start); 42 _UtilExport bool isBetweenQuotes(const std::string& str, unsigned int pos); 42 43 43 44 _UtilExport bool hasStringBetweenQuotes(const std::string& str); 44 45 _UtilExport std::string getStringBetweenQuotes(const std::string& str); 45 46 46 _UtilExport void stripEnclosingQuotes(std::string* str); 47 _UtilExport std::string getStrippedEnclosingQuotes(const std::string& str); 47 _UtilExport std::string stripEnclosingQuotes(const std::string& str); 48 48 49 49 _UtilExport bool isEmpty(const std::string& str); 50 50 _UtilExport bool isComment(const std::string& str); 51 51 _UtilExport bool isNumeric(const std::string& str); 52 53 _UtilExport std::string addSlashes(const std::string& str); 54 _UtilExport std::string removeSlashes(const std::string& str); 52 55 53 56 _UtilExport void lowercase(std::string* str); … … 63 66 _UtilExport std::string getComment(const std::string& str); 64 67 _UtilExport unsigned int getCommentPosition(const std::string& str); 68 _UtilExport unsigned int getNextCommentPosition(const std::string& str, unsigned int start = 0); 65 69 66 70 //! The Convert class has some static member functions to convert strings to values and values to strings.
Note: See TracChangeset
for help on using the changeset viewer.