Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 19, 2008, 2:18:55 AM (16 years ago)
Author:
landauf
Message:

changed the previously implemented assimilate function to take an optional default-value and to return false if the conversion failed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/console/src/util/MultiTypePrimitive.cc

    r1319 r1320  
    266266}
    267267
    268 void MultiTypePrimitive::assimilate(const MultiTypePrimitive& mtp)
     268bool MultiTypePrimitive::assimilate(const MultiTypePrimitive& mtp, const MultiTypePrimitive& defvalue)
    269269{
    270270    if (this->type_ == MT_void)
    271         this->value_.void_ = mtp;
     271        return ConvertValue(&this->value_.void_, mtp, defvalue.value_.void_);
    272272    else if (this->type_ == MT_int)
    273         this->value_.int_ = mtp;
     273        return ConvertValue(&this->value_.int_, mtp, defvalue.value_.int_);
    274274    else if (this->type_ == MT_uint)
    275         this->value_.uint_ = mtp;
     275        return ConvertValue(&this->value_.uint_, mtp, defvalue.value_.uint_);
    276276    else if (this->type_ == MT_char)
    277         this->value_.char_ = mtp;
     277        return ConvertValue(&this->value_.char_, mtp, defvalue.value_.char_);
    278278    else if (this->type_ == MT_uchar)
    279         this->value_.uchar_ = mtp;
     279        return ConvertValue(&this->value_.uchar_, mtp, defvalue.value_.uchar_);
    280280    else if (this->type_ == MT_short)
    281         this->value_.short_ = mtp;
     281        return ConvertValue(&this->value_.short_, mtp, defvalue.value_.short_);
    282282    else if (this->type_ == MT_ushort)
    283         this->value_.ushort_ = mtp;
     283        return ConvertValue(&this->value_.ushort_, mtp, defvalue.value_.ushort_);
    284284    else if (this->type_ == MT_long)
    285         this->value_.long_ = mtp;
     285        return ConvertValue(&this->value_.long_, mtp, defvalue.value_.long_);
    286286    else if (this->type_ == MT_ulong)
    287         this->value_.ulong_ = mtp;
     287        return ConvertValue(&this->value_.ulong_, mtp, defvalue.value_.ulong_);
    288288    else if (this->type_ == MT_float)
    289         this->value_.float_ = mtp;
     289        return ConvertValue(&this->value_.float_, mtp, defvalue.value_.float_);
    290290    else if (this->type_ == MT_double)
    291         this->value_.double_ = mtp;
     291        return ConvertValue(&this->value_.double_, mtp, defvalue.value_.double_);
    292292    else if (this->type_ == MT_longdouble)
    293         this->value_.longdouble_ = mtp;
     293        return ConvertValue(&this->value_.longdouble_, mtp, defvalue.value_.longdouble_);
    294294    else if (this->type_ == MT_bool)
    295         this->value_.bool_ = mtp;
     295        return ConvertValue(&this->value_.bool_, mtp, defvalue.value_.bool_);
     296    else
     297        return false;
     298
    296299}
    297300
Note: See TracChangeset for help on using the changeset viewer.