Changeset 1049 for code/branches/core2/src/orxonox/core
- Timestamp:
- Apr 14, 2008, 12:48:25 AM (17 years ago)
- Location:
- code/branches/core2/src/orxonox/core
- Files:
-
- 5 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_ = "";
Note: See TracChangeset
for help on using the changeset viewer.