Changeset 4624 in orxonox.OLD for orxonox/trunk/src/util/loading
- Timestamp:
- Jun 13, 2005, 8:32:05 PM (19 years ago)
- Location:
- orxonox/trunk/src/util/loading
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/util/loading/load_param.cc
r4623 r4624 113 113 } 114 114 115 116 int isInt(const char* Int, int defaultValue) 117 { 118 char* endPtr = NULL; 119 int result = strtol(Int, &endPtr, 10); 120 121 if ( endPtr >= Int && endPtr < Int + strlen(Int)) 122 return defaultValue; 123 else 124 return result; 125 } 126 127 float isFloat(const char* Float, float defaultValue) 128 { 129 char* endPtr = NULL; 130 double result = strtod(Float, &endPtr); 131 132 if ( endPtr >= Float && endPtr < Float + strlen(Float)) 133 return defaultValue; 134 else 135 return result; 136 } 137 138 const char* isString(const char* string, const char* defaultValue) 139 { 140 if (string != NULL) 141 return string; 142 else 143 return defaultValue; 144 } 145 146 115 147 /** 116 148 \param descriptionText The text to set as a description for this Parameter -
orxonox/trunk/src/util/loading/load_param.h
r4623 r4624 51 51 52 52 #define l_INT_TYPE int //!< The type of an INT 53 #define l_INT_FUNC atoi//!< The function to call to parse INT53 #define l_INT_FUNC isInt //!< The function to call to parse INT 54 54 #define l_INT_NAME "int" //!< The name of an INT 55 55 #define l_INT_DEFAULT 0 //!< a default Value for an INT 56 56 57 57 #define l_LONG_TYPE long //!< The type of a LONG 58 #define l_LONG_FUNC atol//!< The function to parse a LONG58 #define l_LONG_FUNC isInt //!< The function to parse a LONG 59 59 #define l_LONG_NAME "long" //!< The name of a LONG 60 60 #define l_LONG_DEFAULT 0 //!< a default Value for a LONG … … 66 66 67 67 #define l_FLOAT_TYPE float //!< The type of a FLOAT 68 #define l_FLOAT_FUNC atof//!< The function to parse a FLOAT68 #define l_FLOAT_FUNC isFloat //!< The function to parse a FLOAT 69 69 #define l_FLOAT_NAME "float" //!< The name of a FLOAT 70 70 #define l_FLOAT_DEFAULT 0.0 //!< a default Value for a FLOAT 71 71 72 72 #define l_STRING_TYPE const char* //!< The type of a STRING 73 #define l_STRING_FUNC 73 #define l_STRING_FUNC isString //!< The function to parse a STRING 74 74 #define l_STRING_NAME "string" //!< The name of a STRING 75 75 #define l_STRING_DEFAULT "" //!< a default Value for an STRING … … 95 95 { \ 96 96 if (loadString != NULL && root != NULL) \ 97 (*pt2Object.*function)(type1##_FUNC(loadString )); \97 (*pt2Object.*function)(type1##_FUNC(loadString, default1)); \ 98 98 else \ 99 99 PRINTF(4)("Not loaded parameter %s of %s\n", paramName, pt2Object->getClassName()); \ … … 116 116 SubString subLoads(loadString); \ 117 117 if (subLoads.getCount() == 2) \ 118 (*pt2Object.*function)(type1##_FUNC(subLoads.getString(0) ), type2##_FUNC(subLoads.getString(1))); \118 (*pt2Object.*function)(type1##_FUNC(subLoads.getString(0), default1), type2##_FUNC(subLoads.getString(1), default2)); \ 119 119 else \ 120 120 PRINTF(2)("Not loaded Parameter %s of %s, because wrong count of arguments.\n -> Should have %d but have %d\n", \ … … 142 142 SubString subLoads(loadString); \ 143 143 if (subLoads.getCount() == 3) \ 144 (*pt2Object.*function)(type1##_FUNC(subLoads.getString(0) ), type2##_FUNC(subLoads.getString(1)), type3##_FUNC(subLoads.getString(2))); \144 (*pt2Object.*function)(type1##_FUNC(subLoads.getString(0), default1), type2##_FUNC(subLoads.getString(1), default2), type3##_FUNC(subLoads.getString(2), default3)); \ 145 145 else \ 146 146 PRINTF(2)("Not loaded Parameter %s of %s, because wrong count of arguments.\n -> Should have %d but have %d\n", \ … … 171 171 SubString subLoads(loadString); \ 172 172 if (subLoads.getCount() == 4) \ 173 (*pt2Object.*function)(type1##_FUNC(subLoads.getString(0) ), type2##_FUNC(subLoads.getString(1)), type3##_FUNC(subLoads.getString(2)), type4##_FUNC(subLoads.getString(3))); \173 (*pt2Object.*function)(type1##_FUNC(subLoads.getString(0), default1), type2##_FUNC(subLoads.getString(1), default2), type3##_FUNC(subLoads.getString(2), default3), type4##_FUNC(subLoads.getString(3), default4)); \ 174 174 else \ 175 175 PRINTF(2)("Not loaded Parameter %s of %s, because wrong count of arguments.\n -> Should have %d but have %d\n", \ … … 202 202 SubString subLoads(loadString); \ 203 203 if (subLoads.getCount() == 5) \ 204 (*pt2Object.*function)(type1##_FUNC(subLoads.getString(0) ), type2##_FUNC(subLoads.getString(1)), type3##_FUNC(subLoads.getString(2)), type4##_FUNC(subLoads.getString(3)), type5##_FUNC(subLoads.getString(4))); \204 (*pt2Object.*function)(type1##_FUNC(subLoads.getString(0), default1), type2##_FUNC(subLoads.getString(1), default2), type3##_FUNC(subLoads.getString(2), default3), type4##_FUNC(subLoads.getString(3), default4), type5##_FUNC(subLoads.getString(4), default5)); \ 205 205 else \ 206 206 PRINTF(2)("Not loaded Parameter %s of %s, because wrong count of arguments.\n -> Should have %d but have %d\n", \ … … 226 226 } 227 227 228 229 /*********************** 230 *** HELPER FUNCTIONS *** 231 ***********************/ 232 int isInt(const char* Int, int defaultValue); 233 float isFloat(const char* Float, float defaultValue); 234 const char* isString(const char* string, const char* defaultValue); 235 //TiXmlEmlemnt* isXmlElem(const) 236 237 238 /************************ 239 *** DESCRIPTION STUFF *** 240 ************************/ 228 241 //! A class that handles the description of loadable parameters 229 242 class LoadParamDescription … … 269 282 }; 270 283 284 285 /************************** 286 **** REAL DECLARATIONS **** 287 **************************/ 271 288 //! abstract Base class for a Loadable parameter 272 289 class BaseLoadParam : public BaseObject
Note: See TracChangeset
for help on using the changeset viewer.