Changeset 3145 for code/branches/pch/src/util
- Timestamp:
- Jun 11, 2009, 6:22:15 PM (16 years ago)
- Location:
- code/branches/pch/src/util
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/pch/src/util/Convert.h
r3125 r3145 139 139 struct ConverterFallback 140 140 { 141 static bool convert(ToType* output, const FromType& input)141 FORCEINLINE static bool convert(ToType* output, const FromType& input) 142 142 { 143 143 COUT(2) << "Could not convert value of type " << typeid(FromType).name() … … 151 151 struct ConverterFallback<FromType*, ToType*> 152 152 { 153 static bool convert(ToType** output, FromType* const input)153 FORCEINLINE static bool convert(ToType** output, FromType* const input) 154 154 { 155 155 ToType* temp = dynamic_cast<ToType*>(input); … … 174 174 struct ConverterStringStream 175 175 { 176 static bool convert(ToType* output, const FromType& input)176 FORCEINLINE static bool convert(ToType* output, const FromType& input) 177 177 { 178 178 return orxonox::ConverterFallback<FromType, ToType>::convert(output, input); … … 188 188 { 189 189 template <class FromType> 190 inlinebool operator <<(std::ostream& outstream, const FromType& input)190 FORCEINLINE bool operator <<(std::ostream& outstream, const FromType& input) 191 191 { 192 192 std::string temp; … … 205 205 struct ConverterStringStream<FromType, std::string> 206 206 { 207 static bool convert(std::string* output, const FromType& input)207 FORCEINLINE static bool convert(std::string* output, const FromType& input) 208 208 { 209 209 using namespace fallbackTemplates; … … 228 228 { 229 229 template <class ToType> 230 inlinebool operator >>(std::istream& instream, ToType& output)230 FORCEINLINE bool operator >>(std::istream& instream, ToType& output) 231 231 { 232 232 return orxonox::ConverterFallback<std::string, ToType> … … 239 239 struct ConverterStringStream<std::string, ToType> 240 240 { 241 static bool convert(ToType* output, const std::string& input)241 FORCEINLINE static bool convert(ToType* output, const std::string& input) 242 242 { 243 243 using namespace fallbackTemplates; … … 262 262 // implicit cast not possible, try stringstream conversion next 263 263 template <class FromType, class ToType> 264 inlinebool convertImplicitely(ToType* output, const FromType& input, orxonox::Int2Type<false>)264 FORCEINLINE bool convertImplicitely(ToType* output, const FromType& input, orxonox::Int2Type<false>) 265 265 { 266 266 return ConverterStringStream<FromType, ToType>::convert(output, input); … … 269 269 // We can cast implicitely 270 270 template <class FromType, class ToType> 271 inlinebool convertImplicitely(ToType* output, const FromType& input, orxonox::Int2Type<true>)271 FORCEINLINE bool convertImplicitely(ToType* output, const FromType& input, orxonox::Int2Type<true>) 272 272 { 273 273 (*output) = static_cast<ToType>(input); … … 284 284 struct ConverterExplicit 285 285 { 286 static bool convert(ToType* output, const FromType& input)286 FORCEINLINE static bool convert(ToType* output, const FromType& input) 287 287 { 288 288 // Try implict cast and probe first. If a simple cast is not possible, it will not compile … … 306 306 */ 307 307 template <class FromType, class ToType> 308 inlinebool convertValue(ToType* output, const FromType& input)308 FORCEINLINE bool convertValue(ToType* output, const FromType& input) 309 309 { 310 310 return ConverterExplicit<FromType, ToType>::convert(output, input); … … 313 313 // For compatibility reasons. The same, but with capital ConvertValue 314 314 template<class FromType, class ToType> 315 inlinebool ConvertValue(ToType* output, const FromType& input)315 FORCEINLINE bool ConvertValue(ToType* output, const FromType& input) 316 316 { 317 317 return convertValue(output, input); … … 331 331 */ 332 332 template<class FromType, class ToType> 333 inlinebool convertValue(ToType* output, const FromType& input, const ToType& fallback)333 FORCEINLINE bool convertValue(ToType* output, const FromType& input, const ToType& fallback) 334 334 { 335 335 if (convertValue(output, input)) … … 344 344 // for compatibility reason. (capital 'c' in ConvertValue) 345 345 template<class FromType, class ToType> 346 inlinebool ConvertValue(ToType* output, const FromType& input, const ToType& fallback)346 FORCEINLINE bool ConvertValue(ToType* output, const FromType& input, const ToType& fallback) 347 347 { 348 348 return convertValue(output, input, fallback); … … 351 351 // Directly returns the converted value, even if the conversion was not successful. 352 352 template<class FromType, class ToType> 353 inlineToType getConvertedValue(const FromType& input)353 FORCEINLINE ToType getConvertedValue(const FromType& input) 354 354 { 355 355 ToType output; … … 360 360 // Directly returns the converted value, but uses the fallback on failure. 361 361 template<class FromType, class ToType> 362 inlineToType getConvertedValue(const FromType& input, const ToType& fallback)362 FORCEINLINE ToType getConvertedValue(const FromType& input, const ToType& fallback) 363 363 { 364 364 ToType output; … … 370 370 // That means you can call it exactly like static_cast<ToType>(fromTypeValue). 371 371 template<class ToType, class FromType> 372 inlineToType multi_cast(const FromType& input)372 FORCEINLINE ToType multi_cast(const FromType& input) 373 373 { 374 374 ToType output; … … 379 379 // convert to string Shortcut 380 380 template <class FromType> 381 inlinestd::string convertToString(FromType value)381 FORCEINLINE std::string convertToString(FromType value) 382 382 { 383 383 return getConvertedValue<FromType, std::string>(value); … … 386 386 // convert from string Shortcut 387 387 template <class ToType> 388 inlineToType convertFromString(std::string str)388 FORCEINLINE ToType convertFromString(std::string str) 389 389 { 390 390 return getConvertedValue<std::string, ToType>(str); … … 399 399 struct ConverterExplicit<const char*, ToType> 400 400 { 401 static bool convert(ToType* output, const char* input)401 FORCEINLINE static bool convert(ToType* output, const char* input) 402 402 { 403 403 return convertValue<std::string, ToType>(output, input); … … 409 409 struct ConverterExplicit<char, std::string> 410 410 { 411 static bool convert(std::string* output, const char input)411 FORCEINLINE static bool convert(std::string* output, const char input) 412 412 { 413 413 *output = std::string(1, input); … … 418 418 struct ConverterExplicit<unsigned char, std::string> 419 419 { 420 static bool convert(std::string* output, const unsigned char input)420 FORCEINLINE static bool convert(std::string* output, const unsigned char input) 421 421 { 422 422 *output = std::string(1, input); … … 427 427 struct ConverterExplicit<std::string, char> 428 428 { 429 static bool convert(char* output, const std::string input)429 FORCEINLINE static bool convert(char* output, const std::string input) 430 430 { 431 431 if (input != "") … … 439 439 struct ConverterExplicit<std::string, unsigned char> 440 440 { 441 static bool convert(unsigned char* output, const std::string input)441 FORCEINLINE static bool convert(unsigned char* output, const std::string input) 442 442 { 443 443 if (input != "") … … 454 454 struct ConverterExplicit<bool, std::string> 455 455 { 456 static bool convert(std::string* output, const bool& input)456 FORCEINLINE static bool convert(std::string* output, const bool& input) 457 457 { 458 458 if (input) -
code/branches/pch/src/util/MathConvert.h
r2171 r3145 50 50 struct ConverterExplicit<orxonox::Vector2, std::string> 51 51 { 52 static bool convert(std::string* output, const orxonox::Vector2& input)52 FORCEINLINE static bool convert(std::string* output, const orxonox::Vector2& input) 53 53 { 54 54 std::ostringstream ostream; … … 66 66 struct ConverterExplicit<orxonox::Vector3, std::string> 67 67 { 68 static bool convert(std::string* output, const orxonox::Vector3& input)68 FORCEINLINE static bool convert(std::string* output, const orxonox::Vector3& input) 69 69 { 70 70 std::ostringstream ostream; … … 82 82 struct ConverterExplicit<orxonox::Vector4, std::string> 83 83 { 84 static bool convert(std::string* output, const orxonox::Vector4& input)84 FORCEINLINE static bool convert(std::string* output, const orxonox::Vector4& input) 85 85 { 86 86 std::ostringstream ostream; … … 98 98 struct ConverterExplicit<orxonox::Quaternion, std::string> 99 99 { 100 static bool convert(std::string* output, const orxonox::Quaternion& input)100 FORCEINLINE static bool convert(std::string* output, const orxonox::Quaternion& input) 101 101 { 102 102 std::ostringstream ostream; … … 114 114 struct ConverterExplicit<orxonox::ColourValue, std::string> 115 115 { 116 static bool convert(std::string* output, const orxonox::ColourValue& input)116 FORCEINLINE static bool convert(std::string* output, const orxonox::ColourValue& input) 117 117 { 118 118 std::ostringstream ostream; … … 156 156 struct ConverterFallback<orxonox::Radian, ToType> 157 157 { 158 static bool convert(ToType* output, const orxonox::Radian& input)158 FORCEINLINE static bool convert(ToType* output, const orxonox::Radian& input) 159 159 { 160 160 return convertValue<Ogre::Real, ToType>(output, input.valueRadians()); … … 166 166 struct ConverterFallback<orxonox::Degree, ToType> 167 167 { 168 static bool convert(ToType* output, const orxonox::Degree& input)168 FORCEINLINE static bool convert(ToType* output, const orxonox::Degree& input) 169 169 { 170 170 return convertValue<Ogre::Real, ToType>(output, input.valueDegrees()); … … 176 176 struct ConverterFallback<FromType, orxonox::Radian> 177 177 { 178 static bool convert(orxonox::Radian* output, const FromType& input)178 FORCEINLINE static bool convert(orxonox::Radian* output, const FromType& input) 179 179 { 180 180 float temp; … … 193 193 struct ConverterFallback<FromType, orxonox::Degree> 194 194 { 195 static bool convert(orxonox::Degree* output, const FromType& input)195 FORCEINLINE static bool convert(orxonox::Degree* output, const FromType& input) 196 196 { 197 197 float temp;
Note: See TracChangeset
for help on using the changeset viewer.