Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5544 in orxonox.OLD for trunk/src/lib/util/multi_type.cc


Ignore:
Timestamp:
Nov 11, 2005, 3:39:27 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: more elaborate MultiType

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/util/multi_type.cc

    r5541 r5544  
    147147
    148148
    149 bool MultiType::getBool()
     149bool MultiType::getBool() const
    150150{
    151151  // default case:
     
    162162
    163163
    164 int MultiType::getInt()
     164int MultiType::getInt() const
    165165{
    166166  // default case:
     
    183183
    184184
    185 float MultiType::getFloat()
     185float MultiType::getFloat() const
    186186{
    187187 // default case:
     
    204204
    205205
    206 char MultiType::getChar()
     206char MultiType::getChar() const
    207207{
    208208 // default case:
     
    253253}
    254254
     255
     256void 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
     270const 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
     289MT_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}
Note: See TracChangeset for help on using the changeset viewer.