diff --git a/YUViewLib/src/common/EnumMapper.h b/YUViewLib/src/common/EnumMapper.h index f2566c5ee..bad1e4c19 100644 --- a/YUViewLib/src/common/EnumMapper.h +++ b/YUViewLib/src/common/EnumMapper.h @@ -42,11 +42,11 @@ using namespace std::string_view_literals; -template struct EnumMapper +template struct EnumMapper { public: - using ValueNamePair = std::pair; - using ItemArray = std::array; + using ValueNamePair = std::pair; + using ItemArray = std::array; using ItemIterator = typename ItemArray::const_iterator; using NameArray = std::array; using NameIterator = typename NameArray::const_iterator; @@ -103,7 +103,7 @@ template struct EnumMapper constexpr std::size_t size() const { return N; } - constexpr std::string_view getName(const T value) const + constexpr std::string_view getName(const ValueType value) const { const auto it = std::find(this->items.begin(), this->items.end(), value); if (it == this->items.end()) @@ -113,7 +113,7 @@ template struct EnumMapper return this->names.at(index); } - constexpr std::optional getValue(const std::string_view name) const + constexpr std::optional getValue(const std::string_view name) const { const auto it = std::find_if(this->begin(), @@ -125,7 +125,7 @@ template struct EnumMapper return it->first; } - constexpr std::optional getValueCaseInsensitive(const std::string_view name) const + constexpr std::optional getValueCaseInsensitive(const std::string_view name) const { const auto compareToNameLowercase = [&name](const std::string_view str) { @@ -147,7 +147,7 @@ template struct EnumMapper return this->items.at(index); } - std::optional getValueFromNameOrIndex(const std::string_view nameOrIndex) const + std::optional getValueFromNameOrIndex(const std::string_view nameOrIndex) const { if (auto index = functions::toUnsigned(nameOrIndex)) if (*index < N) @@ -156,7 +156,7 @@ template struct EnumMapper return this->getValue(nameOrIndex); } - constexpr size_t indexOf(const T value) const + constexpr size_t indexOf(const ValueType value) const { const auto it = std::find(this->items.begin(), this->items.end(), value); if (it == this->items.end()) @@ -167,23 +167,23 @@ template struct EnumMapper return index; } - constexpr std::optional at(const size_t index) const + constexpr std::optional at(const size_t index) const { if (index >= N) return {}; return this->items.at(index); } - constexpr const ItemArray &getItems() const { return this->items; } + constexpr const ItemArray &getValues() const { return this->items; } constexpr const NameArray &getNames() const { return this->names; } private: constexpr void addElementsRecursively(const std::size_t) {}; - template - constexpr void addElementsRecursively(const std::size_t index, TArg first, Args... args) + template + constexpr void addElementsRecursively(const std::size_t index, ArgumentType first, Args... args) { - static_assert(std::is_same()); + static_assert(std::is_same()); const auto [value, name] = first; this->items[index] = value; diff --git a/YUViewLib/src/video/yuv/videoHandlerYUV.cpp b/YUViewLib/src/video/yuv/videoHandlerYUV.cpp index e5e1c7833..3079de8e3 100644 --- a/YUViewLib/src/video/yuv/videoHandlerYUV.cpp +++ b/YUViewLib/src/video/yuv/videoHandlerYUV.cpp @@ -3333,7 +3333,7 @@ void videoHandlerYUV::setFormatFromCorrelation(const QByteArray &rawYUVData, int { int bits = (b == 0) ? 8 : (b == 1) ? 10 : 16; // Test all subsampling modes - for (const auto &subsampling : SubsamplingMapper.getItems()) + for (const auto &subsampling : SubsamplingMapper.getValues()) for (const auto &size : testSizes) formatList.push_back( testFormatAndSize(size, PixelFormatYUV(subsampling, bits, PlaneOrder::YUV))); diff --git a/YUViewUnitTest/common/EnumMapperTest.cpp b/YUViewUnitTest/common/EnumMapperTest.cpp index 97f05f469..7810e3ba3 100644 --- a/YUViewUnitTest/common/EnumMapperTest.cpp +++ b/YUViewUnitTest/common/EnumMapperTest.cpp @@ -124,9 +124,9 @@ TEST(EnumMapperTest, testAt) EXPECT_FALSE(TestEnumMapper.at(8902)); } -TEST(EnumMapperTest, testGetItems) +TEST(EnumMapperTest, testGetValues) { - ASSERT_THAT(TestEnumMapper.getItems(), + ASSERT_THAT(TestEnumMapper.getValues(), ElementsAre(TestEnum::ValueOne, TestEnum::ValueTwo, TestEnum::ValueThree)); } diff --git a/YUViewUnitTest/video/rgb/ConversionRGBTest.cpp b/YUViewUnitTest/video/rgb/ConversionRGBTest.cpp index 048d0b11b..208a49827 100644 --- a/YUViewUnitTest/video/rgb/ConversionRGBTest.cpp +++ b/YUViewUnitTest/video/rgb/ConversionRGBTest.cpp @@ -202,7 +202,7 @@ void testConversionToRGBASinglePlane(const QByteArray &sourceBuffer, const bool limitedRange, const bool) { - for (const auto channel : ChannelMapper.getItems()) + for (const auto channel : ChannelMapper.getValues()) { if (channel == Channel::Alpha && !srcPixelFormat.hasAlpha()) continue; @@ -246,11 +246,11 @@ void runTestForAllParameters(TestingFunction testingFunction) { for (const auto bitDepth : {8, 10, 12}) { - for (const auto &alphaMode : AlphaModeMapper.getItems()) + for (const auto &alphaMode : AlphaModeMapper.getValues()) { - for (const auto &dataLayout : video::DataLayoutMapper.getItems()) + for (const auto &dataLayout : video::DataLayoutMapper.getValues()) { - for (const auto &channelOrder : video::rgb::ChannelOrderMapper.getItems()) + for (const auto &channelOrder : video::rgb::ChannelOrderMapper.getValues()) { const video::rgb::PixelFormatRGB format( bitDepth, dataLayout, channelOrder, alphaMode, endianness); diff --git a/YUViewUnitTest/video/rgb/GetPixelValueTest.cpp b/YUViewUnitTest/video/rgb/GetPixelValueTest.cpp index e7c39b897..124f5dd62 100644 --- a/YUViewUnitTest/video/rgb/GetPixelValueTest.cpp +++ b/YUViewUnitTest/video/rgb/GetPixelValueTest.cpp @@ -76,15 +76,15 @@ void testGetPixelValueFromBuffer(const QByteArray &sourceBuffer, TEST(GetPixelValueTest, TestGetPixelValueFromBuffer) { - for (const auto endianness : EndianessMapper.getItems()) + for (const auto endianness : EndianessMapper.getValues()) { for (auto bitDepth : {8, 10, 12}) { - for (const auto &alphaMode : AlphaModeMapper.getItems()) + for (const auto &alphaMode : AlphaModeMapper.getValues()) { - for (const auto &dataLayout : DataLayoutMapper.getItems()) + for (const auto &dataLayout : DataLayoutMapper.getValues()) { - for (const auto &channelOrder : ChannelOrderMapper.getItems()) + for (const auto &channelOrder : ChannelOrderMapper.getValues()) { const PixelFormatRGB pixelFormat( bitDepth, dataLayout, channelOrder, alphaMode, endianness); diff --git a/YUViewUnitTest/video/rgb/PixelFormatRGBTest.cpp b/YUViewUnitTest/video/rgb/PixelFormatRGBTest.cpp index 2857d3794..4bd3e4455 100644 --- a/YUViewUnitTest/video/rgb/PixelFormatRGBTest.cpp +++ b/YUViewUnitTest/video/rgb/PixelFormatRGBTest.cpp @@ -45,10 +45,10 @@ std::vector getAllFormats() std::vector allFormats; for (int bitsPerPixel = 8; bitsPerPixel <= 16; bitsPerPixel++) - for (auto dataLayout : DataLayoutMapper.getItems()) - for (auto channelOrder : ChannelOrderMapper.getItems()) - for (auto alphaMode : AlphaModeMapper.getItems()) - for (auto endianness : EndianessMapper.getItems()) + for (auto dataLayout : DataLayoutMapper.getValues()) + for (auto channelOrder : ChannelOrderMapper.getValues()) + for (auto alphaMode : AlphaModeMapper.getValues()) + for (auto endianness : EndianessMapper.getValues()) allFormats.push_back( PixelFormatRGB(bitsPerPixel, dataLayout, channelOrder, alphaMode, endianness)); diff --git a/YUViewUnitTest/video/yuv/PixelFormatYUVTest.cpp b/YUViewUnitTest/video/yuv/PixelFormatYUVTest.cpp index a896b276c..a777de11b 100644 --- a/YUViewUnitTest/video/yuv/PixelFormatYUVTest.cpp +++ b/YUViewUnitTest/video/yuv/PixelFormatYUVTest.cpp @@ -44,7 +44,7 @@ std::vector getAllFormats() { std::vector allFormats; - for (const auto subsampling : SubsamplingMapper.getItems()) + for (const auto subsampling : SubsamplingMapper.getValues()) { for (const auto bitsPerSample : BitDepthList) { @@ -52,7 +52,7 @@ std::vector getAllFormats() (bitsPerSample > 8) ? std::vector({false, true}) : std::vector({false}); // Planar - for (const auto planeOrder : PlaneOrderMapper.getItems()) + for (const auto planeOrder : PlaneOrderMapper.getValues()) for (const auto bigEndian : endianList) allFormats.push_back(PixelFormatYUV(subsampling, bitsPerSample, planeOrder, bigEndian)); @@ -65,7 +65,7 @@ std::vector getAllFormats() } } - for (auto predefinedFormat : PredefinedPixelFormatMapper.getItems()) + for (auto predefinedFormat : PredefinedPixelFormatMapper.getValues()) allFormats.push_back(PixelFormatYUV(predefinedFormat)); return allFormats;