Changeset 5539 in orxonox.OLD for trunk/src/lib
- Timestamp:
- Nov 11, 2005, 12:49:20 PM (19 years ago)
- Location:
- trunk/src/lib/util
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/util/multi_type.cc
r5538 r5539 17 17 18 18 #include "multi_type.h" 19 #include "stdincl.h" 19 #include <stddef.h> 20 #include <stdlib.h> 21 #include <string.h> 22 #include <stdio.h> 20 23 21 24 using namespace std; … … 37 40 38 41 39 MultiType::MultiType( floatvalue)42 MultiType::MultiType(double value) 40 43 { 41 44 this->init(); … … 87 90 else if (this->type & MT_FLOAT) return (this->value.Float == 0.0f)? false : true; 88 91 else if (this->type & MT_CHAR) return (this->value.Char == '\0')? false : true; 89 else if (this->type & MT_STRING) return (!strncmp(this->value.String, "true", 4) || !strncmp(this->value.String, "TRUE", 4) || !strncmp(this->value.String, "1", 1))? true : false; 92 else if (this->type & MT_STRING) return (!strncmp(this->value.String, "true", 4) || !strncmp(this->value.String, "TRUE", 4) || !strncmp(this->value.String, "1", 1))? true : false; //! @TODO make this better. 90 93 91 94 return false; … … 117 120 { 118 121 // default case: 119 if (this->type & MT_FLOAT) return this->value.Float;120 return this->value. Int;121 if (this->type & MT_BOOL) return (this->value.Bool )? 1.0f : 0.0f;122 if (this->type & MT_FLOAT) 123 return this->value.Float; 124 if (this->type & MT_BOOL) return (this->value.Bool == true)? 1.0f : 0.0f; 122 125 else if (this->type & MT_INT) return (float) this->value.Int; 123 126 else if (this->type & MT_CHAR) return (float) this->value.Char; … … 125 128 char* endPtr = NULL; 126 129 double result = strtod(this->value.String, &endPtr); 127 128 130 if ( endPtr >= this->value.String && endPtr < this->value.String + strlen(this->value.String)) 129 131 return 0.0f; -
trunk/src/lib/util/multi_type.h
r5537 r5539 32 32 MultiType(bool value); 33 33 MultiType(int value); 34 MultiType( floatvalue);34 MultiType(double value); 35 35 MultiType(char value); 36 36 MultiType(const char* value);
Note: See TracChangeset
for help on using the changeset viewer.