Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4860 in orxonox.OLD for orxonox


Ignore:
Timestamp:
Jul 14, 2005, 1:04:21 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: made bool's loadable

Location:
orxonox/trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/graphics/render2D/element_2d.cc

    r4858 r4860  
    7878      .describe("the _relative_ position (away from alignment) this 2d-element shows");
    7979
    80 //  LoadParam<Element2D>(root, "visibility", this, &Element2D::setVisibility)
    81 //      .describe("if the Element is visible or not");
     80  LoadParam<Element2D>(root, "visibility", this, &Element2D::setVisibility)
     81      .describe("if the Element is visible or not");
    8282}
    8383
  • orxonox/trunk/src/util/loading/load_param.cc

    r4836 r4860  
    113113}
    114114
     115/**
     116 * checks if the input was a Bool
     117 * @param BOOL a String that holds a bool: must be one of those: 1,0,true,false,TRUE,FALSE
     118 * @param defaultValue a default value that is set, if BOOL is corrupt
     119 * @return returns the bool, if BOOL was correct otherwise defaultValue
     120 */
     121bool isBool(const char* BOOL, bool defaultValue)
     122{
     123  if(!strcmp(BOOL, "1") || !strcmp( BOOL,"true") || !strcmp(BOOL,"TRUE"))
     124    return true;
     125  else if (!strcmp(BOOL, "0") || !strcmp( BOOL,"false") || !strcmp(BOOL,"FALSE"))
     126    return false;
     127  else
     128    return defaultValue;
     129
     130}
    115131
    116132int isInt(const char* INT, int defaultValue)
  • orxonox/trunk/src/util/loading/load_param.h

    r4836 r4860  
    7070*/
    7171
     72#define l_BOOL_TYPE        bool                 //!< The type of an BOOL
     73#define l_BOOL_FUNC        isBool               //!< The function to call to parse BOOL
     74#define l_BOOL_NAME        "bool"               //!< The name of an BOOL
     75#define l_BOOL_DEFAULT     0                    //!< a default Value for an BOOL
     76
     77
    7278#define l_INT_TYPE         int                  //!< The type of an INT
    7379#define l_INT_FUNC         isInt                //!< The function to call to parse INT
    7480#define l_INT_NAME         "int"                //!< The name of an INT
    75 #define l_INT_DEFAULT      0                    //!< a default Value for an INT
     81#define l_INT_DEFAULT      true                 //!< a default Value for an INT
    7682
    7783#define l_LONG_TYPE        long                 //!< The type of a LONG
     
    255261*** HELPER FUNCTIONS ***
    256262***********************/
     263bool          isBool(const char* BOOL, bool defaultValue);
    257264int           isInt(const char* INT, int defaultValue);
    258265float         isFloat(const char* FLOAT, float defaultValue);
     
    353360  LoadParam4(l_STRING, l_STRING, l_STRING, l_STRING);
    354361
     362  //! makes functions with one bool loadeable
     363  LoadParam1(l_BOOL);
     364
    355365  //! makes functions with one int loadable
    356366  LoadParam1(l_INT);
Note: See TracChangeset for help on using the changeset viewer.