Changeset 5538 in orxonox.OLD for trunk/src/lib/util
- Timestamp:
- Nov 11, 2005, 12:30:53 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/util/multi_type.cc
r5537 r5538 88 88 else if (this->type & MT_CHAR) return (this->value.Char == '\0')? false : true; 89 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; 90 91 return false; 90 92 } 91 93 … … 99 101 else if (this->type & MT_FLOAT) return (int) this->value.Float; 100 102 else if (this->type & MT_CHAR) return (int) this->value.Char; 101 else if (this->type & MT_STRING) return 1; //! @TODO 103 else if (this->type & MT_STRING) { 104 char* endPtr = NULL; 105 int result = strtol(this->value.String, &endPtr, 10); 106 if ( endPtr >= this->value.String && endPtr < this->value.String + strlen(this->value.String)) 107 return 0; 108 else 109 return result; 110 } 111 112 return 0; 102 113 } 103 114 … … 111 122 else if (this->type & MT_INT) return (float) this->value.Int; 112 123 else if (this->type & MT_CHAR) return (float) this->value.Char; 113 else if (this->type & MT_STRING) return 1; //! @TODO 124 else if (this->type & MT_STRING) { 125 char* endPtr = NULL; 126 double result = strtod(this->value.String, &endPtr); 127 128 if ( endPtr >= this->value.String && endPtr < this->value.String + strlen(this->value.String)) 129 return 0.0f; 130 else 131 return result; 132 } 133 134 return 0.0f; 114 135 } 115 136 … … 123 144 else if (this->type & MT_INT) return (int) this->value.Int; 124 145 else if (this->type & MT_FLOAT) return (char) this->value.Float; 125 else if (this->type & MT_STRING) return 1; //! @TODO 146 else if (this->type & MT_STRING) return *this->value.String; 147 148 return '\0'; 126 149 } 127 150 … … 131 154 if (this->type & MT_STRING) 132 155 return this->value.String; 133 /* else if (this->type & MT_BOOL) return (this->value.Bool)? 1 : 0; 134 else if (this->type & MT_INT) return 1; //! @TODO 135 else if (this->type & MT_FLOAT) return (int) this->value.Float; 136 else if (this->type & MT_CHAR) return (int) this->value.Char;*/ 156 else 157 { 158 if (this->type & MT_BOOL) return (this->value.Bool)? "true" : "false"; 159 else if (this->type & MT_CHAR) &this->value.Char; 160 161 char tmpString[128]; 162 if (this->storedString != NULL) 163 { 164 delete[] this->storedString; 165 this->storedString = NULL; 166 } 167 168 if (this->type & MT_INT) 169 { 170 sprintf(tmpString, "%d", this->value.Int); 171 this->storedString = new char[strlen (tmpString)+1]; 172 strcpy (this->storedString, tmpString); 173 return this->storedString; 174 } 175 if (this->type & MT_FLOAT) 176 { 177 sprintf(tmpString, "%f", this->value.Float); 178 this->storedString = new char[strlen (tmpString)+1]; 179 strcpy (this->storedString, tmpString); 180 return this->storedString; 181 } 182 } 183 184 return ""; 137 185 } 138 186
Note: See TracChangeset
for help on using the changeset viewer.