diff --git a/src/InputFilter.cpp b/src/InputFilter.cpp index 9a7faa1d68..d26c0dfe4e 100644 --- a/src/InputFilter.cpp +++ b/src/InputFilter.cpp @@ -51,14 +51,29 @@ struct DeviceButtonPair InputDevice device; DeviceButton button; DeviceButtonPair( InputDevice d, DeviceButton b ): device(d), button(b){ } - bool operator<( const DeviceButtonPair &other ) const - { - if( device != other.device ) - return device < other.device; - return button < other.button; - } }; +inline bool operator<(DeviceButtonPair const &lhs, DeviceButtonPair const &rhs) +{ + if (lhs.device != rhs.device) + { + return lhs.device < rhs.device; + } + return lhs.button < rhs.button; +} +inline bool operator>(DeviceButtonPair const &lhs, DeviceButtonPair const &rhs) +{ + return operator<(rhs, lhs); +} +inline bool operator<=(DeviceButtonPair const &lhs, DeviceButtonPair const &rhs) +{ + return !operator<(rhs, lhs); +} +inline bool operator>=(DeviceButtonPair const &lhs, DeviceButtonPair const &rhs) +{ + return !operator<(lhs, rhs); +} + namespace { /* Maintain a set of all interesting buttons: buttons which are being held diff --git a/src/NotesLoaderBMS.cpp b/src/NotesLoaderBMS.cpp index 9de9354d7d..85ec33f6be 100644 --- a/src/NotesLoaderBMS.cpp +++ b/src/NotesLoaderBMS.cpp @@ -136,18 +136,41 @@ struct BMSObject float position; bool flag; RString value; - bool operator<(const BMSObject &other) const - { - if( measure < other.measure ) return true; - if( measure > other.measure ) return false; - if( position < other.position ) return true; - if( position > other.position ) return false; - if( channel == 1 ) return false; - if( other.channel == 1 ) return true; - return channel < other.channel; - } }; +inline bool operator<(BMSObject const &lhs, BMSObject const &rhs) +{ + if (lhs.measure != rhs.measure) + { + return lhs.measure < rhs.measure; + } + if (lhs.position != rhs.position) + { + return lhs.position < rhs.position; + } + if (lhs.channel == 1) + { + return false; + } + if (rhs.channel == 1) + { + return true; + } + return lhs.channel < rhs.channel; +} +inline bool operator>(BMSObject const &lhs, BMSObject const &rhs) +{ + return operator<(rhs, lhs); +} +inline bool operator<=(BMSObject const &lhs, BMSObject const &rhs) +{ + return !operator<(rhs, lhs); +} +inline bool operator>=(BMSObject const &lhs, BMSObject const &rhs) +{ + return !operator<(lhs, rhs); +} + struct BMSMeasure { float size; diff --git a/src/RageInputDevice.h b/src/RageInputDevice.h index 6bf4d498a9..6c29b995e3 100644 --- a/src/RageInputDevice.h +++ b/src/RageInputDevice.h @@ -66,14 +66,18 @@ struct InputDeviceInfo InputDevice id; RString sDesc; - - bool operator==( const InputDeviceInfo &other ) const - { - return id == other.id && - sDesc == other.sDesc; - } }; +inline bool operator==(InputDeviceInfo const &lhs, InputDeviceInfo const &rhs) +{ + return lhs.id == rhs.id && lhs.sDesc == rhs.sDesc; +} + +inline bool operator!=(InputDeviceInfo const &lhs, InputDeviceInfo const &rhs) +{ + return !operator==(lhs, rhs); +} + enum InputDeviceState { InputDeviceState_Connected, // has an InputHandler and controller is plugged in @@ -336,25 +340,6 @@ public: DeviceInput( InputDevice d, DeviceButton b, const RageTimer &t, int zVal=0 ): device(d), button(b), level(0), z(zVal), bDown(false), ts(t) { } - bool operator==( const DeviceInput &other ) const - { - /* Return true if we represent the same button on the same device. - * Don't compare level or ts. */ - return device == other.device && button == other.button; - } - bool operator!=( const DeviceInput &other ) const - { - return ! operator==( other ); - } - bool operator<( const DeviceInput &other ) const - { - /* Return true if we represent the same button on the same device. - * Don't compare level or ts. */ - if( device != other.device ) - return device < other.device; - return button < other.button; - } - RString ToString() const; bool FromString( const RString &s ); @@ -365,6 +350,40 @@ public: bool IsMouse() const { return ::IsMouse(device); } }; +inline bool operator==(DeviceInput const &lhs, DeviceInput const &rhs) +{ + /* Return true if we represent the same button on the same device. + * Don't compare level or ts. */ + return lhs.device == rhs.device && + lhs.button == rhs.button; +} +inline bool operator!=(DeviceInput const &lhs, DeviceInput const &rhs) +{ + return !operator==(lhs, rhs); +} + +inline bool operator<(DeviceInput const &lhs, DeviceInput const &rhs) +{ + /* Only the devices and buttons matter here. */ + if ( lhs.device != rhs.device) + { + return lhs.device < rhs.device; + } + return lhs.button < rhs.button; +} +inline bool operator>(DeviceInput const &lhs, DeviceInput const &rhs) +{ + return operator<(rhs, lhs); +} +inline bool operator<=(DeviceInput const &lhs, DeviceInput const &rhs) +{ + return !operator<(rhs, lhs); +} +inline bool operator>=(DeviceInput const &lhs, DeviceInput const &rhs) +{ + return !operator<(lhs, rhs); +} + typedef vector DeviceInputList; #endif diff --git a/src/RageSurface.cpp b/src/RageSurface.cpp index b765797556..70cecbb133 100644 --- a/src/RageSurface.cpp +++ b/src/RageSurface.cpp @@ -4,10 +4,6 @@ #include -bool RageSurfaceColor::operator== ( const RageSurfaceColor &rhs ) const -{ - return rhs.r == r && rhs.g == g && rhs.b == b && rhs.a == a; -} int32_t RageSurfacePalette::FindColor( const RageSurfaceColor &color ) const { diff --git a/src/RageSurface.h b/src/RageSurface.h index f49fa829cb..7d95f35ffb 100644 --- a/src/RageSurface.h +++ b/src/RageSurface.h @@ -10,10 +10,22 @@ struct RageSurfaceColor RageSurfaceColor(): r(0), g(0), b(0), a(0) { } RageSurfaceColor( uint8_t r_, uint8_t g_, uint8_t b_, uint8_t a_ ): r(r_), g(g_), b(b_), a(a_) { } - - bool operator== ( const RageSurfaceColor &rhs ) const; }; +inline bool operator==(RageSurfaceColor const &lhs, RageSurfaceColor const &rhs) +{ + return + lhs.r == rhs.r && + lhs.g == rhs.g && + lhs.b == rhs.b && + lhs.a == rhs.a; +} + +inline bool operator!=(RageSurfaceColor const &lhs, RageSurfaceColor const &rhs) +{ + return !operator==(lhs, rhs); +} + struct RageSurfacePalette { RageSurfaceColor colors[256]; diff --git a/src/RageTextureID.cpp b/src/RageTextureID.cpp index 0cd65603db..2757384f2c 100644 --- a/src/RageTextureID.cpp +++ b/src/RageTextureID.cpp @@ -17,41 +17,6 @@ void RageTextureID::Init() Policy = TEXTUREMAN->GetDefaultTexturePolicy(); } -bool RageTextureID::operator<(const RageTextureID &rhs) const -{ -#define COMP(a) if(arhs.a) return false; - COMP(filename); - COMP(iMaxSize); - COMP(bMipMaps); - COMP(iAlphaBits); - COMP(iGrayscaleBits); - COMP(iColorDepth); - COMP(bDither); - COMP(bStretch); - COMP(bHotPinkColorKey); - COMP(AdditionalTextureHints); - // COMP(Policy); // don't do this -#undef COMP - return false; -} - -bool RageTextureID::operator==(const RageTextureID &rhs) const -{ -#define EQUAL(a) (a==rhs.a) - return - EQUAL(filename) && - EQUAL(iMaxSize) && - EQUAL(bMipMaps) && - EQUAL(iAlphaBits) && - EQUAL(iGrayscaleBits) && - EQUAL(iColorDepth) && - EQUAL(bDither) && - EQUAL(bStretch) && - EQUAL(bHotPinkColorKey) && - EQUAL(AdditionalTextureHints); - // EQUAL(Policy); // don't do this -} - void RageTextureID::SetFilename( const RString &fn ) { filename = fn; diff --git a/src/RageTextureID.h b/src/RageTextureID.h index 8ed3d6acca..58679d3e8c 100644 --- a/src/RageTextureID.h +++ b/src/RageTextureID.h @@ -48,9 +48,6 @@ struct RageTextureID // These hints will be used in addition to any in the filename. RString AdditionalTextureHints; - bool operator< (const RageTextureID &rhs) const; - bool operator== (const RageTextureID &rhs) const; - /* Used by RageTextureManager. Order is important; see RageTextureManager.cpp. * Note that this property is not considered for ordering/equality. Loading * a texture with a different loading policy will reuse the same texture with @@ -71,6 +68,60 @@ struct RageTextureID void SetFilename( const RString &fn ); }; +inline bool operator==(RageTextureID const &lhs, RageTextureID const &rhs) +{ +#define EQUAL(a) (lhs.a==rhs.a) + return + EQUAL(filename) && + EQUAL(iMaxSize) && + EQUAL(bMipMaps) && + EQUAL(iAlphaBits) && + EQUAL(iGrayscaleBits) && + EQUAL(iColorDepth) && + EQUAL(bDither) && + EQUAL(bStretch) && + EQUAL(bHotPinkColorKey) && + EQUAL(AdditionalTextureHints); + // EQUAL(Policy); // don't do this +#undef EQUAL +} + +inline bool operator!=(RageTextureID const &lhs, RageTextureID const &rhs) +{ + return !operator==(lhs, rhs); +} + +inline bool operator<(RageTextureID const &lhs, RageTextureID const &rhs) +{ +#define COMP(a) if(lhs.arhs.a) return false; + COMP(filename); + COMP(iMaxSize); + COMP(bMipMaps); + COMP(iAlphaBits); + COMP(iGrayscaleBits); + COMP(iColorDepth); + COMP(bDither); + COMP(bStretch); + COMP(bHotPinkColorKey); + COMP(AdditionalTextureHints); + // COMP(Policy); // don't do this +#undef COMP + return false; +} + +inline bool operator>(RageTextureID const &lhs, RageTextureID const &rhs) +{ + return operator<(rhs, lhs); +} +inline bool operator<=(RageTextureID const &lhs, RageTextureID const &rhs) +{ + return !operator<(rhs, lhs); +} +inline bool operator>=(RageTextureID const &lhs, RageTextureID const &rhs) +{ + return !operator<(lhs, rhs); +} + #endif /* diff --git a/src/RageUtil_FileDB.h b/src/RageUtil_FileDB.h index 90449d7086..196a4d1fc9 100644 --- a/src/RageUtil_FileDB.h +++ b/src/RageUtil_FileDB.h @@ -40,7 +40,6 @@ struct File dir=false; size=-1; hash=-1; priv=NULL; dirp=NULL; } - bool operator== (const File &rhs) const { return lname==rhs.lname; } bool operator< (const File &rhs) const { return lname v; diff --git a/src/ScreenOptionsMasterPrefs.cpp b/src/ScreenOptionsMasterPrefs.cpp index 4b50face7d..045e8fb777 100644 --- a/src/ScreenOptionsMasterPrefs.cpp +++ b/src/ScreenOptionsMasterPrefs.cpp @@ -514,22 +514,45 @@ struct res_t int w, h; res_t(): w(0), h(0) { } res_t( int w_, int h_ ): w(w_), h(h_) { } - res_t operator-( const res_t &rhs ) const - { - return res_t( w-rhs.w, h-rhs.h ); - } - - bool operator<( const res_t &rhs ) const - { - if( w != rhs.w ) - return w < rhs.w; - return h < rhs.h; + + res_t& operator-=( res_t const &rhs) { + w -= rhs.w; + h -= rhs.h; + return *this; } // Ugly: allow convert to a float for FindClosestEntry. operator float() const { return w * 5000.0f + h; } }; +inline bool operator<(res_t const &lhs, res_t const &rhs) +{ + if( lhs.w != rhs.w ) + { + return lhs.w < rhs.w; + + } + return lhs.h < rhs.h; +} +inline bool operator>(res_t const &lhs, res_t const &rhs) +{ + return operator<(rhs, lhs); +} +inline bool operator<=(res_t const &lhs, res_t const &rhs) +{ + return !operator<(rhs, lhs); +} +inline bool operator>=(res_t const &lhs, res_t const &rhs) +{ + return !operator<(lhs, rhs); +} + +inline res_t operator-(res_t lhs, res_t const &rhs) +{ + lhs -= rhs; + return lhs; +} + static void DisplayResolutionM( int &sel, bool ToSel, const ConfOption *pConfOption ) { vector v;