Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 834 for code/branches/core


Ignore:
Timestamp:
Feb 21, 2008, 10:05:05 PM (17 years ago)
Author:
landauf
Message:

added convert-operators

Location:
code/branches/core/src/util
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core/src/util/MultiTypeMath.h

    r797 r834  
    8888        bool operator!=(const MultiTypeMath& mtm) const;
    8989
     90        inline operator orxonox::Vector2()     const { return this->vector2_;     }
     91        inline operator orxonox::Vector3()     const { return this->vector3_;     }
     92        inline operator orxonox::ColourValue() const { return this->colourvalue_; }
     93        inline operator orxonox::Quaternion()  const { return this->quaternion_;  }
     94        inline operator orxonox::Radian()      const { return this->radian_;      }
     95        inline operator orxonox::Degree()      const { return this->degree_;      }
     96
    9097        using MultiTypeString::setValue;
    9198        inline void setValue(const orxonox::Vector2&     value) { this->type_ = MT_vector2;     this->vector2_     = value; }
  • code/branches/core/src/util/MultiTypePrimitive.h

    r797 r834  
    5454        MultiTypePrimitive(const MultiTypePrimitive& mtp);
    5555
     56        inline MultiTypePrimitive& operator=(MultiType      value) { this->type_ = MT_null; return *this; }
    5657        inline MultiTypePrimitive& operator=(int            value) { this->setValue(value); return *this; }
    5758        inline MultiTypePrimitive& operator=(unsigned int   value) { this->setValue(value); return *this; }
     
    9596        inline bool operator!=(bool           value) const { return (this->value_.bool_       != value); }
    9697        bool operator!=(const MultiTypePrimitive& mtp) const;
     98
     99        inline operator int()            const { return this->value_.int_;        }
     100        inline operator unsigned int()   const { return this->value_.uint_;       }
     101        inline operator char()           const { return this->value_.char_;       }
     102        inline operator unsigned char()  const { return this->value_.uchar_;      }
     103        inline operator short()          const { return this->value_.short_;      }
     104        inline operator unsigned short() const { return this->value_.ushort_;     }
     105        inline operator long()           const { return this->value_.long_;       }
     106        inline operator unsigned long()  const { return this->value_.ulong_;      }
     107        inline operator float ()         const { return this->value_.float_;      }
     108        inline operator double ()        const { return this->value_.double_;     }
     109        inline operator long double()    const { return this->value_.longdouble_; }
     110        inline operator bool()           const { return this->value_.bool_;       }
    97111
    98112        inline void setValue(int            value) { this->type_ = MT_int;        this->value_.int_        = value; }
  • code/branches/core/src/util/MultiTypeString.h

    r797 r834  
    6363        using MultiTypePrimitive::operator==;
    6464        inline bool operator==(const char*        value) const { return (this->string_ == std::string(value)); }
    65         inline bool operator==(const std::string& value) const { return (this->string_ == value); }
     65        inline bool operator==(const std::string& value) const { return (this->string_ == value);              }
    6666        bool operator==(const MultiTypeString& mtp) const;
    6767
    6868        using MultiTypePrimitive::operator!=;
    6969        inline bool operator!=(const char*        value) const { return (this->string_ != std::string(value)); }
    70         inline bool operator!=(const std::string& value) const { return (this->string_ != value); }
     70        inline bool operator!=(const std::string& value) const { return (this->string_ != value);              }
    7171        bool operator!=(const MultiTypeString& mtp) const;
     72
     73        inline operator std::string() const { return this->string_;         }
     74        inline operator const char*() const { return this->string_.c_str(); }
    7275
    7376        using MultiTypePrimitive::setValue;
    7477        inline void setValue(const char*        value) { this->type_ = MT_string; this->string_ = std::string(value); }
    75         inline void setValue(const std::string& value) { this->type_ = MT_string; this->string_ = value; }
     78        inline void setValue(const std::string& value) { this->type_ = MT_string; this->string_ = value;              }
    7679        void setValue(const MultiTypeString& mtp);
    7780
    78         inline std::string& getString()    { return this->string_; }
     81        inline std::string& getString()    { return this->string_;         }
    7982        inline const char*  getConstChar() { return this->string_.c_str(); }
    8083
    8184        using MultiTypePrimitive::getValue;
    82         inline void getValue(std::string* variable) const { (*variable) = this->string_; }
     85        inline void getValue(std::string* variable) const { (*variable) = this->string_;         }
    8386        inline void getValue(const char** variable) const { (*variable) = this->string_.c_str(); }
    8487
Note: See TracChangeset for help on using the changeset viewer.