- Timestamp:
- Dec 28, 2007, 10:30:29 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/FICN/src/orxonox/core/ConfigValueContainer.h
r705 r708 43 43 #define _ConfigValueContainer_H__ 44 44 45 #include <string>46 45 #include <list> 47 46 48 47 #include "CorePrereqs.h" 49 48 50 #include "OgreVector2.h" 51 #include "OgreVector3.h" 52 #include "OgreColourValue.h" 49 #include "misc/Vector2.h" 50 #include "misc/Vector3.h" 51 #include "misc/Matrix3.h" 52 #include "misc/Quaternion.h" 53 #include "misc/String.h" 54 #include "misc/ColourValue.h" 53 55 #include "Language.h" 54 56 … … 85 87 Bool, 86 88 ConstChar, 87 String,88 Vector2,89 Vector3,90 ColourValue89 _String, 90 _Vector2, 91 _Vector3, 92 _ColourValue 91 93 }; 92 94 93 ConfigValueContainer(const std::string& classname, const std::string& varname, int defvalue);94 ConfigValueContainer(const std::string& classname, const std::string& varname, unsigned int defvalue);95 ConfigValueContainer(const std::string& classname, const std::string& varname, char defvalue);96 ConfigValueContainer(const std::string& classname, const std::string& varname, unsigned char defvalue);97 ConfigValueContainer(const std::string& classname, const std::string& varname, float defvalue);98 ConfigValueContainer(const std::string& classname, const std::string& varname, double defvalue);99 ConfigValueContainer(const std::string& classname, const std::string& varname, long double defvalue);100 ConfigValueContainer(const std::string& classname, const std::string& varname, bool defvalue);101 ConfigValueContainer(const std::string& classname, const std::string& varname, const std::string& defvalue);102 ConfigValueContainer(const std::string& classname, const std::string& varname, const char* defvalue);103 ConfigValueContainer(const std::string& classname, const std::string& varname, Ogre::Vector2 defvalue);104 ConfigValueContainer(const std::string& classname, const std::string& varname, Ogre::Vector3 defvalue);105 ConfigValueContainer(const std::string& classname, const std::string& varname, Ogre::ColourValue defvalue);95 ConfigValueContainer(const String& classname, const String& varname, int defvalue); 96 ConfigValueContainer(const String& classname, const String& varname, unsigned int defvalue); 97 ConfigValueContainer(const String& classname, const String& varname, char defvalue); 98 ConfigValueContainer(const String& classname, const String& varname, unsigned char defvalue); 99 ConfigValueContainer(const String& classname, const String& varname, float defvalue); 100 ConfigValueContainer(const String& classname, const String& varname, double defvalue); 101 ConfigValueContainer(const String& classname, const String& varname, long double defvalue); 102 ConfigValueContainer(const String& classname, const String& varname, bool defvalue); 103 ConfigValueContainer(const String& classname, const String& varname, const String& defvalue); 104 ConfigValueContainer(const String& classname, const String& varname, const char* defvalue); 105 ConfigValueContainer(const String& classname, const String& varname, Vector2 defvalue); 106 ConfigValueContainer(const String& classname, const String& varname, Vector3 defvalue); 107 ConfigValueContainer(const String& classname, const String& varname, ColourValue defvalue); 106 108 107 109 /** @returns the value. @param value This is only needed to determine the right type. */ … … 122 124 inline ConfigValueContainer& getValue(bool& value) { value = this->value_.value_bool_; return *this; } 123 125 /** @returns the value. @param value This is only needed to determine the right type. */ 124 inline ConfigValueContainer& getValue( std::string& value) { value = this->value_string_; return *this; }126 inline ConfigValueContainer& getValue(String& value) { value = this->value_string_; return *this; } 125 127 /** @returns the value. @param value This is only needed to determine the right type. */ 126 128 inline ConfigValueContainer& getValue(const char* value) { value = this->value_string_.c_str(); return *this; } 127 129 /** @returns the value. @param value This is only needed to determine the right type. */ 128 inline ConfigValueContainer& getValue( Ogre::Vector2& value) { value = this->value_vector2_; return *this; }130 inline ConfigValueContainer& getValue(Vector2& value) { value = this->value_vector2_; return *this; } 129 131 /** @returns the value. @param value This is only needed to determine the right type. */ 130 inline ConfigValueContainer& getValue( Ogre::Vector3& value) { value = this->value_vector3_; return *this; }132 inline ConfigValueContainer& getValue(Vector3& value) { value = this->value_vector3_; return *this; } 131 133 /** @returns the value. @param value This is only needed to determine the right type. */ 132 inline ConfigValueContainer& getValue( Ogre::ColourValue& value) { value = this->value_colourvalue_; return *this; }134 inline ConfigValueContainer& getValue(ColourValue& value) { value = this->value_colourvalue_; return *this; } 133 135 134 void description(const std::string& description);136 void description(const String& description); 135 137 136 bool parseSting(const std::string& input);138 bool parseSting(const String& input); 137 139 void resetConfigFileEntry(); 138 140 void resetConfigValue(); 139 141 140 static std::string getStrippedLine(const std::string& line);141 static bool isEmpty(const std::string& line);142 static bool isComment(const std::string& line);142 static String getStrippedLine(const String& line); 143 static bool isEmpty(const String& line); 144 static bool isComment(const String& line); 143 145 144 146 private: 145 bool parseSting(const std::string& input, int defvalue);146 bool parseSting(const std::string& input, unsigned int defvalue);147 bool parseSting(const std::string& input, char defvalue);148 bool parseSting(const std::string& input, unsigned char defvalue);149 bool parseSting(const std::string& input, float defvalue);150 bool parseSting(const std::string& input, double defvalue);151 bool parseSting(const std::string& input, long double defvalue);152 bool parseSting(const std::string& input, bool defvalue);153 bool parseSting(const std::string& input, const std::string& defvalue);154 bool parseSting(const std::string& input, const char* defvalue);155 bool parseSting(const std::string& input, const Ogre::Vector2& defvalue);156 bool parseSting(const std::string& input, const Ogre::Vector3& defvalue);157 bool parseSting(const std::string& input, const Ogre::ColourValue& defvalue);147 bool parseSting(const String& input, int defvalue); 148 bool parseSting(const String& input, unsigned int defvalue); 149 bool parseSting(const String& input, char defvalue); 150 bool parseSting(const String& input, unsigned char defvalue); 151 bool parseSting(const String& input, float defvalue); 152 bool parseSting(const String& input, double defvalue); 153 bool parseSting(const String& input, long double defvalue); 154 bool parseSting(const String& input, bool defvalue); 155 bool parseSting(const String& input, const String& defvalue); 156 bool parseSting(const String& input, const char* defvalue); 157 bool parseSting(const String& input, const Vector2& defvalue); 158 bool parseSting(const String& input, const Vector3& defvalue); 159 bool parseSting(const String& input, const ColourValue& defvalue); 158 160 159 static std::list< std::string>& getConfigFileLines();161 static std::list<String>& getConfigFileLines(); 160 162 static bool finishedReadingConfigFile(bool finished = false); 161 163 void searchConfigFileLine(); 162 std::string parseValueString(bool bStripped = true);164 String parseValueString(bool bStripped = true); 163 165 164 static void readConfigFile(const std::string& filename);165 static void writeConfigFile(const std::string& filename);166 static void readConfigFile(const String& filename); 167 static void writeConfigFile(const String& filename); 166 168 167 std::string classname_; //!< The name of the class the variable belongs to168 std::string varname_; //!< The name of the variable169 std::string defvalueString_; //!< The string of the default-variable169 String classname_; //!< The name of the class the variable belongs to 170 String varname_; //!< The name of the variable 171 String defvalueString_; //!< The string of the default-variable 170 172 171 173 union MultiType … … 181 183 } value_; //!< The value of the variable 182 184 183 std::string value_string_; //!< The value, if the variable is of the type string184 Ogre::Vector2 value_vector2_; //!< The value, if the variable is of the type Vector2185 Ogre::Vector3 value_vector3_; //!< The value, if the variable is of the type Vector3186 Ogre::ColourValue value_colourvalue_; //!< The value, if the variable is of the type ColourValue185 String value_string_; //!< The value, if the variable is of the type string 186 Vector2 value_vector2_; //!< The value, if the variable is of the type Vector2 187 Vector3 value_vector3_; //!< The value, if the variable is of the type Vector3 188 ColourValue value_colourvalue_; //!< The value, if the variable is of the type ColourValue 187 189 188 std::list< std::string>::iterator configFileLine_; //!< An iterator, pointing to the entry of the variable in the config-file190 std::list<String>::iterator configFileLine_; //!< An iterator, pointing to the entry of the variable in the config-file 189 191 190 192 VariableType type_; //!< The type of the variable
Note: See TracChangeset
for help on using the changeset viewer.