Changeset 7199 in orxonox.OLD for trunk/src/lib/util/multi_type.h
- Timestamp:
- Mar 8, 2006, 10:46:37 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/util/multi_type.h
r7197 r7199 1 1 /*! 2 2 * @file multi_type.h 3 * @brief Definition of ...3 * @brief Definition of a MultiType, that is able to hold one Value of many types. 4 4 */ 5 5 6 6 #ifndef _MULTI_TYPE_H 7 7 #define _MULTI_TYPE_H 8 9 #include <string> 8 10 9 11 // FORWARD DECLARATION … … 38 40 MultiType(char value); 39 41 MultiType(const char* value); 42 MultiType(const std::string& value); 40 43 MultiType(const MultiType& multiType); 41 44 virtual ~MultiType(); … … 47 50 MultiType& operator=(char value) { this->setChar(value); return *this; }; 48 51 MultiType& operator=(const char* value) { this->setString(value); return *this; }; 52 MultiType& operator=(const std::string& value) { this->setString(value); return *this; }; 49 53 50 54 bool operator==(const MultiType& mt) const; … … 53 57 bool operator==(float value) const { return (this->getFloat() == value); }; 54 58 bool operator==(char value) const { return (this->getChar() == value); }; 55 bool operator==(const char* value) const;59 bool operator==(const std::string& value) const { return (this->getString() == value); }; 56 60 bool operator==(MT_Type type) const { return (this->type == type); } 57 61 bool operator!=(MT_Type type) const { return (this->type != type); } … … 63 67 void setFloat(float value); 64 68 void setChar(char value); 65 void setString(const char*value);69 void setString(const std::string& value); 66 70 67 71 // for your convenience. … … 71 75 inline void setValue(char value) { this->setChar(value); }; 72 76 inline void setValue(const char* value) { this->setString(value); }; 77 inline void setValue(const std::string& value) { this->setString(value); }; 78 void setValueOf(const MultiType& mt); 73 79 74 80 /** @returns the Type of the Value stored in this MultiType */ … … 81 87 float getFloat() const; 82 88 char getChar() const; 83 const char* getString(); 89 const char* getCString(); 90 std::string getString() const; 84 91 85 92 void reset(); 86 93 87 void debug() ;94 void debug() const; 88 95 89 96 static const char* MultiTypeToString(MT_Type type); … … 101 108 float Float; 102 109 char Char; 103 char* String; 104 110 // std::string* String; 105 111 } value; 106 112 107 113 MT_Type type; 108 114 109 char*storedString;115 std::string storedString; 110 116 }; 111 117
Note: See TracChangeset
for help on using the changeset viewer.