- Timestamp:
- Dec 10, 2007, 3:55:33 AM (17 years ago)
- Location:
- code/branches/objecthierarchy/src/orxonox/core
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy/src/orxonox/core/ConfigValueContainer.cc
r450 r451 12 12 13 13 /** 14 @brief Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets this->value_ int_.14 @brief Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets this->value_.value_int_. 15 15 @param classname The name of the class the variable belongs to 16 16 @param varname The name of the variable … … 32 32 // Try to convert the value-string to int 33 33 std::istringstream istream(valueString); 34 if (!(istream >> this->value_ int_))34 if (!(istream >> this->value_.value_int_)) 35 35 { 36 36 // The conversion failed - use the default value and restore the entry in the config-file 37 this->value_ int_ = defvalue;37 this->value_.value_int_ = defvalue; 38 38 (*this->configFileLine_) = this->varname_ + "=" + this->defvalue_; 39 39 ConfigValueContainer::writeConfigFile(CONFIGFILEPATH); … … 42 42 43 43 /** 44 @brief Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets this->value_ double_.44 @brief Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets this->value_.value_double_. 45 45 @param classname The name of the class the variable belongs to 46 46 @param varname The name of the variable … … 62 62 // Try to convert the value-string to double 63 63 std::istringstream istream(valueString); 64 if (!(istream >> this->value_ double_))64 if (!(istream >> this->value_.value_double_)) 65 65 { 66 66 // The conversion failed - use the default value and restore the entry in the config-file 67 this->value_ double_ = defvalue;67 this->value_.value_double_ = defvalue; 68 68 (*this->configFileLine_) = this->varname_ + "=" + this->defvalue_; 69 69 ConfigValueContainer::writeConfigFile(CONFIGFILEPATH); … … 72 72 73 73 /** 74 @brief Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets this->value_ bool_.74 @brief Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets this->value_.value_bool_. 75 75 @param classname The name of the class the variable belongs to 76 76 @param varname The name of the variable … … 91 91 // Try to parse the value-string - is it a word? 92 92 if (valueString.find("true") < valueString.size() || valueString.find("yes") < valueString.size()) 93 this->value_ bool_ = true;93 this->value_.value_bool_ = true; 94 94 else if (valueString.find("false") < valueString.size() || valueString.find("no") < valueString.size()) 95 this->value_ bool_ = false;95 this->value_.value_bool_ = false; 96 96 else 97 97 { 98 98 // Its not a known word - is it a number? 99 99 std::istringstream istream(valueString); 100 if (!(istream >> this->value_ bool_))101 { 102 // The conversion failed - use the default value and restore the entry in the config-file 103 this->value_ bool_ = defvalue;100 if (!(istream >> this->value_.value_bool_)) 101 { 102 // The conversion failed - use the default value and restore the entry in the config-file 103 this->value_.value_bool_ = defvalue; 104 104 (*this->configFileLine_) = this->varname_ + "=" + this->defvalue_; 105 105 ConfigValueContainer::writeConfigFile(CONFIGFILEPATH); … … 404 404 405 405 // Set the values of all types to zero 406 this->value_ int_ = 0;407 this->value_ double_ = 0.000000;408 this->value_ bool_ = false;406 this->value_.value_int_ = 0; 407 this->value_.value_double_ = 0.000000; 408 this->value_.value_bool_ = false; 409 409 this->value_string_ = ""; 410 410 this->value_vector2_ = Ogre::Vector2(0, 0); -
code/branches/objecthierarchy/src/orxonox/core/ConfigValueContainer.h
r450 r451 63 63 64 64 /** @returns the value of the type int. @param value This is only needed to determine the right type. */ 65 inline int getValue(int value) { return this->value_ int_; }65 inline int getValue(int value) { return this->value_.value_int_; } 66 66 /** @returns the value of the type double. @param value This is only needed to determine the right type. */ 67 inline double getValue(double value) { return this->value_ double_; }67 inline double getValue(double value) { return this->value_.value_double_; } 68 68 /** @returns the value of the type bool. @param value This is only needed to determine the right type. */ 69 inline bool getValue(bool value) { return this->value_ bool_; }69 inline bool getValue(bool value) { return this->value_.value_bool_; } 70 70 /** @returns the value of the type std::string. @param value This is only needed to determine the right type. */ 71 71 inline std::string getValue(const std::string& value) { return this->value_string_; } … … 82 82 std::string defvalue_; //!< The string of the default-variable 83 83 84 int value_int_; //!< The value, if the variable is of the type int 85 double value_double_; //!< The value, if the variable is of the type double 86 bool value_bool_; //!< The value, if the variable is of the type bool 84 union MultiType 85 { 86 int value_int_; //!< The value, if the variable is of the type int 87 double value_double_; //!< The value, if the variable is of the type double 88 bool value_bool_; //!< The value, if the variable is of the type bool 89 } value_; 90 87 91 std::string value_string_; //!< The value, if the variable is of the type string 88 92 Ogre::Vector2 value_vector2_; //!< The value, if the variable is of the type Vector2
Note: See TracChangeset
for help on using the changeset viewer.