From 2ac8a1afd1aaa0d745531d097c9ad93422e67796 Mon Sep 17 00:00:00 2001 From: Johnny Date: Wed, 4 Dec 2024 14:52:59 +0800 Subject: [PATCH 1/2] update c++11 lambda for CAPropertyAddressList --- BGMApp/PublicUtility/CAPropertyAddress.h | 32 +++--------------------- 1 file changed, 3 insertions(+), 29 deletions(-) diff --git a/BGMApp/PublicUtility/CAPropertyAddress.h b/BGMApp/PublicUtility/CAPropertyAddress.h index c311214..1d82d7b 100644 --- a/BGMApp/PublicUtility/CAPropertyAddress.h +++ b/BGMApp/PublicUtility/CAPropertyAddress.h @@ -98,32 +98,6 @@ struct CAPropertyAddress static bool IsCongruentElement(AudioObjectPropertyElement inElement1, AudioObjectPropertyElement inElement2) { return (inElement1 == inElement2) || (inElement1 == kAudioObjectPropertyElementWildcard) || (inElement2 == kAudioObjectPropertyElementWildcard); } static bool IsCongruentAddress(const AudioObjectPropertyAddress& inAddress1, const AudioObjectPropertyAddress& inAddress2) { return IsCongruentScope(inAddress1.mScope, inAddress2.mScope) && IsCongruentSelector(inAddress1.mSelector, inAddress2.mSelector) && IsCongruentElement(inAddress1.mElement, inAddress2.mElement); } static bool IsCongruentLessThanAddress(const AudioObjectPropertyAddress& inAddress1, const AudioObjectPropertyAddress& inAddress2) { bool theAnswer = false; if(!IsCongruentScope(inAddress1.mScope, inAddress2.mScope)) { theAnswer = inAddress1.mScope < inAddress2.mScope; } else if(!IsCongruentSelector(inAddress1.mSelector, inAddress2.mSelector)) { theAnswer = inAddress1.mSelector < inAddress2.mSelector; } else if(!IsCongruentElement(inAddress1.mElement, inAddress2.mElement)) { theAnswer = inAddress1.mElement < inAddress2.mElement; } return theAnswer; } - -// STL Helpers -public: -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated" - struct EqualTo : public std::binary_function - { - bool operator()(const AudioObjectPropertyAddress& inAddress1, const AudioObjectPropertyAddress& inAddress2) const { return IsSameAddress(inAddress1, inAddress2); } - }; - - struct LessThan : public std::binary_function - { - bool operator()(const AudioObjectPropertyAddress& inAddress1, const AudioObjectPropertyAddress& inAddress2) const { return IsLessThanAddress(inAddress1, inAddress2); } - }; - - struct CongruentEqualTo : public std::binary_function - { - bool operator()(const AudioObjectPropertyAddress& inAddress1, const AudioObjectPropertyAddress& inAddress2) const { return IsCongruentAddress(inAddress1, inAddress2); } - }; - - struct CongruentLessThan : public std::binary_function - { - bool operator()(const AudioObjectPropertyAddress& inAddress1, const AudioObjectPropertyAddress& inAddress2) const { return IsCongruentLessThanAddress(inAddress1, inAddress2); } - }; -#pragma clang diagnostic pop - }; //================================================================================================== @@ -162,8 +136,8 @@ class CAPropertyAddressList #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated" - bool HasItem(const AudioObjectPropertyAddress& inAddress) const { AddressList::const_iterator theIterator = std::find_if(mAddressList.begin(), mAddressList.end(), std::bind1st(CAPropertyAddress::CongruentEqualTo(), inAddress)); return theIterator != mAddressList.end(); } - bool HasExactItem(const AudioObjectPropertyAddress& inAddress) const { AddressList::const_iterator theIterator = std::find_if(mAddressList.begin(), mAddressList.end(), std::bind1st(CAPropertyAddress::EqualTo(), inAddress)); return theIterator != mAddressList.end(); } + bool HasItem(const AudioObjectPropertyAddress& inAddress) const { AddressList::const_iterator theIterator = std::find_if(mAddressList.begin(), mAddressList.end(), [&inAddress](const CAPropertyAddress& addr) { return CAPropertyAddress::IsCongruentAddress(addr, inAddress); }); return theIterator != mAddressList.end(); } + bool HasExactItem(const AudioObjectPropertyAddress& inAddress) const { AddressList::const_iterator theIterator = std::find_if(mAddressList.begin(), mAddressList.end(), [&inAddress](const CAPropertyAddress& addr) { return CAPropertyAddress::IsSameAddress(addr, inAddress); }); return theIterator != mAddressList.end(); } #pragma clang diagnostic pop void AppendItem(const AudioObjectPropertyAddress& inAddress) { mAddressList.push_back(inAddress); } @@ -172,7 +146,7 @@ class CAPropertyAddressList void InsertItemAtIndex(UInt32 inIndex, const AudioObjectPropertyAddress& inAddress) { if(inIndex < mAddressList.size()) { AddressList::iterator theIterator = mAddressList.begin(); std::advance(theIterator, static_cast(inIndex)); mAddressList.insert(theIterator, inAddress); } else { mAddressList.push_back(inAddress); } } #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated" - void EraseExactItem(const AudioObjectPropertyAddress& inAddress) { AddressList::iterator theIterator = std::find_if(mAddressList.begin(), mAddressList.end(), std::bind1st(CAPropertyAddress::EqualTo(), inAddress)); if(theIterator != mAddressList.end()) { mAddressList.erase(theIterator); } } + void EraseExactItem(const AudioObjectPropertyAddress& inAddress) { AddressList::iterator theIterator = std::find_if(mAddressList.begin(), mAddressList.end(), [&inAddress](const CAPropertyAddress& addr) { return CAPropertyAddress::IsSameAddress(addr, inAddress); }); if(theIterator != mAddressList.end()) { mAddressList.erase(theIterator); } } #pragma clang diagnostic pop void EraseItemAtIndex(UInt32 inIndex) { if(inIndex < mAddressList.size()) { AddressList::iterator theIterator = mAddressList.begin(); std::advance(theIterator, static_cast(inIndex)); mAddressList.erase(theIterator); } } void EraseAllItems() { mAddressList.clear(); } From 029cb2f5f8b0fb6a47fa7d14e9e8169c3f282dff Mon Sep 17 00:00:00 2001 From: Johnny Date: Sun, 8 Dec 2024 15:15:57 +0800 Subject: [PATCH 2/2] remove part of `#pragma clang diagnostic ignored "-Wdeprecated"`. --- BGMApp/PublicUtility/CAPropertyAddress.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/BGMApp/PublicUtility/CAPropertyAddress.h b/BGMApp/PublicUtility/CAPropertyAddress.h index 1d82d7b..d97f26b 100644 --- a/BGMApp/PublicUtility/CAPropertyAddress.h +++ b/BGMApp/PublicUtility/CAPropertyAddress.h @@ -134,11 +134,8 @@ class CAPropertyAddressList const AudioObjectPropertyAddress* GetItems() const { return &(*mAddressList.begin()); } AudioObjectPropertyAddress* GetItems() { return &(*mAddressList.begin()); } -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated" bool HasItem(const AudioObjectPropertyAddress& inAddress) const { AddressList::const_iterator theIterator = std::find_if(mAddressList.begin(), mAddressList.end(), [&inAddress](const CAPropertyAddress& addr) { return CAPropertyAddress::IsCongruentAddress(addr, inAddress); }); return theIterator != mAddressList.end(); } bool HasExactItem(const AudioObjectPropertyAddress& inAddress) const { AddressList::const_iterator theIterator = std::find_if(mAddressList.begin(), mAddressList.end(), [&inAddress](const CAPropertyAddress& addr) { return CAPropertyAddress::IsSameAddress(addr, inAddress); }); return theIterator != mAddressList.end(); } -#pragma clang diagnostic pop void AppendItem(const AudioObjectPropertyAddress& inAddress) { mAddressList.push_back(inAddress); } void AppendUniqueItem(const AudioObjectPropertyAddress& inAddress) { if(!HasItem(inAddress)) { mAddressList.push_back(inAddress); } }