[4744] | 1 | /* |
---|
[1853] | 2 | orxonox - the future of 3D-vertical-scrollers |
---|
| 3 | |
---|
| 4 | Copyright (C) 2004 orx |
---|
| 5 | |
---|
| 6 | This program is free software; you can redistribute it and/or modify |
---|
| 7 | it under the terms of the GNU General Public License as published by |
---|
| 8 | the Free Software Foundation; either version 2, or (at your option) |
---|
| 9 | any later version. |
---|
[1855] | 10 | |
---|
| 11 | ### File Specific: |
---|
[5643] | 12 | main-programmer: Benjamin Grauer |
---|
[1855] | 13 | co-programmer: ... |
---|
[1853] | 14 | */ |
---|
| 15 | |
---|
[3955] | 16 | //#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_ |
---|
[1853] | 17 | |
---|
[5536] | 18 | #include "multi_type.h" |
---|
[1853] | 19 | |
---|
[7199] | 20 | #include <sstream> |
---|
[5659] | 21 | |
---|
| 22 | #ifdef DEBUG |
---|
| 23 | #include "debug.h" |
---|
| 24 | #endif |
---|
| 25 | |
---|
[5545] | 26 | /** |
---|
[7199] | 27 | * @brief creates a multiType without any stored value at all. |
---|
[5545] | 28 | */ |
---|
[7197] | 29 | MultiType::MultiType(MT_Type type) |
---|
[5540] | 30 | { |
---|
[7197] | 31 | this->type = type; |
---|
[7200] | 32 | switch (this->type) |
---|
| 33 | { |
---|
[8035] | 34 | default: |
---|
[9730] | 35 | this->value.Float = 0.0f; |
---|
| 36 | break; |
---|
[8035] | 37 | case MT_BOOL: |
---|
[9730] | 38 | this->value.Bool = false; |
---|
| 39 | break; |
---|
[8035] | 40 | case MT_INT: |
---|
[9730] | 41 | this->value.Int = 0; |
---|
| 42 | break; |
---|
[8035] | 43 | case MT_FLOAT: |
---|
[9730] | 44 | this->value.Float = 0.0f; |
---|
| 45 | break; |
---|
[8035] | 46 | case MT_CHAR: |
---|
[9730] | 47 | this->value.Char = '\0'; |
---|
| 48 | break; |
---|
[8035] | 49 | case MT_STRING: |
---|
[9730] | 50 | this->storedString = ""; |
---|
| 51 | break; |
---|
[7200] | 52 | } |
---|
[5540] | 53 | } |
---|
[5545] | 54 | /** |
---|
[7199] | 55 | * @brief creates a multiType out of a boolean |
---|
[5545] | 56 | * @param value the Value of this MulitType |
---|
| 57 | */ |
---|
[5537] | 58 | MultiType::MultiType(bool value) |
---|
| 59 | { |
---|
[5540] | 60 | this->setBool(value); |
---|
[5537] | 61 | } |
---|
| 62 | |
---|
[5545] | 63 | /** |
---|
[7199] | 64 | * @brief creates a multiType out of an integer |
---|
[5545] | 65 | * @param value the Value of this MulitType |
---|
| 66 | */ |
---|
[5536] | 67 | MultiType::MultiType(int value) |
---|
| 68 | { |
---|
[5540] | 69 | this->setInt(value); |
---|
[5536] | 70 | } |
---|
[1856] | 71 | |
---|
[5545] | 72 | /** |
---|
[7199] | 73 | * @brief creates a multiType out of a float (double) |
---|
[5545] | 74 | * @param value the Value of this MulitType |
---|
| 75 | */ |
---|
[5539] | 76 | MultiType::MultiType(double value) |
---|
[3365] | 77 | { |
---|
[5540] | 78 | this->setFloat(value); |
---|
[5536] | 79 | } |
---|
[4320] | 80 | |
---|
[5545] | 81 | /** |
---|
[7199] | 82 | * @brief creates a multiType out of a char |
---|
[5545] | 83 | * @param value the Value of this MulitType |
---|
| 84 | */ |
---|
[5536] | 85 | MultiType::MultiType(char value) |
---|
| 86 | { |
---|
[5540] | 87 | this->setChar(value); |
---|
[3365] | 88 | } |
---|
[1853] | 89 | |
---|
[5545] | 90 | /** |
---|
[7199] | 91 | * @brief creates a multiType out of a String |
---|
| 92 | * @param value the Value of this MulitType |
---|
| 93 | */ |
---|
| 94 | MultiType::MultiType(const std::string& value) |
---|
| 95 | { |
---|
| 96 | this->setString(value); |
---|
| 97 | } |
---|
| 98 | |
---|
| 99 | /** |
---|
| 100 | * @brief constructs a new MultiType from another one (copy) |
---|
| 101 | */ |
---|
[5659] | 102 | MultiType::MultiType(const MultiType& multiType) |
---|
| 103 | { |
---|
| 104 | *this = multiType; |
---|
| 105 | } |
---|
| 106 | |
---|
[3245] | 107 | /** |
---|
[7199] | 108 | * @brief standard deconstructor |
---|
[3245] | 109 | */ |
---|
[5536] | 110 | MultiType::~MultiType () |
---|
[7199] | 111 | { } |
---|
[5537] | 112 | |
---|
[5540] | 113 | /** |
---|
[7199] | 114 | * @brief copy operator |
---|
[5540] | 115 | * @param mt: the entity to copy |
---|
[7199] | 116 | * @returns A Copy of itself. (strings inside are copied as well) |
---|
[5540] | 117 | */ |
---|
[5659] | 118 | MultiType& MultiType::operator= (const MultiType& mt) |
---|
| 119 | { |
---|
| 120 | this->type = mt.type; |
---|
| 121 | this->value = mt.value; |
---|
[7199] | 122 | this->storedString = mt.storedString; |
---|
| 123 | |
---|
[5659] | 124 | return *this; |
---|
| 125 | } |
---|
| 126 | |
---|
[5545] | 127 | /** |
---|
[6643] | 128 | * @brief checks if the two Multitypes match |
---|
| 129 | * @param mt MultiType to check against this one |
---|
| 130 | * @returns true on match. false otherwise |
---|
| 131 | * |
---|
| 132 | * Two MultiType match if and only if |
---|
| 133 | * 1. the internal Type is the same |
---|
| 134 | * 2. the stored values match |
---|
| 135 | */ |
---|
| 136 | bool MultiType::operator==(const MultiType& mt) const |
---|
| 137 | { |
---|
| 138 | if (this->type != mt.type) |
---|
| 139 | return false; |
---|
| 140 | |
---|
| 141 | switch (this->type) |
---|
| 142 | { |
---|
[8035] | 143 | case MT_NULL: |
---|
[9730] | 144 | return true; |
---|
[8035] | 145 | case MT_BOOL: |
---|
[9730] | 146 | return (this->value.Bool == mt.value.Bool); |
---|
[8035] | 147 | case MT_INT: |
---|
[9730] | 148 | return (this->value.Int == mt.value.Int); |
---|
[8035] | 149 | case MT_CHAR: |
---|
[9730] | 150 | return (this->value.Char == mt.value.Char); |
---|
[8035] | 151 | case MT_FLOAT: |
---|
[9730] | 152 | return (this->value.Float == mt.value.Float); |
---|
[8035] | 153 | case MT_STRING: |
---|
[9730] | 154 | return (this->storedString == mt.storedString); |
---|
[8316] | 155 | default: |
---|
[9730] | 156 | return false; |
---|
[6643] | 157 | } |
---|
| 158 | } |
---|
| 159 | |
---|
| 160 | |
---|
| 161 | /** |
---|
[7199] | 162 | * @brief sets the type of this MultiType and resets to the default value |
---|
[5643] | 163 | * @param type the new Type |
---|
| 164 | */ |
---|
[6645] | 165 | void MultiType::setType(MT_Type type) |
---|
[5540] | 166 | { |
---|
[7199] | 167 | if (this->type == type) |
---|
| 168 | return; |
---|
| 169 | |
---|
| 170 | switch (type) |
---|
| 171 | { |
---|
[8035] | 172 | case MT_BOOL: |
---|
[9730] | 173 | this->setBool(this->getBool()); |
---|
| 174 | break; |
---|
[8035] | 175 | case MT_INT: |
---|
[9730] | 176 | this->setInt(this->getInt()); |
---|
| 177 | break; |
---|
[8035] | 178 | case MT_FLOAT: |
---|
[9730] | 179 | this->setFloat(this->getFloat()); |
---|
| 180 | break; |
---|
[8035] | 181 | case MT_CHAR: |
---|
[9730] | 182 | this->setChar(this->getChar()); |
---|
| 183 | break; |
---|
[8035] | 184 | case MT_STRING: |
---|
[9730] | 185 | this->setString(this->getString()); |
---|
| 186 | break; |
---|
[8316] | 187 | default: |
---|
[9730] | 188 | this->type = type; |
---|
[7199] | 189 | } |
---|
[5540] | 190 | } |
---|
| 191 | |
---|
[5545] | 192 | /** |
---|
[7199] | 193 | * @brief sets the Value of mt without changing the type of this MultiType |
---|
| 194 | * @param mt: the MultiType to get the value from |
---|
| 195 | * |
---|
| 196 | * This is a pure Value copy. The current type will be preserved. |
---|
| 197 | * |
---|
| 198 | * @TODO speedup |
---|
| 199 | */ |
---|
| 200 | void MultiType::setValueOf(const MultiType& mt) |
---|
| 201 | { |
---|
| 202 | MT_Type prevType = this->type; |
---|
| 203 | |
---|
| 204 | *this = mt; |
---|
| 205 | this->setType(prevType); |
---|
| 206 | } |
---|
| 207 | |
---|
| 208 | |
---|
| 209 | /** |
---|
| 210 | * @brief sets a new Value to the MultiType |
---|
[5545] | 211 | * @param value the new Value as a bool |
---|
| 212 | */ |
---|
[5540] | 213 | void MultiType::setBool(bool value) |
---|
| 214 | { |
---|
| 215 | this->type = MT_BOOL; |
---|
| 216 | this->value.Bool = value; |
---|
| 217 | } |
---|
| 218 | |
---|
[5545] | 219 | /** |
---|
[7199] | 220 | * @brief sets a new Value to the MultiType |
---|
[5545] | 221 | * @param value the new Value as an int |
---|
| 222 | */ |
---|
[5540] | 223 | void MultiType::setInt(int value) |
---|
| 224 | { |
---|
| 225 | this->type = MT_INT; |
---|
| 226 | this->value.Int = value; |
---|
| 227 | } |
---|
| 228 | |
---|
[5545] | 229 | /** |
---|
[7199] | 230 | * @brief sets a new Value to the MultiType |
---|
[5545] | 231 | * @param value the new Value as a float |
---|
| 232 | */ |
---|
[5540] | 233 | void MultiType::setFloat(float value) |
---|
| 234 | { |
---|
| 235 | this->type = MT_FLOAT; |
---|
| 236 | this->value.Float = value; |
---|
| 237 | } |
---|
| 238 | |
---|
[5545] | 239 | /** |
---|
[7199] | 240 | * @brief sets a new Value to the MultiType |
---|
[5545] | 241 | * @param value the new Value as a char |
---|
| 242 | */ |
---|
[5540] | 243 | void MultiType::setChar(char value) |
---|
| 244 | { |
---|
| 245 | this->type = MT_CHAR; |
---|
| 246 | this->value.Char = value; |
---|
| 247 | } |
---|
| 248 | |
---|
[5545] | 249 | /** |
---|
[7199] | 250 | * @brief sets a new Value to the MultiType |
---|
[5545] | 251 | * @param value the new Value as a String |
---|
| 252 | */ |
---|
[7199] | 253 | void MultiType::setString(const std::string& value) |
---|
[5540] | 254 | { |
---|
| 255 | this->type = MT_STRING; |
---|
[7199] | 256 | this->storedString = value; |
---|
[5540] | 257 | } |
---|
| 258 | |
---|
[9730] | 259 | /** |
---|
| 260 | * @brief stores any value to the string. |
---|
| 261 | * @note this Value can be grabbed by using the getStoredString function. |
---|
| 262 | */ |
---|
| 263 | void MultiType::storeString() |
---|
| 264 | { |
---|
| 265 | if (!(this->type & MT_STRING)) |
---|
| 266 | this->storedString = this->getString(); |
---|
| 267 | } |
---|
[5540] | 268 | |
---|
[7199] | 269 | /************************** |
---|
| 270 | *** RETRIEVAL FUNCTIONS *** |
---|
| 271 | **************************/ |
---|
[5545] | 272 | /** |
---|
| 273 | * @returns the Value of this MultiType as a int |
---|
| 274 | */ |
---|
[5544] | 275 | bool MultiType::getBool() const |
---|
[5537] | 276 | { |
---|
| 277 | // default case: |
---|
| 278 | if (this->type & MT_BOOL) |
---|
| 279 | return this->value.Bool; |
---|
| 280 | // Special Cases: |
---|
| 281 | else if (this->type & MT_INT) return (this->value.Int == 0)? false : true; |
---|
| 282 | else if (this->type & MT_FLOAT) return (this->value.Float == 0.0f)? false : true; |
---|
| 283 | else if (this->type & MT_CHAR) return (this->value.Char == '\0')? false : true; |
---|
[7199] | 284 | else if (this->type & MT_STRING) return (this->storedString == "true" || |
---|
| 285 | this->storedString == "TRUE" || |
---|
| 286 | this->storedString != "0"); //! @TODO make this better... |
---|
[5538] | 287 | |
---|
| 288 | return false; |
---|
[5537] | 289 | } |
---|
| 290 | |
---|
[5545] | 291 | /** |
---|
| 292 | * @returns the Value of this MultiType as a int |
---|
| 293 | */ |
---|
[5544] | 294 | int MultiType::getInt() const |
---|
[5537] | 295 | { |
---|
| 296 | // default case: |
---|
| 297 | if (this->type & MT_INT) |
---|
| 298 | return this->value.Int; |
---|
| 299 | if (this->type & MT_BOOL) return (this->value.Bool)? 1 : 0; |
---|
| 300 | else if (this->type & MT_FLOAT) return (int) this->value.Float; |
---|
| 301 | else if (this->type & MT_CHAR) return (int) this->value.Char; |
---|
[7199] | 302 | else if (this->type & MT_STRING) |
---|
| 303 | { |
---|
[7284] | 304 | std::stringstream ssStream(this->storedString); |
---|
| 305 | int iReturn; |
---|
| 306 | ssStream >> iReturn; |
---|
| 307 | return iReturn; |
---|
[5538] | 308 | } |
---|
| 309 | return 0; |
---|
[5537] | 310 | } |
---|
| 311 | |
---|
[7199] | 312 | |
---|
[5545] | 313 | /** |
---|
| 314 | * @returns the Value of this MultiType as a float |
---|
| 315 | */ |
---|
[5544] | 316 | float MultiType::getFloat() const |
---|
[5537] | 317 | { |
---|
[7199] | 318 | // default case: |
---|
[5539] | 319 | if (this->type & MT_FLOAT) |
---|
| 320 | return this->value.Float; |
---|
| 321 | if (this->type & MT_BOOL) return (this->value.Bool == true)? 1.0f : 0.0f; |
---|
[5537] | 322 | else if (this->type & MT_INT) return (float) this->value.Int; |
---|
| 323 | else if (this->type & MT_CHAR) return (float) this->value.Char; |
---|
[7199] | 324 | else if (this->type & MT_STRING) |
---|
| 325 | { |
---|
[5538] | 326 | char* endPtr = NULL; |
---|
[7199] | 327 | double result = strtod(this->storedString.c_str(), &endPtr); |
---|
[7284] | 328 | if ( endPtr >= this->storedString.c_str() && endPtr < this->storedString.c_str() + this->storedString.size()) |
---|
[5538] | 329 | return 0.0f; |
---|
| 330 | else |
---|
| 331 | return result; |
---|
| 332 | } |
---|
| 333 | return 0.0f; |
---|
[5537] | 334 | } |
---|
| 335 | |
---|
| 336 | |
---|
[5545] | 337 | /** |
---|
| 338 | * @returns the Value of this MultiType as a char |
---|
| 339 | */ |
---|
[5544] | 340 | char MultiType::getChar() const |
---|
[5537] | 341 | { |
---|
[7199] | 342 | // default case: |
---|
[5537] | 343 | if (this->type & MT_INT) |
---|
| 344 | return this->value.Int; |
---|
| 345 | if (this->type & MT_BOOL) return (this->value.Bool)? 'y' : 'n'; |
---|
| 346 | else if (this->type & MT_INT) return (int) this->value.Int; |
---|
| 347 | else if (this->type & MT_FLOAT) return (char) this->value.Float; |
---|
[7199] | 348 | else if (this->type & MT_STRING) return this->storedString[0]; |
---|
[5538] | 349 | |
---|
| 350 | return '\0'; |
---|
[5537] | 351 | } |
---|
| 352 | |
---|
[7199] | 353 | |
---|
[5545] | 354 | /** |
---|
| 355 | * @returns the Value of this MultiType as a String |
---|
| 356 | */ |
---|
[7199] | 357 | std::string MultiType::getString() const |
---|
[5537] | 358 | { |
---|
[7199] | 359 | // default case: |
---|
[5537] | 360 | if (this->type & MT_STRING) |
---|
[7199] | 361 | return this->storedString; |
---|
[5538] | 362 | else |
---|
| 363 | { |
---|
| 364 | if (this->type & MT_BOOL) return (this->value.Bool)? "true" : "false"; |
---|
[7199] | 365 | |
---|
[5641] | 366 | else if (this->type & MT_INT) |
---|
| 367 | { |
---|
[7199] | 368 | char tmpString[32]; |
---|
[5538] | 369 | sprintf(tmpString, "%d", this->value.Int); |
---|
[7199] | 370 | return tmpString; |
---|
[5538] | 371 | } |
---|
[7199] | 372 | else if (this->type & MT_FLOAT) |
---|
[5538] | 373 | { |
---|
[7199] | 374 | char tmpString[64]; |
---|
[5538] | 375 | sprintf(tmpString, "%f", this->value.Float); |
---|
[7199] | 376 | return tmpString; |
---|
[5538] | 377 | } |
---|
[7200] | 378 | else if (this->type & MT_CHAR) |
---|
| 379 | { |
---|
| 380 | char tmpString[2]; |
---|
| 381 | tmpString[0] = this->value.Char; |
---|
| 382 | tmpString[1] = '\0'; |
---|
| 383 | return tmpString; |
---|
| 384 | } |
---|
[5538] | 385 | } |
---|
| 386 | return ""; |
---|
[5537] | 387 | } |
---|
| 388 | |
---|
[5545] | 389 | /** |
---|
[8035] | 390 | * @brief returns a Constant string (actually this is slower than getString() |
---|
| 391 | * @returns a constant string of the stored version's one. |
---|
[9730] | 392 | * @note this could lead to a inconsistency of data AND IS HIGHLY NON_THREAD_SAFE! |
---|
| 393 | * PLEASE THINK ABOUT USING THE getStoredString function in conjunction with storeString(). |
---|
[8035] | 394 | */ |
---|
| 395 | const std::string& MultiType::getConstString() const |
---|
| 396 | { |
---|
[9730] | 397 | MultiType::constString = this->getString(); |
---|
| 398 | return MultiType::constString; |
---|
| 399 | } |
---|
[8035] | 400 | |
---|
[9730] | 401 | /** |
---|
| 402 | * @brief returns the currently stored string. |
---|
| 403 | * @returns the Stored string. |
---|
| 404 | * @note Storing a string works as follows: \\ |
---|
| 405 | * MultiType a(3); // Creates a MultiType of Type int with value 3 \\ |
---|
| 406 | * a.storeString(); // Stores the String in the internal structure. \\ |
---|
| 407 | * std::string name = a.getStoredString(); |
---|
| 408 | * |
---|
| 409 | * This would be the same as |
---|
| 410 | * name = a.getString(); |
---|
| 411 | * but with much more const'ness. |
---|
| 412 | */ |
---|
| 413 | const std::string& MultiType::getStoredString() const |
---|
| 414 | { |
---|
[8035] | 415 | MultiType::constString = this->getString(); |
---|
| 416 | return MultiType::constString; |
---|
| 417 | } |
---|
| 418 | |
---|
| 419 | /** |
---|
[7199] | 420 | * @returns a formated c-string of the held value |
---|
[5545] | 421 | */ |
---|
[7199] | 422 | const char* MultiType::getCString() |
---|
[5544] | 423 | { |
---|
[7199] | 424 | if (this->type & MT_STRING) return this->storedString.c_str(); |
---|
| 425 | else |
---|
| 426 | { |
---|
| 427 | this->storedString = this->getString(); |
---|
| 428 | return this->storedString.c_str(); |
---|
| 429 | } |
---|
| 430 | } |
---|
| 431 | |
---|
| 432 | /** |
---|
| 433 | * @brief prints out some nice debug output |
---|
| 434 | */ |
---|
| 435 | void MultiType::debug() const |
---|
| 436 | { |
---|
[5659] | 437 | #ifdef DEBUG |
---|
| 438 | PRINT(0) |
---|
| 439 | #else |
---|
| 440 | printf |
---|
| 441 | #endif |
---|
[7199] | 442 | ("MultiType of Type '%s' :: Values: BOOL: '%d', INT: '%d', FLOAT: '%f', CHAR: '%c', STRING '%s'\n", |
---|
[7401] | 443 | MultiType::MultiTypeToString(this->type).c_str(), |
---|
[7199] | 444 | this->getBool(), |
---|
| 445 | this->getInt(), |
---|
| 446 | this->getFloat(), |
---|
| 447 | this->getChar(), |
---|
| 448 | this->getString().c_str() |
---|
| 449 | ); |
---|
| 450 | } |
---|
[5544] | 451 | |
---|
| 452 | |
---|
[5545] | 453 | /** |
---|
[7199] | 454 | * @brief Resets the MultiType to default values. |
---|
[5643] | 455 | */ |
---|
| 456 | void MultiType::reset() |
---|
| 457 | { |
---|
[5659] | 458 | switch ( this->type ) |
---|
[5643] | 459 | { |
---|
[8035] | 460 | case MT_BOOL: |
---|
[9730] | 461 | this->setBool(false); |
---|
| 462 | break; |
---|
[8035] | 463 | case MT_INT: |
---|
[9730] | 464 | this->setInt(0); |
---|
| 465 | break; |
---|
[8035] | 466 | case MT_FLOAT: |
---|
[9730] | 467 | this->setFloat(0.0f); |
---|
| 468 | break; |
---|
[8035] | 469 | case MT_CHAR: |
---|
[9730] | 470 | this->setChar('\0'); |
---|
| 471 | break; |
---|
[8035] | 472 | case MT_STRING: |
---|
[9730] | 473 | this->setString(""); |
---|
| 474 | break; |
---|
[8035] | 475 | default: |
---|
[5659] | 476 | #ifdef DEBUG |
---|
[9730] | 477 | PRINTF(2)("Unknown Type not reseting\n"); |
---|
[5659] | 478 | #endif |
---|
[9730] | 479 | break; |
---|
[5643] | 480 | } |
---|
| 481 | } |
---|
| 482 | |
---|
| 483 | /** |
---|
[7199] | 484 | * @brief converts a MT_Type into a String |
---|
[5545] | 485 | * @param type: the MT_Type |
---|
| 486 | * @returns: the Type as a constant String (do not delete) |
---|
| 487 | */ |
---|
[7401] | 488 | const std::string& MultiType::MultiTypeToString(MT_Type type) |
---|
[5544] | 489 | { |
---|
[5659] | 490 | switch ( type ) |
---|
[5544] | 491 | { |
---|
[8035] | 492 | case MT_BOOL: |
---|
[9730] | 493 | return MultiType::typeNames[1]; |
---|
[8035] | 494 | case MT_INT: |
---|
[9730] | 495 | return MultiType::typeNames[2]; |
---|
[8035] | 496 | case MT_FLOAT: |
---|
[9730] | 497 | return MultiType::typeNames[3]; |
---|
[8035] | 498 | case MT_CHAR: |
---|
[9730] | 499 | return MultiType::typeNames[4]; |
---|
[8035] | 500 | case MT_STRING: |
---|
[9730] | 501 | return MultiType::typeNames[5]; |
---|
[8316] | 502 | default: |
---|
[9730] | 503 | return MultiType::typeNames[0]; |
---|
[5544] | 504 | } |
---|
| 505 | } |
---|
| 506 | |
---|
[5545] | 507 | /** |
---|
[7199] | 508 | * @brief converts a String into a MT_Type |
---|
[5545] | 509 | * @param type: the Type as a String |
---|
| 510 | * @returns: the Type as MT_Type |
---|
| 511 | */ |
---|
[7221] | 512 | MT_Type MultiType::StringToMultiType(const std::string& type) |
---|
[5544] | 513 | { |
---|
[7401] | 514 | if (type == MultiType::typeNames[1]) |
---|
[5544] | 515 | return MT_BOOL; |
---|
[7401] | 516 | if (type == MultiType::typeNames[2]) |
---|
[5544] | 517 | return MT_INT; |
---|
[7401] | 518 | if (type == MultiType::typeNames[3]) |
---|
[5544] | 519 | return MT_FLOAT; |
---|
[7401] | 520 | if (type == MultiType::typeNames[4]) |
---|
[5544] | 521 | return MT_CHAR; |
---|
[7401] | 522 | if (type == MultiType::typeNames[5]) |
---|
[5544] | 523 | return MT_STRING; |
---|
[7200] | 524 | |
---|
| 525 | return MT_NULL; |
---|
[5544] | 526 | } |
---|
[7401] | 527 | |
---|
| 528 | |
---|
[8035] | 529 | std::string MultiType::constString = ""; |
---|
[7401] | 530 | const std::string MultiType::typeNames[] = |
---|
| 531 | { |
---|
| 532 | "NONE", //0 |
---|
| 533 | "bool", //1 |
---|
| 534 | "int", //2 |
---|
| 535 | "float", //3 |
---|
| 536 | "char", //4 |
---|
| 537 | "string" //5 |
---|
| 538 | }; |
---|