Changeset 2017 for code/branches/objecthierarchy/src
- Timestamp:
- Oct 26, 2008, 12:46:44 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy/src/util/Convert.h
r2016 r2017 139 139 << " to type " << typeid(ToType).name() << std::endl; 140 140 return false; 141 } 142 }; 143 144 // If all else fails, try a dynamic_cast for pointer types. 145 template <class FromType, class ToType> 146 struct ConverterFallback<FromType*, ToType*> 147 { 148 static bool convert(ToType** output, FromType* const input) 149 { 150 ToType* temp = dynamic_cast<ToType*>(input); 151 if (temp) 152 { 153 *output = temp; 154 return true; 155 } 156 else 157 return false; 141 158 } 142 159 }; … … 345 362 // That means you can call it exactly like static_cast<ToType>(fromTypeValue). 346 363 template<class ToType, class FromType> 347 inline ToType conversion_cast(const FromType& input)364 inline ToType omni_cast(const FromType& input) 348 365 { 349 366 ToType output; … … 354 371 // convert to string Shortcut 355 372 template <class FromType> 356 std::string convertToString(FromType value)373 inline std::string convertToString(FromType value) 357 374 { 358 375 return getConvertedValue<FromType, std::string>(value); … … 361 378 // convert from string Shortcut 362 379 template <class ToType> 363 ToType convertFromString(std::string str)380 inline ToType convertFromString(std::string str) 364 381 { 365 382 return getConvertedValue<std::string, ToType>(str);
Note: See TracChangeset
for help on using the changeset viewer.