Added release type in scanner + UI (detailed view only)

This commit is contained in:
emeric
2023-04-16 15:00:04 +02:00
parent 52406e7e4b
commit 1d41a26ead
21 changed files with 443 additions and 35 deletions
+32 -12
View File
@@ -31,9 +31,11 @@ class EnumSet
static_assert(std::is_enum<T>::value);
static_assert(std::is_same<underlying_type, std::uint64_t>::value || std::is_same<underlying_type, std::uint32_t>::value);
using index_type = std::uint_fast8_t;
using IndexType = std::uint_fast8_t;
public:
using ValueType = underlying_type;
EnumSet() = default;
constexpr EnumSet(std::initializer_list<T> values)
{
@@ -112,14 +114,14 @@ class EnumSet
private:
friend class EnumSet;
constexpr iterator(const EnumSet& _container, index_type _index)
constexpr iterator(const EnumSet& _container, IndexType _index)
: _container {_container}
, _index {_index}
{
}
const EnumSet& _container;
index_type _index;
IndexType _index;
};
constexpr iterator begin() const
@@ -132,25 +134,45 @@ class EnumSet
return iterator {*this, npos};
}
private:
static_assert(std::numeric_limits<index_type>::max() >= sizeof(underlying_type) * 8);
enum : index_type { npos = sizeof(underlying_type) * 8 };
constexpr underlying_type getBitfield() const
{
return _bitfield;
}
constexpr index_type getFirstBitSetIndex(index_type start = {}) const
constexpr void setBitfield(underlying_type bitfield)
{
_bitfield = bitfield;
}
constexpr bool operator==(const EnumSet other) const
{
return _bitfield == other._bitfield;
}
constexpr bool operator!=(const EnumSet other) const
{
return _bitfield != other._bitfield;
}
private:
static_assert(std::numeric_limits<IndexType>::max() >= sizeof(underlying_type) * 8);
enum : IndexType { npos = sizeof(underlying_type) * 8 };
constexpr IndexType getFirstBitSetIndex(IndexType start = {}) const
{
assert(start < npos);
// return npos if no bit found
index_type res {countTrailingZero(_bitfield >> start)};
IndexType res {countTrailingZero(_bitfield >> start)};
if (res == npos)
return res;
return res + start;
}
static constexpr index_type countTrailingZero(underlying_type bitField)
static constexpr IndexType countTrailingZero(underlying_type bitField)
{
index_type res {};
IndexType res {};
while (res < (sizeof(underlying_type) * 8) && (bitField & 1) == 0)
{
@@ -166,5 +188,3 @@ class EnumSet
underlying_type _bitfield{};
};
+2 -1
View File
@@ -1,8 +1,9 @@
include(GoogleTest)
add_executable(test-utils
String.cpp
EnumSet.cpp
RecursiveSharedMutex.cpp
String.cpp
Utils.cpp
)
+60
View File
@@ -0,0 +1,60 @@
/*
* Copyright (C) 2019 Emeric Poupon
*
* This file is part of LMS.
*
* LMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/
#include <gtest/gtest.h>
#include "utils/EnumSet.hpp"
TEST(EnumSet, ctr)
{
enum class Foo
{
One,
Two,
};
{
constexpr EnumSet<Foo> test {Foo::One};
static_assert(!test.empty());
static_assert(test.contains(Foo::One));
static_assert(!test.contains(Foo::Two));
EXPECT_TRUE(!test.empty());
EXPECT_TRUE(test.contains(Foo::One));
EXPECT_FALSE(test.contains(Foo::Two));
static_assert(test.getBitfield() != 0);
}
{
constexpr EnumSet<Foo> test {Foo::One, Foo::Two};
constexpr auto bitfield {test.getBitfield()};
EnumSet<Foo> test2;
EXPECT_FALSE(test2.contains(Foo::One));
EXPECT_FALSE(test2.contains(Foo::Two));
test2.setBitfield(bitfield);
EXPECT_TRUE(test2.contains(Foo::One));
EXPECT_TRUE(test2.contains(Foo::Two));
EXPECT_EQ(test, test2);
}
}