Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1502 for code/trunk/src/util


Ignore:
Timestamp:
Jun 1, 2008, 3:54:20 PM (16 years ago)
Author:
rgrieder
Message:
  • @everyone: Do not create a branch until I've added the svn:eol-style property correctly. Otherwise this would cost me another 4 hours or so when we want to merge back.
  • merged network branch back to trunk
  • I had to omit the changes from last evening concerning the line endings
  • might not work yet because of the line endings
  • @beni: script branch is the only branch still open. you probably will have to apply a patch because of inconsistent new lines
Location:
code/trunk/src/util
Files:
12 edited
1 copied

Legend:

Unmodified
Added
Removed
  • code/trunk/src/util/Convert.h

    r1064 r1502  
    384384        else if (input.getType() == MT_vector3)
    385385            return ConvertValue(output, input.getVector3());
     386        else if (input.getType() == MT_vector4)
     387            return ConvertValue(output, input.getVector4());
    386388        else if (input.getType() == MT_quaternion)
    387389            return ConvertValue(output, input.getQuaternion());
  • code/trunk/src/util/Math.h

    r1349 r1502  
    121121
    122122template <typename T>
     123inline int mod(T x, int max)
     124{
     125    if (x >= 0)
     126        return (x % max);
     127    else
     128        return ((x % max) + max);
     129}
     130
     131template <typename T>
    123132T interpolate(float time, const T& start, const T& end)
    124133{
  • code/trunk/src/util/MultiType.h

    r1056 r1502  
    5454    MT_vector2,
    5555    MT_vector3,
     56    MT_vector4,
    5657    MT_colourvalue,
    5758    MT_quaternion,
  • code/trunk/src/util/MultiTypeMath.cc

    r1056 r1502  
    3737    else if (type == MT_vector3)
    3838        this->vector3_ = orxonox::Vector3(0, 0, 0);
     39    else if (type == MT_vector4)
     40        this->vector4_ = orxonox::Vector4(0, 0, 0, 0);
    3941    else if (type == MT_colourvalue)
    4042        this->colourvalue_ = orxonox::ColourValue(0, 0, 0, 0);
     
    5557        else if (this->type_ == MT_vector3)
    5658            return (this->vector3_ == mtm.vector3_);
     59        else if (this->type_ == MT_vector4)
     60            return (this->vector4_ == mtm.vector4_);
    5761        else if (this->type_ == MT_colourvalue)
    5862            return (this->colourvalue_ == mtm.colourvalue_);
     
    6872}
    6973
     74bool MultiTypeMath::operator==(const MultiTypeString& mts) const
     75{
     76    return MultiTypeString::operator==(mts);
     77}
     78
     79bool MultiTypeMath::operator==(const MultiTypePrimitive& mtp) const
     80{
     81    return MultiTypePrimitive::operator==(mtp);
     82}
     83
    7084bool MultiTypeMath::operator!=(const MultiTypeMath& mtm) const
    7185{
     
    7690        else if (this->type_ == MT_vector3)
    7791            return (this->vector3_ != mtm.vector3_);
     92        else if (this->type_ == MT_vector4)
     93            return (this->vector4_ != mtm.vector4_);
    7894        else if (this->type_ == MT_colourvalue)
    7995            return (this->colourvalue_ != mtm.colourvalue_);
     
    87103
    88104    return true;
     105}
     106
     107bool MultiTypeMath::operator!=(const MultiTypeString& mts) const
     108{
     109    return MultiTypeString::operator!=(mts);
     110}
     111
     112bool MultiTypeMath::operator!=(const MultiTypePrimitive& mtp) const
     113{
     114    return MultiTypePrimitive::operator!=(mtp);
    89115}
    90116
     
    123149MultiTypeMath::operator orxonox::Vector3() const
    124150{ return (this->type_ == MT_vector3) ? this->vector3_ : getConvertedValue<MultiTypeMath, orxonox::Vector3>(*this); }
     151MultiTypeMath::operator orxonox::Vector4() const
     152{ return (this->type_ == MT_vector4) ? this->vector4_ : getConvertedValue<MultiTypeMath, orxonox::Vector4>(*this); }
    125153MultiTypeMath::operator orxonox::Quaternion() const
    126154{ return (this->type_ == MT_quaternion) ? this->quaternion_ : getConvertedValue<MultiTypeMath, orxonox::Quaternion>(*this); }
     
    137165    this->vector2_ = mtm.vector2_;
    138166    this->vector3_ = mtm.vector3_;
     167    this->vector4_ = mtm.vector4_;
    139168    this->quaternion_ = mtm.quaternion_;
    140169    this->colourvalue_ = mtm.colourvalue_;
     
    143172}
    144173
     174void MultiTypeMath::setValue(const MultiTypeString& mts)
     175{
     176    MultiTypeString::setValue(mts);
     177}
     178
     179void MultiTypeMath::setValue(const MultiTypePrimitive& mtp)
     180{
     181    MultiTypePrimitive::setValue(mtp);
     182}
     183
    145184std::string MultiTypeMath::getTypename() const
    146185{
     
    149188    else if (this->type_ == MT_vector3)
    150189        return "Vector3";
     190    else if (this->type_ == MT_vector4)
     191        return "Vector4";
    151192    else if (this->type_ == MT_colourvalue)
    152193        return "ColourValue";
     
    169210    else if (this->type_ == MT_vector3)
    170211        ConvertValue(&output, this->vector3_);
     212    else if (this->type_ == MT_vector4)
     213        ConvertValue(&output, this->vector4_);
    171214    else if (this->type_ == MT_colourvalue)
    172215        ConvertValue(&output, this->colourvalue_);
     
    189232    else if (this->type_ == MT_vector3)
    190233        return ConvertValue(&this->vector3_, value, orxonox::Vector3(0, 0, 0));
     234    else if (this->type_ == MT_vector4)
     235        return ConvertValue(&this->vector4_, value, orxonox::Vector4(0, 0, 0, 0));
    191236    else if (this->type_ == MT_colourvalue)
    192237        return ConvertValue(&this->colourvalue_, value, orxonox::ColourValue(0, 0, 0, 0));
     
    201246}
    202247
     248bool MultiTypeMath::assimilate(const MultiTypeMath& mtm, const MultiTypeMath& defvalue)
     249{
     250    if (this->type_ == MT_void)
     251        return ConvertValue(&this->value_.void_, mtm, defvalue.value_.void_);
     252    else if (this->type_ == MT_int)
     253        return ConvertValue(&this->value_.int_, mtm, defvalue.value_.int_);
     254    else if (this->type_ == MT_uint)
     255        return ConvertValue(&this->value_.uint_, mtm, defvalue.value_.uint_);
     256    else if (this->type_ == MT_char)
     257        return ConvertValue(&this->value_.char_, mtm, defvalue.value_.char_);
     258    else if (this->type_ == MT_uchar)
     259        return ConvertValue(&this->value_.uchar_, mtm, defvalue.value_.uchar_);
     260    else if (this->type_ == MT_short)
     261        return ConvertValue(&this->value_.short_, mtm, defvalue.value_.short_);
     262    else if (this->type_ == MT_ushort)
     263        return ConvertValue(&this->value_.ushort_, mtm, defvalue.value_.ushort_);
     264    else if (this->type_ == MT_long)
     265        return ConvertValue(&this->value_.long_, mtm, defvalue.value_.long_);
     266    else if (this->type_ == MT_ulong)
     267        return ConvertValue(&this->value_.ulong_, mtm, defvalue.value_.ulong_);
     268    else if (this->type_ == MT_float)
     269        return ConvertValue(&this->value_.float_, mtm, defvalue.value_.float_);
     270    else if (this->type_ == MT_double)
     271        return ConvertValue(&this->value_.double_, mtm, defvalue.value_.double_);
     272    else if (this->type_ == MT_longdouble)
     273        return ConvertValue(&this->value_.longdouble_, mtm, defvalue.value_.longdouble_);
     274    else if (this->type_ == MT_bool)
     275        return ConvertValue(&this->value_.bool_, mtm, defvalue.value_.bool_);
     276    else if (this->type_ == MT_constchar)
     277        return ConvertValue(&this->string_, mtm, defvalue.string_);
     278    else if (this->type_ == MT_string)
     279        return ConvertValue(&this->string_, mtm, defvalue.string_);
     280    else if (this->type_ == MT_vector2)
     281        return ConvertValue(&this->vector2_, mtm, defvalue.vector2_);
     282    else if (this->type_ == MT_vector3)
     283        return ConvertValue(&this->vector3_, mtm, defvalue.vector3_);
     284    else if (this->type_ == MT_vector4)
     285        return ConvertValue(&this->vector4_, mtm, defvalue.vector4_);
     286    else if (this->type_ == MT_colourvalue)
     287        return ConvertValue(&this->colourvalue_, mtm, defvalue.colourvalue_);
     288    else if (this->type_ == MT_quaternion)
     289        return ConvertValue(&this->quaternion_, mtm, defvalue.quaternion_);
     290    else if (this->type_ == MT_radian)
     291        return ConvertValue(&this->radian_, mtm, defvalue.radian_);
     292    else if (this->type_ == MT_degree)
     293        return ConvertValue(&this->degree_, mtm, defvalue.degree_);
     294    else
     295        return false;
     296}
     297
    203298std::ostream& operator<<(std::ostream& out, MultiTypeMath& mtm)
    204299{
  • code/trunk/src/util/MultiTypeMath.h

    r1064 r1502  
    6363        inline MultiTypeMath(const orxonox::Vector2&     value) { this->setValue(value); }
    6464        inline MultiTypeMath(const orxonox::Vector3&     value) { this->setValue(value); }
     65        inline MultiTypeMath(const orxonox::Vector4&     value) { this->setValue(value); }
    6566        inline MultiTypeMath(const orxonox::ColourValue& value) { this->setValue(value); }
    6667        inline MultiTypeMath(const orxonox::Quaternion&  value) { this->setValue(value); }
     
    6869        inline MultiTypeMath(const orxonox::Degree&      value) { this->setValue(value); }
    6970        inline MultiTypeMath(const MultiTypeMath& mtm)          { this->setValue(mtm);   }
     71        inline MultiTypeMath(const MultiTypeString& mts)        { this->setValue(mts);   }
     72        inline MultiTypeMath(const MultiTypePrimitive& mtp)     { this->setValue(mtp);   }
    7073        virtual inline ~MultiTypeMath() {}
    7174
     
    7376        inline MultiTypeMath& operator=(const orxonox::Vector2&     value) { this->setValue(value); return *this; }
    7477        inline MultiTypeMath& operator=(const orxonox::Vector3&     value) { this->setValue(value); return *this; }
     78        inline MultiTypeMath& operator=(const orxonox::Vector4&     value) { this->setValue(value); return *this; }
    7579        inline MultiTypeMath& operator=(const orxonox::ColourValue& value) { this->setValue(value); return *this; }
    7680        inline MultiTypeMath& operator=(const orxonox::Quaternion&  value) { this->setValue(value); return *this; }
     
    7882        inline MultiTypeMath& operator=(const orxonox::Degree&      value) { this->setValue(value); return *this; }
    7983        inline MultiTypeMath& operator=(const MultiTypeMath& mtm)          { this->setValue(mtm);   return *this; }
     84        inline MultiTypeMath& operator=(const MultiTypeString& mts)        { this->setValue(mts);   return *this; }
     85        inline MultiTypeMath& operator=(const MultiTypePrimitive mtp)      { this->setValue(mtp);   return *this; }
    8086
    8187        using MultiTypeString::operator==;
    8288        inline bool operator==(const orxonox::Vector2&     value) const { return (this->vector2_     == value); }
    8389        inline bool operator==(const orxonox::Vector3&     value) const { return (this->vector3_     == value); }
     90        inline bool operator==(const orxonox::Vector4&     value) const { return (this->vector4_     == value); }
    8491        inline bool operator==(const orxonox::ColourValue& value) const { return (this->colourvalue_ == value); }
    8592        inline bool operator==(const orxonox::Quaternion&  value) const { return (this->quaternion_  == value); }
     
    8794        inline bool operator==(const orxonox::Degree&      value) const { return (this->degree_      == value); }
    8895        bool operator==(const MultiTypeMath& mtm) const;
     96        bool operator==(const MultiTypeString& mts) const;
     97        bool operator==(const MultiTypePrimitive& mtp) const;
    8998
    9099        using MultiTypeString::operator!=;
    91100        inline bool operator!=(const orxonox::Vector2&     value) const { return (this->vector2_     != value); }
    92101        inline bool operator!=(const orxonox::Vector3&     value) const { return (this->vector3_     != value); }
     102        inline bool operator!=(const orxonox::Vector4&     value) const { return (this->vector4_     != value); }
    93103        inline bool operator!=(const orxonox::ColourValue& value) const { return (this->colourvalue_ != value); }
    94104        inline bool operator!=(const orxonox::Quaternion&  value) const { return (this->quaternion_  != value); }
     
    96106        inline bool operator!=(const orxonox::Degree&      value) const { return (this->degree_      != value); }
    97107        bool operator!=(const MultiTypeMath& mtm) const;
     108        bool operator!=(const MultiTypeString& mts) const;
     109        bool operator!=(const MultiTypePrimitive& mtp) const;
    98110
    99111        virtual operator void*()                const;
     
    114126        virtual operator orxonox::Vector2()     const;
    115127        virtual operator orxonox::Vector3()     const;
     128        virtual operator orxonox::Vector4()     const;
    116129        virtual operator orxonox::ColourValue() const;
    117130        virtual operator orxonox::Quaternion()  const;
     
    122135        inline void setValue(const orxonox::Vector2&     value) { this->type_ = MT_vector2;     this->vector2_     = value; }
    123136        inline void setValue(const orxonox::Vector3&     value) { this->type_ = MT_vector3;     this->vector3_     = value; }
     137        inline void setValue(const orxonox::Vector4&     value) { this->type_ = MT_vector4;     this->vector4_     = value; }
    124138        inline void setValue(const orxonox::ColourValue& value) { this->type_ = MT_colourvalue; this->colourvalue_ = value; }
    125139        inline void setValue(const orxonox::Quaternion&  value) { this->type_ = MT_quaternion;  this->quaternion_  = value; }
     
    127141        inline void setValue(const orxonox::Degree&      value) { this->type_ = MT_degree;      this->degree_      = value; }
    128142        void setValue(const MultiTypeMath& mtm);
     143        void setValue(const MultiTypeString& mts);
     144        void setValue(const MultiTypePrimitive& mtp);
    129145
    130146        inline orxonox::Vector2     getVector2()     const { return this->vector2_;     }
    131147        inline orxonox::Vector3     getVector3()     const { return this->vector3_;     }
     148        inline orxonox::Vector4     getVector4()     const { return this->vector4_;     }
    132149        inline orxonox::ColourValue getColourValue() const { return this->colourvalue_; }
    133150        inline orxonox::Quaternion  getQuaternion()  const { return this->quaternion_;  }
     
    137154        inline orxonox::Vector2&     getVector2()     { return this->vector2_;     }
    138155        inline orxonox::Vector3&     getVector3()     { return this->vector3_;     }
     156        inline orxonox::Vector4&     getVector4()     { return this->vector4_;     }
    139157        inline orxonox::ColourValue& getColourValue() { return this->colourvalue_; }
    140158        inline orxonox::Quaternion&  getQuaternion()  { return this->quaternion_;  }
     
    145163        inline void getValue(orxonox::Vector2*     variable) const { (*variable) = orxonox::Vector2     (this->vector2_);     }
    146164        inline void getValue(orxonox::Vector3*     variable) const { (*variable) = orxonox::Vector3     (this->vector3_);     }
     165        inline void getValue(orxonox::Vector4*     variable) const { (*variable) = orxonox::Vector4     (this->vector4_);     }
    147166        inline void getValue(orxonox::ColourValue* variable) const { (*variable) = orxonox::ColourValue (this->colourvalue_); }
    148167        inline void getValue(orxonox::Quaternion*  variable) const { (*variable) = orxonox::Quaternion  (this->quaternion_);  }
     
    155174        virtual bool fromString(const std::string value);
    156175
     176        virtual bool assimilate(const MultiTypeMath& mtm, const MultiTypeMath& defvalue = MultiTypeMath());
     177
    157178    protected:
    158179        orxonox::Vector2      vector2_;
    159180        orxonox::Vector3      vector3_;
     181        orxonox::Vector4      vector4_;
    160182        orxonox::ColourValue  colourvalue_;
    161183        orxonox::Quaternion   quaternion_;
  • code/trunk/src/util/MultiTypePrimitive.cc

    r1056 r1502  
    266266}
    267267
     268bool MultiTypePrimitive::assimilate(const MultiTypePrimitive& mtp, const MultiTypePrimitive& defvalue)
     269{
     270    if (this->type_ == MT_void)
     271        return ConvertValue(&this->value_.void_, mtp, defvalue.value_.void_);
     272    else if (this->type_ == MT_int)
     273        return ConvertValue(&this->value_.int_, mtp, defvalue.value_.int_);
     274    else if (this->type_ == MT_uint)
     275        return ConvertValue(&this->value_.uint_, mtp, defvalue.value_.uint_);
     276    else if (this->type_ == MT_char)
     277        return ConvertValue(&this->value_.char_, mtp, defvalue.value_.char_);
     278    else if (this->type_ == MT_uchar)
     279        return ConvertValue(&this->value_.uchar_, mtp, defvalue.value_.uchar_);
     280    else if (this->type_ == MT_short)
     281        return ConvertValue(&this->value_.short_, mtp, defvalue.value_.short_);
     282    else if (this->type_ == MT_ushort)
     283        return ConvertValue(&this->value_.ushort_, mtp, defvalue.value_.ushort_);
     284    else if (this->type_ == MT_long)
     285        return ConvertValue(&this->value_.long_, mtp, defvalue.value_.long_);
     286    else if (this->type_ == MT_ulong)
     287        return ConvertValue(&this->value_.ulong_, mtp, defvalue.value_.ulong_);
     288    else if (this->type_ == MT_float)
     289        return ConvertValue(&this->value_.float_, mtp, defvalue.value_.float_);
     290    else if (this->type_ == MT_double)
     291        return ConvertValue(&this->value_.double_, mtp, defvalue.value_.double_);
     292    else if (this->type_ == MT_longdouble)
     293        return ConvertValue(&this->value_.longdouble_, mtp, defvalue.value_.longdouble_);
     294    else if (this->type_ == MT_bool)
     295        return ConvertValue(&this->value_.bool_, mtp, defvalue.value_.bool_);
     296    else
     297        return false;
     298
     299}
     300
    268301std::ostream& operator<<(std::ostream& out, const MultiTypePrimitive& mtp)
    269302{
  • code/trunk/src/util/MultiTypePrimitive.h

    r1062 r1502  
    138138        void setValue(const MultiTypePrimitive& mtp);
    139139
    140         inline void*          getVoid()          const { return this->value_.void_;        }
     140        inline void*          getVoid()          const { return this->value_.void_;       }
    141141        inline int            getInt()           const { return this->value_.int_;        }
    142142        inline unsigned int   getUnsignedInt()   const { return this->value_.uint_;       }
     
    187187        virtual bool fromString(const std::string value);
    188188
     189        virtual bool assimilate(const MultiTypePrimitive& mtp, const MultiTypePrimitive& defvalue = MultiTypePrimitive());
     190
    189191    protected:
    190192        MultiTypeValue  value_;
  • code/trunk/src/util/MultiTypeString.cc

    r1064 r1502  
    3333MultiTypeString::MultiTypeString(MultiType type) : MultiTypePrimitive(type)
    3434{
    35     // Nothing to do for string and xml-element
     35    // Nothing to do for string
    3636}
    3737
     
    4949}
    5050
     51bool MultiTypeString::operator==(const MultiTypePrimitive& mtp) const
     52{
     53    return MultiTypePrimitive::operator==(mtp);
     54}
     55
    5156bool MultiTypeString::operator!=(const MultiTypeString& mts) const
    5257{
     
    6065
    6166    return true;
     67}
     68
     69bool MultiTypeString::operator!=(const MultiTypePrimitive& mtp) const
     70{
     71    return MultiTypePrimitive::operator!=(mtp);
    6272}
    6373
     
    99109}
    100110
     111void MultiTypeString::setValue(const MultiTypePrimitive& mtp)
     112{
     113    MultiTypePrimitive::setValue(mtp);
     114}
     115
    101116std::string MultiTypeString::getTypename() const
    102117{
     
    136151}
    137152
     153bool MultiTypeString::assimilate(const MultiTypeString& mts, const MultiTypeString& defvalue)
     154{
     155    if (this->type_ == MT_void)
     156        return ConvertValue(&this->value_.void_, mts, defvalue.value_.void_);
     157    else if (this->type_ == MT_int)
     158        return ConvertValue(&this->value_.int_, mts, defvalue.value_.int_);
     159    else if (this->type_ == MT_uint)
     160        return ConvertValue(&this->value_.uint_, mts, defvalue.value_.uint_);
     161    else if (this->type_ == MT_char)
     162        return ConvertValue(&this->value_.char_, mts, defvalue.value_.char_);
     163    else if (this->type_ == MT_uchar)
     164        return ConvertValue(&this->value_.uchar_, mts, defvalue.value_.uchar_);
     165    else if (this->type_ == MT_short)
     166        return ConvertValue(&this->value_.short_, mts, defvalue.value_.short_);
     167    else if (this->type_ == MT_ushort)
     168        return ConvertValue(&this->value_.ushort_, mts, defvalue.value_.ushort_);
     169    else if (this->type_ == MT_long)
     170        return ConvertValue(&this->value_.long_, mts, defvalue.value_.long_);
     171    else if (this->type_ == MT_ulong)
     172        return ConvertValue(&this->value_.ulong_, mts, defvalue.value_.ulong_);
     173    else if (this->type_ == MT_float)
     174        return ConvertValue(&this->value_.float_, mts, defvalue.value_.float_);
     175    else if (this->type_ == MT_double)
     176        return ConvertValue(&this->value_.double_, mts, defvalue.value_.double_);
     177    else if (this->type_ == MT_longdouble)
     178        return ConvertValue(&this->value_.longdouble_, mts, defvalue.value_.longdouble_);
     179    else if (this->type_ == MT_bool)
     180        return ConvertValue(&this->value_.bool_, mts, defvalue.value_.bool_);
     181    else if (this->type_ == MT_constchar)
     182        return ConvertValue(&this->string_, mts, defvalue.string_);
     183    else if (this->type_ == MT_string)
     184        return ConvertValue(&this->string_, mts, defvalue.string_);
     185    else
     186        return false;
     187}
     188
    138189std::ostream& operator<<(std::ostream& out, MultiTypeString& mts)
    139190{
  • code/trunk/src/util/MultiTypeString.h

    r1064 r1502  
    6161        inline MultiTypeString(long double    value) : MultiTypePrimitive(value) {}
    6262        inline MultiTypeString(bool           value) : MultiTypePrimitive(value) {}
    63         inline MultiTypeString(const char*           value)   { this->setValue(value); }
    64         inline MultiTypeString(const std::string&    value)   { this->setValue(value); }
    65         inline MultiTypeString(const MultiTypeString& mts)    { this->setValue(mts);   }
     63        inline MultiTypeString(const char*             value) { this->setValue(value); }
     64        inline MultiTypeString(const std::string&      value) { this->setValue(value); }
     65        inline MultiTypeString(const MultiTypeString&    mts)  { this->setValue(mts);   }
     66        inline MultiTypeString(const MultiTypePrimitive& mtp)  { this->setValue(mtp);   }
    6667        virtual inline ~MultiTypeString() {}
    6768
    6869        using MultiTypePrimitive::operator=;
    69         inline MultiTypeString& operator=(const char*             value)   { this->setValue(value); return *this; }
    70         inline MultiTypeString& operator=(const std::string&      value)   { this->setValue(value); return *this; }
    71         inline MultiTypeString& operator=(const MultiTypeString& mts)      { this->setValue(mts);   return *this; }
     70        inline MultiTypeString& operator=(const char*             value) { this->setValue(value); return *this; }
     71        inline MultiTypeString& operator=(const std::string&      value) { this->setValue(value); return *this; }
     72        inline MultiTypeString& operator=(const MultiTypeString&    mts) { this->setValue(mts);   return *this; }
     73        inline MultiTypeString& operator=(const MultiTypePrimitive& mtp) { this->setValue(mtp);   return *this; }
    7274
    7375        using MultiTypePrimitive::operator==;
    74         inline bool operator==(const char*             value) const { return (this->string_      == std::string(value)); }
    75         inline bool operator==(const std::string&      value) const { return (this->string_      == value);              }
    76         bool operator==(const MultiTypeString& mts) const;
     76        inline bool operator==(const char*        value) const { return (this->string_ == std::string(value)); }
     77        inline bool operator==(const std::string& value) const { return (this->string_ == value);              }
     78        bool operator==(const MultiTypeString&    mts) const;
     79        bool operator==(const MultiTypePrimitive& mtp) const;
    7780
    7881        using MultiTypePrimitive::operator!=;
    79         inline bool operator!=(const char*             value) const { return (this->string_      != std::string(value)); }
    80         inline bool operator!=(const std::string&      value) const { return (this->string_      != value);              }
    81         bool operator!=(const MultiTypeString& mts) const;
     82        inline bool operator!=(const char*        value) const { return (this->string_ != std::string(value)); }
     83        inline bool operator!=(const std::string& value) const { return (this->string_ != value);              }
     84        bool operator!=(const MultiTypeString&    mts) const;
     85        bool operator!=(const MultiTypePrimitive& mtp) const;
    8286
    83         virtual operator void*()                const;
    84         virtual operator int()                  const;
    85         virtual operator unsigned int()         const;
    86         virtual operator char()                 const;
    87         virtual operator unsigned char()        const;
    88         virtual operator short()                const;
    89         virtual operator unsigned short()       const;
    90         virtual operator long()                 const;
    91         virtual operator unsigned long()        const;
    92         virtual operator float ()               const;
    93         virtual operator double ()              const;
    94         virtual operator long double()          const;
    95         virtual operator bool()                 const;
    96         virtual operator std::string()          const;
    97         virtual operator const char*()          const;
     87        virtual operator void*()          const;
     88        virtual operator int()            const;
     89        virtual operator unsigned int()   const;
     90        virtual operator char()           const;
     91        virtual operator unsigned char()  const;
     92        virtual operator short()          const;
     93        virtual operator unsigned short() const;
     94        virtual operator long()           const;
     95        virtual operator unsigned long()  const;
     96        virtual operator float ()         const;
     97        virtual operator double ()        const;
     98        virtual operator long double()    const;
     99        virtual operator bool()           const;
     100        virtual operator std::string()    const;
     101        virtual operator const char*()    const;
    98102
    99103        using MultiTypePrimitive::setValue;
    100         inline void setValue(const char*             value) { this->type_ = MT_string;     this->string_     = std::string(value); }
    101         inline void setValue(const std::string&      value) { this->type_ = MT_string;     this->string_     = value;              }
    102         void setValue(const MultiTypeString& mts);
     104        inline void setValue(const char*        value) { this->type_ = MT_string; this->string_ = std::string(value); }
     105        inline void setValue(const std::string& value) { this->type_ = MT_string; this->string_ = value;              }
     106        void setValue(const MultiTypeString&    mts);
     107        void setValue(const MultiTypePrimitive& mtp);
    103108
    104         inline std::string getString()          const { return this->string_;         }
    105         inline const char*  getConstChar()      const { return this->string_.c_str(); }
     109        inline std::string getString()     const { return this->string_;         }
     110        inline const char*  getConstChar() const { return this->string_.c_str(); }
    106111
    107         inline std::string& getString()          { return this->string_;         }
    108         inline const char*  getConstChar()       { return this->string_.c_str(); }
     112        inline std::string& getString()    { return this->string_;         }
     113        inline const char*  getConstChar() { return this->string_.c_str(); }
    109114
    110115        using MultiTypePrimitive::getValue;
    111         inline void getValue(std::string*      variable) const { (*variable) = this->string_;         }
    112         inline void getValue(const char**      variable) const { (*variable) = this->string_.c_str(); }
     116        inline void getValue(std::string* variable) const { (*variable) = this->string_;         }
     117        inline void getValue(const char** variable) const { (*variable) = this->string_.c_str(); }
    113118
    114119        virtual std::string getTypename() const;
     
    116121        virtual std::string toString() const;
    117122        virtual bool fromString(const std::string value);
     123
     124        virtual bool assimilate(const MultiTypeString& mts, const MultiTypeString& defvalue = MultiTypeString());
    118125
    119126    protected:
  • code/trunk/src/util/String.cc

    r1219 r1502  
    108108
    109109    unsigned int quotecount = 0;
    110     unsigned int quote = 0;
    111     while ((quote = getNextQuote(str, quote)) < pos)
     110    unsigned int quote = (unsigned int)-1;
     111    while ((quote = getNextQuote(str, quote + 1)) < pos)
    112112    {
    113113        quotecount++;
     
    185185    else
    186186        return str;
     187}
     188
     189/**
     190    @brief Removes enclosing {braces}.
     191    @param str The string to strip
     192    @return The striped string
     193*/
     194std::string stripEnclosingBraces(const std::string& str)
     195{
     196    std::string output = str;
     197
     198    while (output.size() >= 2 && output[0] == '{' && output[output.size() - 1] == '}')
     199        output = output.substr(1, output.size() - 2);
     200
     201    return output;
    187202}
    188203
  • code/trunk/src/util/String.h

    r1062 r1502  
    4747
    4848_UtilExport std::string  stripEnclosingQuotes(const std::string& str);
     49_UtilExport std::string  stripEnclosingBraces(const std::string& str);
    4950
    5051_UtilExport bool         isEmpty(const std::string& str);
  • code/trunk/src/util/UtilPrereqs.h

    r1062 r1502  
    3535#define _UtilPrereqs_H__
    3636
    37 #include "OrxonoxPlatform.h"
     37#include "util/OrxonoxPlatform.h"
    3838
    3939//-----------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.