- Timestamp:
- Dec 28, 2007, 10:30:29 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/FICN/src/orxonox/core/ConfigValueContainer.cc
r705 r708 28 28 #include <fstream> 29 29 30 #include " ../../misc/Tokenizer.h"31 #include " ../../misc/String2Number.h"30 #include "misc/Tokenizer.h" 31 #include "misc/String2Number.h" 32 32 #include "ConfigValueContainer.h" 33 33 … … 43 43 @param defvalue The default-value 44 44 */ 45 ConfigValueContainer::ConfigValueContainer(const std::string& classname, const std::string& varname, int defvalue)45 ConfigValueContainer::ConfigValueContainer(const String& classname, const String& varname, int defvalue) 46 46 { 47 47 this->bAddedDescription_ = false; … … 53 53 this->searchConfigFileLine(); // Search the entry in the config-file 54 54 55 std::string valueString = this->parseValueString(); // Parses the value string from the config-file-entry56 if (!this->parseSting(valueString, defvalue)) // Try to convert the string to a value 57 this->resetConfigFileEntry(); // The conversion failed 58 } 59 60 /** 61 @brief Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets the intern value variable. 62 @param value This is only needed to determine the right type. 63 @param classname The name of the class the variable belongs to 64 @param varname The name of the variable 65 @param defvalue The default-value 66 */ 67 ConfigValueContainer::ConfigValueContainer(const std::string& classname, const std::string& varname, unsigned int defvalue)55 String valueString = this->parseValueString(); // Parses the value string from the config-file-entry 56 if (!this->parseSting(valueString, defvalue)) // Try to convert the string to a value 57 this->resetConfigFileEntry(); // The conversion failed 58 } 59 60 /** 61 @brief Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets the intern value variable. 62 @param value This is only needed to determine the right type. 63 @param classname The name of the class the variable belongs to 64 @param varname The name of the variable 65 @param defvalue The default-value 66 */ 67 ConfigValueContainer::ConfigValueContainer(const String& classname, const String& varname, unsigned int defvalue) 68 68 { 69 69 this->bAddedDescription_ = false; … … 75 75 this->searchConfigFileLine(); // Search the entry in the config-file 76 76 77 std::string valueString = this->parseValueString(); // Parses the value string from the config-file-entry78 if (!this->parseSting(valueString, defvalue)) // Try to convert the string to a value 79 this->resetConfigFileEntry(); // The conversion failed 80 } 81 82 /** 83 @brief Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets the intern value variable. 84 @param value This is only needed to determine the right type. 85 @param classname The name of the class the variable belongs to 86 @param varname The name of the variable 87 @param defvalue The default-value 88 */ 89 ConfigValueContainer::ConfigValueContainer(const std::string& classname, const std::string& varname, char defvalue)77 String valueString = this->parseValueString(); // Parses the value string from the config-file-entry 78 if (!this->parseSting(valueString, defvalue)) // Try to convert the string to a value 79 this->resetConfigFileEntry(); // The conversion failed 80 } 81 82 /** 83 @brief Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets the intern value variable. 84 @param value This is only needed to determine the right type. 85 @param classname The name of the class the variable belongs to 86 @param varname The name of the variable 87 @param defvalue The default-value 88 */ 89 ConfigValueContainer::ConfigValueContainer(const String& classname, const String& varname, char defvalue) 90 90 { 91 91 this->bAddedDescription_ = false; … … 97 97 this->searchConfigFileLine(); // Search the entry in the config-file 98 98 99 std::string valueString = this->parseValueString(); // Parses the value string from the config-file-entry100 if (!this->parseSting(valueString, defvalue)) // Try to convert the string to a value 101 this->resetConfigFileEntry(); // The conversion failed 102 } 103 104 /** 105 @brief Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets the intern value variable. 106 @param value This is only needed to determine the right type. 107 @param classname The name of the class the variable belongs to 108 @param varname The name of the variable 109 @param defvalue The default-value 110 */ 111 ConfigValueContainer::ConfigValueContainer(const std::string& classname, const std::string& varname, unsigned char defvalue)99 String valueString = this->parseValueString(); // Parses the value string from the config-file-entry 100 if (!this->parseSting(valueString, defvalue)) // Try to convert the string to a value 101 this->resetConfigFileEntry(); // The conversion failed 102 } 103 104 /** 105 @brief Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets the intern value variable. 106 @param value This is only needed to determine the right type. 107 @param classname The name of the class the variable belongs to 108 @param varname The name of the variable 109 @param defvalue The default-value 110 */ 111 ConfigValueContainer::ConfigValueContainer(const String& classname, const String& varname, unsigned char defvalue) 112 112 { 113 113 this->bAddedDescription_ = false; … … 119 119 this->searchConfigFileLine(); // Search the entry in the config-file 120 120 121 std::string valueString = this->parseValueString(); // Parses the value string from the config-file-entry122 if (!this->parseSting(valueString, defvalue)) // Try to convert the string to a value 123 this->resetConfigFileEntry(); // The conversion failed 124 } 125 126 /** 127 @brief Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets the intern value variable. 128 @param value This is only needed to determine the right type. 129 @param classname The name of the class the variable belongs to 130 @param varname The name of the variable 131 @param defvalue The default-value 132 */ 133 ConfigValueContainer::ConfigValueContainer(const std::string& classname, const std::string& varname, float defvalue)121 String valueString = this->parseValueString(); // Parses the value string from the config-file-entry 122 if (!this->parseSting(valueString, defvalue)) // Try to convert the string to a value 123 this->resetConfigFileEntry(); // The conversion failed 124 } 125 126 /** 127 @brief Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets the intern value variable. 128 @param value This is only needed to determine the right type. 129 @param classname The name of the class the variable belongs to 130 @param varname The name of the variable 131 @param defvalue The default-value 132 */ 133 ConfigValueContainer::ConfigValueContainer(const String& classname, const String& varname, float defvalue) 134 134 { 135 135 this->bAddedDescription_ = false; … … 141 141 this->searchConfigFileLine(); // Search the entry in the config-file 142 142 143 std::string valueString = this->parseValueString(); // Parses the value string from the config-file-entry144 if (!this->parseSting(valueString, defvalue)) // Try to convert the string to a value 145 this->resetConfigFileEntry(); // The conversion failed 146 } 147 148 /** 149 @brief Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets the intern value variable. 150 @param value This is only needed to determine the right type. 151 @param classname The name of the class the variable belongs to 152 @param varname The name of the variable 153 @param defvalue The default-value 154 */ 155 ConfigValueContainer::ConfigValueContainer(const std::string& classname, const std::string& varname, double defvalue)143 String valueString = this->parseValueString(); // Parses the value string from the config-file-entry 144 if (!this->parseSting(valueString, defvalue)) // Try to convert the string to a value 145 this->resetConfigFileEntry(); // The conversion failed 146 } 147 148 /** 149 @brief Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets the intern value variable. 150 @param value This is only needed to determine the right type. 151 @param classname The name of the class the variable belongs to 152 @param varname The name of the variable 153 @param defvalue The default-value 154 */ 155 ConfigValueContainer::ConfigValueContainer(const String& classname, const String& varname, double defvalue) 156 156 { 157 157 this->bAddedDescription_ = false; … … 163 163 this->searchConfigFileLine(); // Search the entry in the config-file 164 164 165 std::string valueString = this->parseValueString(); // Parses the value string from the config-file-entry166 if (!this->parseSting(valueString, defvalue)) // Try to convert the string to a value 167 this->resetConfigFileEntry(); // The conversion failed 168 } 169 170 /** 171 @brief Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets the intern value variable. 172 @param value This is only needed to determine the right type. 173 @param classname The name of the class the variable belongs to 174 @param varname The name of the variable 175 @param defvalue The default-value 176 */ 177 ConfigValueContainer::ConfigValueContainer(const std::string& classname, const std::string& varname, long double defvalue)165 String valueString = this->parseValueString(); // Parses the value string from the config-file-entry 166 if (!this->parseSting(valueString, defvalue)) // Try to convert the string to a value 167 this->resetConfigFileEntry(); // The conversion failed 168 } 169 170 /** 171 @brief Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets the intern value variable. 172 @param value This is only needed to determine the right type. 173 @param classname The name of the class the variable belongs to 174 @param varname The name of the variable 175 @param defvalue The default-value 176 */ 177 ConfigValueContainer::ConfigValueContainer(const String& classname, const String& varname, long double defvalue) 178 178 { 179 179 this->bAddedDescription_ = false; … … 185 185 this->searchConfigFileLine(); // Search the entry in the config-file 186 186 187 std::string valueString = this->parseValueString(); // Parses the value string from the config-file-entry188 if (!this->parseSting(valueString, defvalue)) // Try to convert the string to a value 189 this->resetConfigFileEntry(); // The conversion failed 190 } 191 192 /** 193 @brief Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets the intern value variable. 194 @param value This is only needed to determine the right type. 195 @param classname The name of the class the variable belongs to 196 @param varname The name of the variable 197 @param defvalue The default-value 198 */ 199 ConfigValueContainer::ConfigValueContainer(const std::string& classname, const std::string& varname, bool defvalue)187 String valueString = this->parseValueString(); // Parses the value string from the config-file-entry 188 if (!this->parseSting(valueString, defvalue)) // Try to convert the string to a value 189 this->resetConfigFileEntry(); // The conversion failed 190 } 191 192 /** 193 @brief Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets the intern value variable. 194 @param value This is only needed to determine the right type. 195 @param classname The name of the class the variable belongs to 196 @param varname The name of the variable 197 @param defvalue The default-value 198 */ 199 ConfigValueContainer::ConfigValueContainer(const String& classname, const String& varname, bool defvalue) 200 200 { 201 201 this->bAddedDescription_ = false; … … 211 211 212 212 this->searchConfigFileLine(); // Search the entry in the config-file 213 std::string valueString = this->parseValueString(); // Parses the value string from the config-file-entry214 if (!this->parseSting(valueString, defvalue)) // Try to convert the string to a value 215 this->resetConfigFileEntry(); // The conversion failed 216 } 217 218 /** 219 @brief Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets the intern value variable. 220 @param value This is only needed to determine the right type. 221 @param classname The name of the class the variable belongs to 222 @param varname The name of the variable 223 @param defvalue The default-value 224 */ 225 ConfigValueContainer::ConfigValueContainer(const std::string& classname, const std::string& varname, const std::string& defvalue)226 { 227 this->bAddedDescription_ = false; 228 this->classname_ = classname; 229 this->varname_ = varname; 230 this->type_ = String;213 String valueString = this->parseValueString(); // Parses the value string from the config-file-entry 214 if (!this->parseSting(valueString, defvalue)) // Try to convert the string to a value 215 this->resetConfigFileEntry(); // The conversion failed 216 } 217 218 /** 219 @brief Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets the intern value variable. 220 @param value This is only needed to determine the right type. 221 @param classname The name of the class the variable belongs to 222 @param varname The name of the variable 223 @param defvalue The default-value 224 */ 225 ConfigValueContainer::ConfigValueContainer(const String& classname, const String& varname, const String& defvalue) 226 { 227 this->bAddedDescription_ = false; 228 this->classname_ = classname; 229 this->varname_ = varname; 230 this->type_ = _String; 231 231 232 232 this->defvalueString_ = "\"" + defvalue + "\""; // Convert the string to a "config-file-string" with quotes 233 233 this->searchConfigFileLine(); // Search the entry in the config-file 234 std::string valueString = this->parseValueString(false); // Parses the value string from the config-file-entry235 if (!this->parseSting(valueString, defvalue)) // Try to convert the string to a value 236 this->resetConfigFileEntry(); // The conversion failed 237 } 238 239 /** 240 @brief Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets the intern value variable. 241 @param value This is only needed to determine the right type. 242 @param classname The name of the class the variable belongs to 243 @param varname The name of the variable 244 @param defvalue The default-value 245 */ 246 ConfigValueContainer::ConfigValueContainer(const std::string& classname, const std::string& varname, const char* defvalue)234 String valueString = this->parseValueString(false); // Parses the value string from the config-file-entry 235 if (!this->parseSting(valueString, defvalue)) // Try to convert the string to a value 236 this->resetConfigFileEntry(); // The conversion failed 237 } 238 239 /** 240 @brief Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets the intern value variable. 241 @param value This is only needed to determine the right type. 242 @param classname The name of the class the variable belongs to 243 @param varname The name of the variable 244 @param defvalue The default-value 245 */ 246 ConfigValueContainer::ConfigValueContainer(const String& classname, const String& varname, const char* defvalue) 247 247 { 248 248 this->bAddedDescription_ = false; … … 251 251 this->type_ = ConstChar; 252 252 253 this->defvalueString_ = "\"" + std::string(defvalue) + "\""; // Convert the string to a "config-file-string" with quotes254 this->searchConfigFileLine(); // Search the entry in the config-file 255 std::string valueString = this->parseValueString(false); // Parses the value string from the config-file-entry256 if (!this->parseSting(valueString, defvalue)) // Try to convert the string to a value 257 this->resetConfigFileEntry(); // The conversion failed 258 } 259 260 /** 261 @brief Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets the intern value variable. 262 @param value This is only needed to determine the right type. 263 @param classname The name of the class the variable belongs to 264 @param varname The name of the variable 265 @param defvalue The default-value 266 */ 267 ConfigValueContainer::ConfigValueContainer(const std::string& classname, const std::string& varname, Ogre::Vector2 defvalue)268 { 269 this->bAddedDescription_ = false; 270 this->classname_ = classname; 271 this->varname_ = varname; 272 this->type_ = Vector2;253 this->defvalueString_ = "\"" + String(defvalue) + "\""; // Convert the string to a "config-file-string" with quotes 254 this->searchConfigFileLine(); // Search the entry in the config-file 255 String valueString = this->parseValueString(false); // Parses the value string from the config-file-entry 256 if (!this->parseSting(valueString, defvalue)) // Try to convert the string to a value 257 this->resetConfigFileEntry(); // The conversion failed 258 } 259 260 /** 261 @brief Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets the intern value variable. 262 @param value This is only needed to determine the right type. 263 @param classname The name of the class the variable belongs to 264 @param varname The name of the variable 265 @param defvalue The default-value 266 */ 267 ConfigValueContainer::ConfigValueContainer(const String& classname, const String& varname, Vector2 defvalue) 268 { 269 this->bAddedDescription_ = false; 270 this->classname_ = classname; 271 this->varname_ = varname; 272 this->type_ = _Vector2; 273 273 274 274 // Try to convert the default-value from Vector2 to string … … 280 280 281 281 this->searchConfigFileLine(); // Search the entry in the config-file 282 std::string valueString = this->parseValueString(); // Parses the value string from the config-file-entry283 if (!this->parseSting(valueString, defvalue)) // Try to convert the string to a value 284 this->resetConfigFileEntry(); // The conversion failed 285 } 286 287 /** 288 @brief Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets the intern value variable. 289 @param value This is only needed to determine the right type. 290 @param classname The name of the class the variable belongs to 291 @param varname The name of the variable 292 @param defvalue The default-value 293 */ 294 ConfigValueContainer::ConfigValueContainer(const std::string& classname, const std::string& varname, Ogre::Vector3 defvalue)295 { 296 this->bAddedDescription_ = false; 297 this->classname_ = classname; 298 this->varname_ = varname; 299 this->type_ = Vector3;282 String valueString = this->parseValueString(); // Parses the value string from the config-file-entry 283 if (!this->parseSting(valueString, defvalue)) // Try to convert the string to a value 284 this->resetConfigFileEntry(); // The conversion failed 285 } 286 287 /** 288 @brief Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets the intern value variable. 289 @param value This is only needed to determine the right type. 290 @param classname The name of the class the variable belongs to 291 @param varname The name of the variable 292 @param defvalue The default-value 293 */ 294 ConfigValueContainer::ConfigValueContainer(const String& classname, const String& varname, Vector3 defvalue) 295 { 296 this->bAddedDescription_ = false; 297 this->classname_ = classname; 298 this->varname_ = varname; 299 this->type_ = _Vector3; 300 300 301 301 // Try to convert the default-value from Vector3 to string … … 307 307 308 308 this->searchConfigFileLine(); // Search the entry in the config-file 309 std::string valueString = this->parseValueString(); // Parses the value string from the config-file-entry310 if (!this->parseSting(valueString, defvalue)) // Try to convert the string to a value 311 this->resetConfigFileEntry(); // The conversion failed 312 } 313 314 /** 315 @brief Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets the intern value variable. 316 @param value This is only needed to determine the right type. 317 @param classname The name of the class the variable belongs to 318 @param varname The name of the variable 319 @param defvalue The default-value 320 */ 321 ConfigValueContainer::ConfigValueContainer(const std::string& classname, const std::string& varname, Ogre::ColourValue defvalue)322 { 323 this->bAddedDescription_ = false; 324 this->classname_ = classname; 325 this->varname_ = varname; 326 this->type_ = ColourValue;309 String valueString = this->parseValueString(); // Parses the value string from the config-file-entry 310 if (!this->parseSting(valueString, defvalue)) // Try to convert the string to a value 311 this->resetConfigFileEntry(); // The conversion failed 312 } 313 314 /** 315 @brief Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets the intern value variable. 316 @param value This is only needed to determine the right type. 317 @param classname The name of the class the variable belongs to 318 @param varname The name of the variable 319 @param defvalue The default-value 320 */ 321 ConfigValueContainer::ConfigValueContainer(const String& classname, const String& varname, ColourValue defvalue) 322 { 323 this->bAddedDescription_ = false; 324 this->classname_ = classname; 325 this->varname_ = varname; 326 this->type_ = _ColourValue; 327 327 328 328 // Try to convert the default-value from ColourValue to string … … 334 334 335 335 this->searchConfigFileLine(); // Search the entry in the config-file 336 std::string valueString = this->parseValueString(); // Parses the value string from the config-file-entry337 if (!this->parseSting(valueString, defvalue)) // Try to convert the string to a value 338 this->resetConfigFileEntry(); // The conversion failed 339 } 340 341 /** 342 @brief Parses a given std::string into a value of the type of the associated variable and assigns it.343 @param input The string to convert 344 @return True if the string was successfully parsed 345 */ 346 bool ConfigValueContainer::parseSting(const std::string& input)336 String valueString = this->parseValueString(); // Parses the value string from the config-file-entry 337 if (!this->parseSting(valueString, defvalue)) // Try to convert the string to a value 338 this->resetConfigFileEntry(); // The conversion failed 339 } 340 341 /** 342 @brief Parses a given String into a value of the type of the associated variable and assigns it. 343 @param input The string to convert 344 @return True if the string was successfully parsed 345 */ 346 bool ConfigValueContainer::parseSting(const String& input) 347 347 { 348 348 if (this->type_ == ConfigValueContainer::Int) … … 362 362 else if (this->type_ == ConfigValueContainer::Bool) 363 363 return this->parseSting(input, this->value_.value_bool_); 364 else if (this->type_ == ConfigValueContainer:: String)364 else if (this->type_ == ConfigValueContainer::_String) 365 365 return this->parseSting(input, this->value_string_); 366 366 else if (this->type_ == ConfigValueContainer::ConstChar) 367 367 return this->parseSting(input, this->value_string_); 368 else if (this->type_ == ConfigValueContainer:: Vector2)368 else if (this->type_ == ConfigValueContainer::_Vector2) 369 369 return this->parseSting(input, this->value_vector2_); 370 else if (this->type_ == ConfigValueContainer:: Vector3)370 else if (this->type_ == ConfigValueContainer::_Vector3) 371 371 return this->parseSting(input, this->value_vector3_); 372 else if (this->type_ == ConfigValueContainer:: ColourValue)372 else if (this->type_ == ConfigValueContainer::_ColourValue) 373 373 return this->parseSting(input, this->value_colourvalue_); 374 374 … … 377 377 378 378 /** 379 @brief Parses a given std::string into a value of the type int and assigns it to the right variable. If the conversion failed, the default-value gets assigned.380 @param input The string to convert 381 @param defvalue The default-value 382 @return True if the string was successfully parsed 383 */ 384 bool ConfigValueContainer::parseSting(const std::string& input, int defvalue)379 @brief Parses a given String into a value of the type int and assigns it to the right variable. If the conversion failed, the default-value gets assigned. 380 @param input The string to convert 381 @param defvalue The default-value 382 @return True if the string was successfully parsed 383 */ 384 bool ConfigValueContainer::parseSting(const String& input, int defvalue) 385 385 { 386 386 return string2Number(this->value_.value_int_, input, defvalue); … … 388 388 389 389 /** 390 @brief Parses a given std::string into a value of the type unsigned int and assigns it to the right variable. If the conversion failed, the default-value gets assigned.391 @param input The string to convert 392 @param defvalue The default-value 393 @return True if the string was successfully parsed 394 */ 395 bool ConfigValueContainer::parseSting(const std::string& input, unsigned int defvalue)390 @brief Parses a given String into a value of the type unsigned int and assigns it to the right variable. If the conversion failed, the default-value gets assigned. 391 @param input The string to convert 392 @param defvalue The default-value 393 @return True if the string was successfully parsed 394 */ 395 bool ConfigValueContainer::parseSting(const String& input, unsigned int defvalue) 396 396 { 397 397 return string2Number(this->value_.value_uint_, input, defvalue); … … 399 399 400 400 /** 401 @brief Parses a given std::string into a value of the type char and assigns it to the right variable. If the conversion failed, the default-value gets assigned.402 @param input The string to convert 403 @param defvalue The default-value 404 @return True if the string was successfully parsed 405 */ 406 bool ConfigValueContainer::parseSting(const std::string& input, char defvalue)401 @brief Parses a given String into a value of the type char and assigns it to the right variable. If the conversion failed, the default-value gets assigned. 402 @param input The string to convert 403 @param defvalue The default-value 404 @return True if the string was successfully parsed 405 */ 406 bool ConfigValueContainer::parseSting(const String& input, char defvalue) 407 407 { 408 408 // I used value_int_ instead of value_char_ to avoid number <-> char confusion in the config-file … … 411 411 412 412 /** 413 @brief Parses a given std::string into a value of the type unsigned char and assigns it to the right variable. If the conversion failed, the default-value gets assigned.414 @param input The string to convert 415 @param defvalue The default-value 416 @return True if the string was successfully parsed 417 */ 418 bool ConfigValueContainer::parseSting(const std::string& input, unsigned char defvalue)413 @brief Parses a given String into a value of the type unsigned char and assigns it to the right variable. If the conversion failed, the default-value gets assigned. 414 @param input The string to convert 415 @param defvalue The default-value 416 @return True if the string was successfully parsed 417 */ 418 bool ConfigValueContainer::parseSting(const String& input, unsigned char defvalue) 419 419 { 420 420 // I used value_uint_ instead of value_uchar_ to avoid number <-> char confusion in the config-file … … 423 423 424 424 /** 425 @brief Parses a given std::string into a value of the type float and assigns it to the right variable. If the conversion failed, the default-value gets assigned.426 @param input The string to convert 427 @param defvalue The default-value 428 @return True if the string was successfully parsed 429 */ 430 bool ConfigValueContainer::parseSting(const std::string& input, float defvalue)425 @brief Parses a given String into a value of the type float and assigns it to the right variable. If the conversion failed, the default-value gets assigned. 426 @param input The string to convert 427 @param defvalue The default-value 428 @return True if the string was successfully parsed 429 */ 430 bool ConfigValueContainer::parseSting(const String& input, float defvalue) 431 431 { 432 432 return string2Number(this->value_.value_float_, input, defvalue); … … 434 434 435 435 /** 436 @brief Parses a given std::string into a value of the type double and assigns it to the right variable. If the conversion failed, the default-value gets assigned.437 @param input The string to convert 438 @param defvalue The default-value 439 @return True if the string was successfully parsed 440 */ 441 bool ConfigValueContainer::parseSting(const std::string& input, double defvalue)436 @brief Parses a given String into a value of the type double and assigns it to the right variable. If the conversion failed, the default-value gets assigned. 437 @param input The string to convert 438 @param defvalue The default-value 439 @return True if the string was successfully parsed 440 */ 441 bool ConfigValueContainer::parseSting(const String& input, double defvalue) 442 442 { 443 443 return string2Number(this->value_.value_double_, input, defvalue); … … 445 445 446 446 /** 447 @brief Parses a given std::string into a value of the type long double and assigns it to the right variable. If the conversion failed, the default-value gets assigned.448 @param input The string to convert 449 @param defvalue The default-value 450 @return True if the string was successfully parsed 451 */ 452 bool ConfigValueContainer::parseSting(const std::string& input, long double defvalue)447 @brief Parses a given String into a value of the type long double and assigns it to the right variable. If the conversion failed, the default-value gets assigned. 448 @param input The string to convert 449 @param defvalue The default-value 450 @return True if the string was successfully parsed 451 */ 452 bool ConfigValueContainer::parseSting(const String& input, long double defvalue) 453 453 { 454 454 return string2Number(this->value_.value_long_double_, input, defvalue); … … 456 456 457 457 /** 458 @brief Parses a given std::string into a value of the type bool and assigns it to the right variable. If the conversion failed, the default-value gets assigned.459 @param input The string to convert 460 @param defvalue The default-value 461 @return True if the string was successfully parsed 462 */ 463 bool ConfigValueContainer::parseSting(const std::string& input, bool defvalue)458 @brief Parses a given String into a value of the type bool and assigns it to the right variable. If the conversion failed, the default-value gets assigned. 459 @param input The string to convert 460 @param defvalue The default-value 461 @return True if the string was successfully parsed 462 */ 463 bool ConfigValueContainer::parseSting(const String& input, bool defvalue) 464 464 { 465 465 // Try to parse the value-string - is it a word? … … 484 484 485 485 /** 486 @brief Parses a given std::string into a value of the type std::string and assigns it to the right variable. If the conversion failed, the default-value gets assigned.487 @param input The string to convert 488 @param defvalue The default-value 489 @return True if the string was successfully parsed 490 */ 491 bool ConfigValueContainer::parseSting(const std::string& input, const std::string& defvalue)486 @brief Parses a given String into a value of the type String and assigns it to the right variable. If the conversion failed, the default-value gets assigned. 487 @param input The string to convert 488 @param defvalue The default-value 489 @return True if the string was successfully parsed 490 */ 491 bool ConfigValueContainer::parseSting(const String& input, const String& defvalue) 492 492 { 493 493 // Strip the quotes … … 509 509 510 510 /** 511 @brief Parses a given std::string into a value of the type const char* and assigns it to the right variable. If the conversion failed, the default-value gets assigned.512 @param input The string to convert 513 @param defvalue The default-value 514 @return True if the string was successfully parsed 515 */ 516 bool ConfigValueContainer::parseSting(const std::string& input, const char* defvalue)511 @brief Parses a given String into a value of the type const char* and assigns it to the right variable. If the conversion failed, the default-value gets assigned. 512 @param input The string to convert 513 @param defvalue The default-value 514 @return True if the string was successfully parsed 515 */ 516 bool ConfigValueContainer::parseSting(const String& input, const char* defvalue) 517 517 { 518 518 // Strip the quotes … … 534 534 535 535 /** 536 @brief Parses a given std::string into a value of the type Ogre::Vector2 and assigns it to the right variable. If the conversion failed, the default-value gets assigned.537 @param input The string to convert 538 @param defvalue The default-value 539 @return True if the string was successfully parsed 540 */ 541 bool ConfigValueContainer::parseSting(const std::string& input, const Ogre::Vector2& defvalue)536 @brief Parses a given String into a value of the type _Vector2 and assigns it to the right variable. If the conversion failed, the default-value gets assigned. 537 @param input The string to convert 538 @param defvalue The default-value 539 @return True if the string was successfully parsed 540 */ 541 bool ConfigValueContainer::parseSting(const String& input, const Vector2& defvalue) 542 542 { 543 543 // Strip the value-string … … 548 548 if (pos1 < input.length() && pos2 < input.length() && pos1 < pos2) 549 549 { 550 std::vector< std::string> tokens = tokenize(input.substr(pos1, pos2 - pos1), ",");550 std::vector<String> tokens = tokenize(input.substr(pos1, pos2 - pos1), ","); 551 551 if (!string2Number(this->value_vector2_.x, tokens[0], defvalue.x)) 552 552 { … … 568 568 569 569 /** 570 @brief Parses a given std::string into a value of the type Ogre::Vector3 and assigns it to the right variable. If the conversion failed, the default-value gets assigned.571 @param input The string to convert 572 @param defvalue The default-value 573 @return True if the string was successfully parsed 574 */ 575 bool ConfigValueContainer::parseSting(const std::string& input, const Ogre::Vector3& defvalue)570 @brief Parses a given String into a value of the type Vector3 and assigns it to the right variable. If the conversion failed, the default-value gets assigned. 571 @param input The string to convert 572 @param defvalue The default-value 573 @return True if the string was successfully parsed 574 */ 575 bool ConfigValueContainer::parseSting(const String& input, const Vector3& defvalue) 576 576 { 577 577 // Strip the value-string … … 582 582 if (pos1 < input.length() && pos2 < input.length() && pos1 < pos2) 583 583 { 584 std::vector< std::string> tokens = tokenize(input.substr(pos1, pos2 - pos1), ",");584 std::vector<String> tokens = tokenize(input.substr(pos1, pos2 - pos1), ","); 585 585 if (!string2Number(this->value_vector3_.x, tokens[0], defvalue.x)) 586 586 { … … 607 607 608 608 /** 609 @brief Parses a given std::string into a value of the type Ogre::ColourValue and assigns it to the right variable. If the conversion failed, the default-value gets assigned.610 @param input The string to convert 611 @param defvalue The default-value 612 @return True if the string was successfully parsed 613 */ 614 bool ConfigValueContainer::parseSting(const std::string& input, const Ogre::ColourValue& defvalue)609 @brief Parses a given String into a value of the type ColourValue and assigns it to the right variable. If the conversion failed, the default-value gets assigned. 610 @param input The string to convert 611 @param defvalue The default-value 612 @return True if the string was successfully parsed 613 */ 614 bool ConfigValueContainer::parseSting(const String& input, const ColourValue& defvalue) 615 615 { 616 616 // Strip the value-string … … 621 621 if (pos1 < input.length() && pos2 < input.length() && pos1 < pos2) 622 622 { 623 std::vector< std::string> tokens = tokenize(input.substr(pos1, pos2 - pos1), ",");623 std::vector<String> tokens = tokenize(input.substr(pos1, pos2 - pos1), ","); 624 624 if (!string2Number(this->value_colourvalue_.r, tokens[0], defvalue.r)) 625 625 { … … 678 678 679 679 // The string of the section we're searching 680 std::string section = "";680 String section = ""; 681 681 section.append("["); 682 682 section.append(this->classname_); … … 685 685 // Iterate through all config-file-lines 686 686 bool success = false; 687 std::list< std::string>::iterator it1;687 std::list<String>::iterator it1; 688 688 for(it1 = ConfigValueContainer::getConfigFileLines().begin(); it1 != ConfigValueContainer::getConfigFileLines().end(); ++it1) 689 689 { … … 696 696 // We found the right section 697 697 bool bLineIsEmpty = false; 698 std::list< std::string>::iterator positionToPutNewLineAt;698 std::list<String>::iterator positionToPutNewLineAt; 699 699 700 700 // Iterate through all lines in the section 701 std::list< std::string>::iterator it2;701 std::list<String>::iterator it2; 702 702 for(it2 = ++it1; it2 != ConfigValueContainer::getConfigFileLines().end(); ++it2) 703 703 { … … 777 777 @return True = it's a comment 778 778 */ 779 bool ConfigValueContainer::isComment(const std::string& line)779 bool ConfigValueContainer::isComment(const String& line) 780 780 { 781 781 // Strip the line, whitespaces are disturbing 782 std::string teststring = getStrippedLine(line);782 String teststring = getStrippedLine(line); 783 783 784 784 // There are four possible comment-symbols: … … 798 798 @return True = it's empty 799 799 */ 800 bool ConfigValueContainer::isEmpty(const std::string& line)800 bool ConfigValueContainer::isEmpty(const String& line) 801 801 { 802 802 return getStrippedLine(line) == ""; … … 808 808 @return The stripped line 809 809 */ 810 std::string ConfigValueContainer::getStrippedLine(const std::string& line)811 { 812 std::string output = line;810 String ConfigValueContainer::getStrippedLine(const String& line) 811 { 812 String output = line; 813 813 unsigned int pos; 814 814 while ((pos = output.find(" ")) < output.length()) … … 825 825 @return The value-string 826 826 */ 827 std::string ConfigValueContainer::parseValueString(bool bStripped)828 { 829 std::string output;827 String ConfigValueContainer::parseValueString(bool bStripped) 828 { 829 String output; 830 830 if (bStripped) 831 831 output = this->getStrippedLine(*this->configFileLine_); … … 839 839 @returns a list, containing all entrys in the config-file. 840 840 */ 841 std::list< std::string>& ConfigValueContainer::getConfigFileLines()841 std::list<String>& ConfigValueContainer::getConfigFileLines() 842 842 { 843 843 // This is done to avoid problems while executing this code before main() 844 static std::list< std::string> configFileLinesStaticReference = std::list<std::string>();844 static std::list<String> configFileLinesStaticReference = std::list<String>(); 845 845 return configFileLinesStaticReference; 846 846 } … … 866 866 @param filename The name of the config-file 867 867 */ 868 void ConfigValueContainer::readConfigFile(const std::string& filename)868 void ConfigValueContainer::readConfigFile(const String& filename) 869 869 { 870 870 // This creates the file if it's not existing … … 913 913 @param filename The name of the config-file 914 914 */ 915 void ConfigValueContainer::writeConfigFile(const std::string& filename)915 void ConfigValueContainer::writeConfigFile(const String& filename) 916 916 { 917 917 // Make sure we stored the config-file in the list … … 930 930 931 931 // Iterate through the list an write the lines into the file 932 std::list< std::string>::iterator it;932 std::list<String>::iterator it; 933 933 for (it = ConfigValueContainer::getConfigFileLines().begin(); it != ConfigValueContainer::getConfigFileLines().end(); ++it) 934 934 { … … 943 943 @param description The description 944 944 */ 945 void ConfigValueContainer::description(const std::string& description)945 void ConfigValueContainer::description(const String& description) 946 946 { 947 947 if (!this->bAddedDescription_) 948 948 { 949 this->description_ = std::string("ConfigValueDescription::" + this->classname_ + "::" + this->varname_);949 this->description_ = String("ConfigValueDescription::" + this->classname_ + "::" + this->varname_); 950 950 Language::getLanguage().addEntry(description_, description); 951 951 this->bAddedDescription_ = true;
Note: See TracChangeset
for help on using the changeset viewer.