Changeset 5544 in orxonox.OLD for trunk/src/lib/util
- Timestamp:
- Nov 11, 2005, 3:39:27 PM (19 years ago)
- Location:
- trunk/src/lib/util
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/util/multi_type.cc
r5541 r5544 147 147 148 148 149 bool MultiType::getBool() 149 bool MultiType::getBool() const 150 150 { 151 151 // default case: … … 162 162 163 163 164 int MultiType::getInt() 164 int MultiType::getInt() const 165 165 { 166 166 // default case: … … 183 183 184 184 185 float MultiType::getFloat() 185 float MultiType::getFloat() const 186 186 { 187 187 // default case: … … 204 204 205 205 206 char MultiType::getChar() 206 char MultiType::getChar() const 207 207 { 208 208 // default case: … … 253 253 } 254 254 255 256 void MultiType::debug() 257 { 258 printf("MultiType of Type: %s is: BOOL: %d, INT: %d, FLOAT: %f, CHAR: %c, STRING %s\n", 259 MultiType::MultiTypeToString(this->type), 260 this->getBool(), 261 this->getInt(), 262 this->getFloat(), 263 this->getChar(), 264 this->getString() 265 ); 266 267 268 } 269 270 const char* MultiType::MultiTypeToString(MT_Type type) 271 { 272 switch (type) 273 { 274 default: 275 return "NONE"; 276 case MT_BOOL: 277 return "bool"; 278 case MT_INT: 279 return "int"; 280 case MT_FLOAT: 281 return "float"; 282 case MT_CHAR: 283 return "char"; 284 case MT_STRING: 285 return "string"; 286 } 287 } 288 289 MT_Type MultiType::StringToMultiType(const char* type) 290 { 291 if (!strncmp(type, "bool", 4)) 292 return MT_BOOL; 293 if (!strncmp(type, "int", 3)) 294 return MT_INT; 295 if (!strncmp(type, "float", 5)) 296 return MT_FLOAT; 297 if (!strncmp(type, "char", 4)) 298 return MT_CHAR; 299 if (!strncmp(type, "string", 6)) 300 return MT_STRING; 301 } -
trunk/src/lib/util/multi_type.h
r5541 r5544 58 58 inline MT_Type getType() const { return this->type; }; 59 59 60 bool getBool() ;61 int getInt() ;62 float getFloat() ;63 char getChar() ;60 bool getBool() const; 61 int getInt() const; 62 float getFloat() const; 63 char getChar() const; 64 64 const char* getString(); 65 65 66 67 void debug(); 68 69 static const char* MultiTypeToString(MT_Type type); 70 static MT_Type StringToMultiType(const char* type); 66 71 67 72 private: … … 69 74 union Type 70 75 { 71 bool Bool; 72 int Int; 73 float Float; 74 char Char; 75 char* String; 76 } value; 76 bool Bool; 77 int Int; 78 float Float; 79 char Char; 80 char* String; 77 81 78 char* storedString; 82 } value; 83 84 char* storedString; 79 85 }; 80 86
Note: See TracChangeset
for help on using the changeset viewer.