Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 14, 2008, 3:42:49 AM (16 years ago)
Author:
landauf
Message:

merged core2 back to trunk
there might be some errors, wasn't able to test it yet due to some strange g++ and linker behaviour.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/util/MultiTypePrimitive.cc

    r871 r1052  
    3434    this->type_ = type;
    3535
    36     if (type == MT_int)
     36    if (type == MT_void)
     37        this->value_.void_ = 0;
     38    else if (type == MT_int)
    3739        this->value_.int_ = 0;
    3840    else if (type == MT_uint)
     
    5961        this->value_.bool_ = false;
    6062    else
    61         this->value_.int_ = 0;
     63        this->value_.void_ = 0;
    6264}
    6365
     
    6668    if (this->type_ == mtp.type_)
    6769    {
    68         if (this->type_ == MT_int)
     70        if (this->type_ == MT_void)
     71            return (this->value_.void_ == mtp.value_.void_);
     72        else if (this->type_ == MT_int)
    6973            return (this->value_.int_ == mtp.value_.int_);
    7074        else if (this->type_ == MT_uint)
     
    99103    if (this->type_ == mtp.type_)
    100104    {
    101         if (this->type_ == MT_int)
     105        if (this->type_ == MT_void)
     106            return (this->value_.void_ != mtp.value_.void_);
     107        else if (this->type_ == MT_int)
    102108            return (this->value_.int_ != mtp.value_.int_);
    103109        else if (this->type_ == MT_uint)
     
    128134}
    129135
     136MultiTypePrimitive::operator void*() const
     137{ return (this->type_ == MT_void) ? this->value_.void_ : getConvertedValue<MultiTypePrimitive, void*>(*this, 0); }
    130138MultiTypePrimitive::operator int() const
    131 { return (this->type_ == MT_int) ? this->value_.int_ : ConvertValueAndReturn<MultiTypePrimitive, int>(*this); }
     139{ return (this->type_ == MT_int) ? this->value_.int_ : getConvertedValue<MultiTypePrimitive, int>(*this, 0); }
    132140MultiTypePrimitive::operator unsigned int() const
    133 { return (this->type_ == MT_uint) ? this->value_.uint_ : ConvertValueAndReturn<MultiTypePrimitive, unsigned int>(*this); }
     141{ return (this->type_ == MT_uint) ? this->value_.uint_ : getConvertedValue<MultiTypePrimitive, unsigned int>(*this, 0); }
    134142MultiTypePrimitive::operator char() const
    135 { return (this->type_ == MT_char) ? this->value_.char_ : ConvertValueAndReturn<MultiTypePrimitive, char>(*this); }
     143{ return (this->type_ == MT_char) ? this->value_.char_ : getConvertedValue<MultiTypePrimitive, char>(*this, 0); }
    136144MultiTypePrimitive::operator unsigned char() const
    137 { return (this->type_ == MT_uchar) ? this->value_.uchar_ : ConvertValueAndReturn<MultiTypePrimitive, unsigned char>(*this); }
     145{ return (this->type_ == MT_uchar) ? this->value_.uchar_ : getConvertedValue<MultiTypePrimitive, unsigned char>(*this, 0); }
    138146MultiTypePrimitive::operator short() const
    139 { return (this->type_ == MT_short) ? this->value_.short_ : ConvertValueAndReturn<MultiTypePrimitive, short>(*this); }
     147{ return (this->type_ == MT_short) ? this->value_.short_ : getConvertedValue<MultiTypePrimitive, short>(*this, 0); }
    140148MultiTypePrimitive::operator unsigned short() const
    141 { return (this->type_ == MT_ushort) ? this->value_.ushort_ : ConvertValueAndReturn<MultiTypePrimitive, unsigned short>(*this); }
     149{ return (this->type_ == MT_ushort) ? this->value_.ushort_ : getConvertedValue<MultiTypePrimitive, unsigned short>(*this, 0); }
    142150MultiTypePrimitive::operator long() const
    143 { return (this->type_ == MT_long) ? this->value_.long_ : ConvertValueAndReturn<MultiTypePrimitive, long>(*this); }
     151{ return (this->type_ == MT_long) ? this->value_.long_ : getConvertedValue<MultiTypePrimitive, long>(*this, 0); }
    144152MultiTypePrimitive::operator unsigned long() const
    145 { return (this->type_ == MT_ulong) ? this->value_.ulong_ : ConvertValueAndReturn<MultiTypePrimitive, unsigned long>(*this); }
     153{ return (this->type_ == MT_ulong) ? this->value_.ulong_ : getConvertedValue<MultiTypePrimitive, unsigned long>(*this, 0); }
    146154MultiTypePrimitive::operator float() const
    147 { return (this->type_ == MT_float) ? this->value_.float_ : ConvertValueAndReturn<MultiTypePrimitive, float>(*this); }
     155{ return (this->type_ == MT_float) ? this->value_.float_ : getConvertedValue<MultiTypePrimitive, float>(*this, 0); }
    148156MultiTypePrimitive::operator double() const
    149 { return (this->type_ == MT_double) ? this->value_.double_ : ConvertValueAndReturn<MultiTypePrimitive, double>(*this); }
     157{ return (this->type_ == MT_double) ? this->value_.double_ : getConvertedValue<MultiTypePrimitive, double>(*this, 0); }
    150158MultiTypePrimitive::operator long double() const
    151 { return (this->type_ == MT_longdouble) ? this->value_.longdouble_ : ConvertValueAndReturn<MultiTypePrimitive, long double>(*this); }
     159{ return (this->type_ == MT_longdouble) ? this->value_.longdouble_ : getConvertedValue<MultiTypePrimitive, long double>(*this, 0); }
    152160MultiTypePrimitive::operator bool() const
    153 { return (this->type_ == MT_bool) ? this->value_.bool_ : ConvertValueAndReturn<MultiTypePrimitive, bool>(*this); }
     161{ return (this->type_ == MT_bool) ? this->value_.bool_ : getConvertedValue<MultiTypePrimitive, bool>(*this, 0); }
    154162
    155163void MultiTypePrimitive::setValue(const MultiTypePrimitive& mtp)
     
    159167}
    160168
     169std::string MultiTypePrimitive::getTypename() const
     170{
     171    if (this->type_ == MT_void)
     172        return "pointer";
     173    else if (this->type_ == MT_int)
     174        return "int";
     175    else if (this->type_ == MT_uint)
     176        return "unsigned int";
     177    else if (this->type_ == MT_char)
     178        return "char";
     179    else if (this->type_ == MT_uchar)
     180        return "unsigned char";
     181    else if (this->type_ == MT_short)
     182        return "short";
     183    else if (this->type_ == MT_ushort)
     184        return "unsigned short";
     185    else if (this->type_ == MT_long)
     186        return "long";
     187    else if (this->type_ == MT_ulong)
     188        return "unsigned long";
     189    else if (this->type_ == MT_float)
     190        return "float";
     191    else if (this->type_ == MT_double)
     192        return "double";
     193    else if (this->type_ == MT_longdouble)
     194        return "long double";
     195    else if (this->type_ == MT_bool)
     196        return "bool";
     197    else
     198        return "unknown";
     199}
     200
    161201std::string MultiTypePrimitive::toString() const
    162202{
    163203    std::string output;
    164204
    165     if (this->type_ == MT_int)
     205    if (this->type_ == MT_void)
     206        ConvertValue(&output, this->value_.void_);
     207    else if (this->type_ == MT_int)
    166208        ConvertValue(&output, this->value_.int_);
    167209    else if (this->type_ == MT_uint)
     
    193235bool MultiTypePrimitive::fromString(const std::string value)
    194236{
    195     if (this->type_ == MT_int)
     237    if (this->type_ == MT_void)
     238        return ConvertValue(&this->value_.void_, value, (void*)0);
     239    else if (this->type_ == MT_int)
    196240        return ConvertValue(&this->value_.int_, value, (int)0);
    197241    else if (this->type_ == MT_uint)
Note: See TracChangeset for help on using the changeset viewer.