Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 960


Ignore:
Timestamp:
Mar 30, 2008, 4:54:44 PM (17 years ago)
Author:
landauf
Message:

next try

Location:
code/branches/core2/src/util
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core2/src/util/Convert.h

    r959 r960  
    116116// THE SAME, BUT WITH DEFAULT VALUE
    117117template<typename FromType, typename ToType>
    118 static ToType ConvertValueAndReturn(const FromType& input, const FromType& fallback)
    119 {
    120   ToType output;
     118static ToType ConvertValueAndReturn(const FromType& input, const ToType& fallback)
     119{
     120  ToType output = fallback;
    121121  ConvertValue(&output, input, fallback);
    122122  return output;
     
    541541};
    542542
    543 ////////////////////////////////////////////
    544 // Some specializations to avoid warnings //
    545 ////////////////////////////////////////////
    546 #define CONVERT_VALUE_AND_RETURN_SPECIALIZATION(ToType) \
    547   template<typename FromType> \
    548   static ToType ConvertValueAndReturn(const FromType& input) \
    549   { \
    550     ToType output = 0; \
    551     ConvertValue(&output, input); \
    552     return output; \
    553   }
    554 
    555 CONVERT_VALUE_AND_RETURN_SPECIALIZATION(void*)
    556 CONVERT_VALUE_AND_RETURN_SPECIALIZATION(int)
    557 CONVERT_VALUE_AND_RETURN_SPECIALIZATION(unsigned int)
    558 CONVERT_VALUE_AND_RETURN_SPECIALIZATION(char)
    559 CONVERT_VALUE_AND_RETURN_SPECIALIZATION(unsigned char)
    560 CONVERT_VALUE_AND_RETURN_SPECIALIZATION(short)
    561 CONVERT_VALUE_AND_RETURN_SPECIALIZATION(unsigned short)
    562 CONVERT_VALUE_AND_RETURN_SPECIALIZATION(long)
    563 CONVERT_VALUE_AND_RETURN_SPECIALIZATION(unsigned long)
    564 CONVERT_VALUE_AND_RETURN_SPECIALIZATION(float)
    565 CONVERT_VALUE_AND_RETURN_SPECIALIZATION(double)
    566 CONVERT_VALUE_AND_RETURN_SPECIALIZATION(long double)
    567 CONVERT_VALUE_AND_RETURN_SPECIALIZATION(bool)
    568 
    569543#endif /* _Convert_H__ */
  • code/branches/core2/src/util/MultiTypeMath.cc

    r947 r960  
    8989
    9090MultiTypeMath::operator void*() const
    91 { return (this->type_ == MT_void) ? this->value_.void_ : ConvertValueAndReturn<MultiTypeMath, void*>(*this); }
     91{ return (this->type_ == MT_void) ? this->value_.void_ : ConvertValueAndReturn<MultiTypeMath, void*>(*this, 0); }
    9292MultiTypeMath::operator int() const
    93 { return (this->type_ == MT_int) ? this->value_.int_ : ConvertValueAndReturn<MultiTypeMath, int>(*this); }
     93{ return (this->type_ == MT_int) ? this->value_.int_ : ConvertValueAndReturn<MultiTypeMath, int>(*this, 0); }
    9494MultiTypeMath::operator unsigned int() const
    95 { return (this->type_ == MT_uint) ? this->value_.uint_ : ConvertValueAndReturn<MultiTypeMath, unsigned int>(*this); }
     95{ return (this->type_ == MT_uint) ? this->value_.uint_ : ConvertValueAndReturn<MultiTypeMath, unsigned int>(*this, 0); }
    9696MultiTypeMath::operator char() const
    97 { return (this->type_ == MT_char) ? this->value_.char_ : ConvertValueAndReturn<MultiTypeMath, char>(*this); }
     97{ return (this->type_ == MT_char) ? this->value_.char_ : ConvertValueAndReturn<MultiTypeMath, char>(*this, 0); }
    9898MultiTypeMath::operator unsigned char() const
    99 { return (this->type_ == MT_uchar) ? this->value_.uchar_ : ConvertValueAndReturn<MultiTypeMath, unsigned char>(*this); }
     99{ return (this->type_ == MT_uchar) ? this->value_.uchar_ : ConvertValueAndReturn<MultiTypeMath, unsigned char>(*this, 0); }
    100100MultiTypeMath::operator short() const
    101 { return (this->type_ == MT_short) ? this->value_.short_ : ConvertValueAndReturn<MultiTypeMath, short>(*this); }
     101{ return (this->type_ == MT_short) ? this->value_.short_ : ConvertValueAndReturn<MultiTypeMath, short>(*this, 0); }
    102102MultiTypeMath::operator unsigned short() const
    103 { return (this->type_ == MT_ushort) ? this->value_.ushort_ : ConvertValueAndReturn<MultiTypeMath, unsigned short>(*this); }
     103{ return (this->type_ == MT_ushort) ? this->value_.ushort_ : ConvertValueAndReturn<MultiTypeMath, unsigned short>(*this, 0); }
    104104MultiTypeMath::operator long() const
    105 { return (this->type_ == MT_long) ? this->value_.long_ : ConvertValueAndReturn<MultiTypeMath, long>(*this); }
     105{ return (this->type_ == MT_long) ? this->value_.long_ : ConvertValueAndReturn<MultiTypeMath, long>(*this, 0); }
    106106MultiTypeMath::operator unsigned long() const
    107 { return (this->type_ == MT_ulong) ? this->value_.ulong_ : ConvertValueAndReturn<MultiTypeMath, unsigned long>(*this); }
     107{ return (this->type_ == MT_ulong) ? this->value_.ulong_ : ConvertValueAndReturn<MultiTypeMath, unsigned long>(*this, 0); }
    108108MultiTypeMath::operator float() const
    109 { return (this->type_ == MT_float) ? this->value_.float_ : ConvertValueAndReturn<MultiTypeMath, float>(*this); }
     109{ return (this->type_ == MT_float) ? this->value_.float_ : ConvertValueAndReturn<MultiTypeMath, float>(*this, 0); }
    110110MultiTypeMath::operator double() const
    111 { return (this->type_ == MT_double) ? this->value_.double_ : ConvertValueAndReturn<MultiTypeMath, double>(*this); }
     111{ return (this->type_ == MT_double) ? this->value_.double_ : ConvertValueAndReturn<MultiTypeMath, double>(*this, 0); }
    112112MultiTypeMath::operator long double() const
    113 { return (this->type_ == MT_longdouble) ? this->value_.longdouble_ : ConvertValueAndReturn<MultiTypeMath, long double>(*this); }
     113{ return (this->type_ == MT_longdouble) ? this->value_.longdouble_ : ConvertValueAndReturn<MultiTypeMath, long double>(*this, 0); }
    114114MultiTypeMath::operator bool() const
    115 { return (this->type_ == MT_bool) ? this->value_.bool_ : ConvertValueAndReturn<MultiTypeMath, bool>(*this); }
     115{ return (this->type_ == MT_bool) ? this->value_.bool_ : ConvertValueAndReturn<MultiTypeMath, bool>(*this, 0); }
    116116MultiTypeMath::operator std::string() const
    117117{ return (this->type_ == MT_string) ? this->string_ : ConvertValueAndReturn<MultiTypeMath, std::string>(*this); }
  • code/branches/core2/src/util/MultiTypePrimitive.cc

    r947 r960  
    135135
    136136MultiTypePrimitive::operator void*() const
    137 { return (this->type_ == MT_void) ? this->value_.void_ : ConvertValueAndReturn<MultiTypePrimitive, void*>(*this); }
     137{ return (this->type_ == MT_void) ? this->value_.void_ : ConvertValueAndReturn<MultiTypePrimitive, void*>(*this, 0); }
    138138MultiTypePrimitive::operator int() const
    139 { return (this->type_ == MT_int) ? this->value_.int_ : ConvertValueAndReturn<MultiTypePrimitive, int>(*this); }
     139{ return (this->type_ == MT_int) ? this->value_.int_ : ConvertValueAndReturn<MultiTypePrimitive, int>(*this, 0); }
    140140MultiTypePrimitive::operator unsigned int() const
    141 { return (this->type_ == MT_uint) ? this->value_.uint_ : ConvertValueAndReturn<MultiTypePrimitive, unsigned int>(*this); }
     141{ return (this->type_ == MT_uint) ? this->value_.uint_ : ConvertValueAndReturn<MultiTypePrimitive, unsigned int>(*this, 0); }
    142142MultiTypePrimitive::operator char() const
    143 { return (this->type_ == MT_char) ? this->value_.char_ : ConvertValueAndReturn<MultiTypePrimitive, char>(*this); }
     143{ return (this->type_ == MT_char) ? this->value_.char_ : ConvertValueAndReturn<MultiTypePrimitive, char>(*this, 0); }
    144144MultiTypePrimitive::operator unsigned char() const
    145 { return (this->type_ == MT_uchar) ? this->value_.uchar_ : ConvertValueAndReturn<MultiTypePrimitive, unsigned char>(*this); }
     145{ return (this->type_ == MT_uchar) ? this->value_.uchar_ : ConvertValueAndReturn<MultiTypePrimitive, unsigned char>(*this, 0); }
    146146MultiTypePrimitive::operator short() const
    147 { return (this->type_ == MT_short) ? this->value_.short_ : ConvertValueAndReturn<MultiTypePrimitive, short>(*this); }
     147{ return (this->type_ == MT_short) ? this->value_.short_ : ConvertValueAndReturn<MultiTypePrimitive, short>(*this, 0); }
    148148MultiTypePrimitive::operator unsigned short() const
    149 { return (this->type_ == MT_ushort) ? this->value_.ushort_ : ConvertValueAndReturn<MultiTypePrimitive, unsigned short>(*this); }
     149{ return (this->type_ == MT_ushort) ? this->value_.ushort_ : ConvertValueAndReturn<MultiTypePrimitive, unsigned short>(*this, 0); }
    150150MultiTypePrimitive::operator long() const
    151 { return (this->type_ == MT_long) ? this->value_.long_ : ConvertValueAndReturn<MultiTypePrimitive, long>(*this); }
     151{ return (this->type_ == MT_long) ? this->value_.long_ : ConvertValueAndReturn<MultiTypePrimitive, long>(*this, 0); }
    152152MultiTypePrimitive::operator unsigned long() const
    153 { return (this->type_ == MT_ulong) ? this->value_.ulong_ : ConvertValueAndReturn<MultiTypePrimitive, unsigned long>(*this); }
     153{ return (this->type_ == MT_ulong) ? this->value_.ulong_ : ConvertValueAndReturn<MultiTypePrimitive, unsigned long>(*this, 0); }
    154154MultiTypePrimitive::operator float() const
    155 { return (this->type_ == MT_float) ? this->value_.float_ : ConvertValueAndReturn<MultiTypePrimitive, float>(*this); }
     155{ return (this->type_ == MT_float) ? this->value_.float_ : ConvertValueAndReturn<MultiTypePrimitive, float>(*this, 0); }
    156156MultiTypePrimitive::operator double() const
    157 { return (this->type_ == MT_double) ? this->value_.double_ : ConvertValueAndReturn<MultiTypePrimitive, double>(*this); }
     157{ return (this->type_ == MT_double) ? this->value_.double_ : ConvertValueAndReturn<MultiTypePrimitive, double>(*this, 0); }
    158158MultiTypePrimitive::operator long double() const
    159 { return (this->type_ == MT_longdouble) ? this->value_.longdouble_ : ConvertValueAndReturn<MultiTypePrimitive, long double>(*this); }
     159{ return (this->type_ == MT_longdouble) ? this->value_.longdouble_ : ConvertValueAndReturn<MultiTypePrimitive, long double>(*this, 0); }
    160160MultiTypePrimitive::operator bool() const
    161 { return (this->type_ == MT_bool) ? this->value_.bool_ : ConvertValueAndReturn<MultiTypePrimitive, bool>(*this); }
     161{ return (this->type_ == MT_bool) ? this->value_.bool_ : ConvertValueAndReturn<MultiTypePrimitive, bool>(*this, 0); }
    162162
    163163void MultiTypePrimitive::setValue(const MultiTypePrimitive& mtp)
  • code/branches/core2/src/util/MultiTypeString.cc

    r947 r960  
    6666
    6767MultiTypeString::operator void*() const
    68 { return (this->type_ == MT_void) ? this->value_.void_ : ConvertValueAndReturn<MultiTypeString, void*>(*this); }
     68{ return (this->type_ == MT_void) ? this->value_.void_ : ConvertValueAndReturn<MultiTypeString, void*>(*this, 0); }
    6969MultiTypeString::operator int() const
    70 { return (this->type_ == MT_int) ? this->value_.int_ : ConvertValueAndReturn<MultiTypeString, int>(*this); }
     70{ return (this->type_ == MT_int) ? this->value_.int_ : ConvertValueAndReturn<MultiTypeString, int>(*this, 0); }
    7171MultiTypeString::operator unsigned int() const
    72 { return (this->type_ == MT_uint) ? this->value_.uint_ : ConvertValueAndReturn<MultiTypeString, unsigned int>(*this); }
     72{ return (this->type_ == MT_uint) ? this->value_.uint_ : ConvertValueAndReturn<MultiTypeString, unsigned int>(*this, 0); }
    7373MultiTypeString::operator char() const
    74 { return (this->type_ == MT_char) ? this->value_.char_ : ConvertValueAndReturn<MultiTypeString, char>(*this); }
     74{ return (this->type_ == MT_char) ? this->value_.char_ : ConvertValueAndReturn<MultiTypeString, char>(*this, 0); }
    7575MultiTypeString::operator unsigned char() const
    76 { return (this->type_ == MT_uchar) ? this->value_.uchar_ : ConvertValueAndReturn<MultiTypeString, unsigned char>(*this); }
     76{ return (this->type_ == MT_uchar) ? this->value_.uchar_ : ConvertValueAndReturn<MultiTypeString, unsigned char>(*this, 0); }
    7777MultiTypeString::operator short() const
    78 { return (this->type_ == MT_short) ? this->value_.short_ : ConvertValueAndReturn<MultiTypeString, short>(*this); }
     78{ return (this->type_ == MT_short) ? this->value_.short_ : ConvertValueAndReturn<MultiTypeString, short>(*this, 0); }
    7979MultiTypeString::operator unsigned short() const
    80 { return (this->type_ == MT_ushort) ? this->value_.ushort_ : ConvertValueAndReturn<MultiTypeString, unsigned short>(*this); }
     80{ return (this->type_ == MT_ushort) ? this->value_.ushort_ : ConvertValueAndReturn<MultiTypeString, unsigned short>(*this, 0); }
    8181MultiTypeString::operator long() const
    82 { return (this->type_ == MT_long) ? this->value_.long_ : ConvertValueAndReturn<MultiTypeString, long>(*this); }
     82{ return (this->type_ == MT_long) ? this->value_.long_ : ConvertValueAndReturn<MultiTypeString, long>(*this, 0); }
    8383MultiTypeString::operator unsigned long() const
    84 { return (this->type_ == MT_ulong) ? this->value_.ulong_ : ConvertValueAndReturn<MultiTypeString, unsigned long>(*this); }
     84{ return (this->type_ == MT_ulong) ? this->value_.ulong_ : ConvertValueAndReturn<MultiTypeString, unsigned long>(*this, 0); }
    8585MultiTypeString::operator float() const
    86 { return (this->type_ == MT_float) ? this->value_.float_ : ConvertValueAndReturn<MultiTypeString, float>(*this); }
     86{ return (this->type_ == MT_float) ? this->value_.float_ : ConvertValueAndReturn<MultiTypeString, float>(*this, 0); }
    8787MultiTypeString::operator double() const
    88 { return (this->type_ == MT_double) ? this->value_.double_ : ConvertValueAndReturn<MultiTypeString, double>(*this); }
     88{ return (this->type_ == MT_double) ? this->value_.double_ : ConvertValueAndReturn<MultiTypeString, double>(*this, 0); }
    8989MultiTypeString::operator long double() const
    90 { return (this->type_ == MT_longdouble) ? this->value_.longdouble_ : ConvertValueAndReturn<MultiTypeString, long double>(*this); }
     90{ return (this->type_ == MT_longdouble) ? this->value_.longdouble_ : ConvertValueAndReturn<MultiTypeString, long double>(*this, 0); }
    9191MultiTypeString::operator bool() const
    92 { return (this->type_ == MT_bool) ? this->value_.bool_ : ConvertValueAndReturn<MultiTypeString, bool>(*this); }
     92{ return (this->type_ == MT_bool) ? this->value_.bool_ : ConvertValueAndReturn<MultiTypeString, bool>(*this, 0); }
    9393MultiTypeString::operator std::string() const
    9494{ return (this->type_ == MT_string) ? this->string_ : ConvertValueAndReturn<MultiTypeString, std::string>(*this); }
Note: See TracChangeset for help on using the changeset viewer.