| 1 | #ifndef _ConfigValueContainer_H__ |
|---|
| 2 | #define _ConfigValueContainer_H__ |
|---|
| 3 | |
|---|
| 4 | #include <string> |
|---|
| 5 | #include <list> |
|---|
| 6 | #include "OgreVector3.h" |
|---|
| 7 | #include "OgreColourValue.h" |
|---|
| 8 | |
|---|
| 9 | namespace orxonox |
|---|
| 10 | { |
|---|
| 11 | class ConfigValueContainer |
|---|
| 12 | { |
|---|
| 13 | public: |
|---|
| 14 | ConfigValueContainer(const std::string& classname, const std::string& varname, int defvalue); |
|---|
| 15 | ConfigValueContainer(const std::string& classname, const std::string& varname, double defvalue); |
|---|
| 16 | ConfigValueContainer(const std::string& classname, const std::string& varname, bool defvalue); |
|---|
| 17 | ConfigValueContainer(const std::string& classname, const std::string& varname, const char* defvalue); |
|---|
| 18 | ConfigValueContainer(const std::string& classname, const std::string& varname, Ogre::Vector3 defvalue); |
|---|
| 19 | ConfigValueContainer(const std::string& classname, const std::string& varname, Ogre::ColourValue defvalue); |
|---|
| 20 | |
|---|
| 21 | void setDefaultValues(const std::string& classname, const std::string& varname); |
|---|
| 22 | void searchConfigFileLine(); |
|---|
| 23 | std::string getValueString(bool bStripped = true); |
|---|
| 24 | |
|---|
| 25 | static std::string getStrippedLine(const std::string& line); |
|---|
| 26 | static bool isEmpty(const std::string& line); |
|---|
| 27 | static bool isComment(const std::string& line); |
|---|
| 28 | static void readConfigFile(const std::string& filename); |
|---|
| 29 | static void writeConfigFile(const std::string& filename); |
|---|
| 30 | |
|---|
| 31 | inline int getValue(int value) { return this->value_int_; } |
|---|
| 32 | inline double getValue(double value) { return this->value_double_; } |
|---|
| 33 | inline bool getValue(bool value) { return this->value_bool_; } |
|---|
| 34 | inline std::string getValue(const std::string& value) { return this->value_string_; } |
|---|
| 35 | inline Ogre::Vector3 getValue(const Ogre::Vector3& value) { return this->value_vector3_; } |
|---|
| 36 | inline Ogre::ColourValue getValue(const Ogre::ColourValue& value) { return this->value_colourvalue_; } |
|---|
| 37 | |
|---|
| 38 | private: |
|---|
| 39 | std::string classname_; |
|---|
| 40 | std::string varname_; |
|---|
| 41 | std::string defvalue_; |
|---|
| 42 | |
|---|
| 43 | int value_int_; |
|---|
| 44 | double value_double_; |
|---|
| 45 | bool value_bool_; |
|---|
| 46 | std::string value_string_; |
|---|
| 47 | Ogre::Vector3 value_vector3_; |
|---|
| 48 | Ogre::ColourValue value_colourvalue_; |
|---|
| 49 | |
|---|
| 50 | std::list<std::string>::iterator configFileLine_; |
|---|
| 51 | static std::list<std::string>* configFileLines_s; |
|---|
| 52 | static bool readConfigFile_s; |
|---|
| 53 | }; |
|---|
| 54 | } |
|---|
| 55 | |
|---|
| 56 | #endif |
|---|