Apply clang-format

This commit is contained in:
Martchus 2022-05-31 20:03:09 +02:00
parent ecebf9fbde
commit f2902f1d08
8 changed files with 43 additions and 36 deletions

View File

@ -100,9 +100,8 @@ static void printPackageSearchResults(const LibRepoMgr::WebClient::Response::bod
t.add_row({ "Arch", "Repo", "Name", "Version", "Description", "Build date" });
for (const auto &[db, package, packageID] : packages) {
const auto &dbInfo = std::get<LibPkg::DatabaseInfo>(db);
t.add_row(
{ package->packageInfo ? package->arch : dbInfo.arch, dbInfo.name, package->name, package->version, package->description,
package->packageInfo && !package->buildDate.isNull() ? package->packageInfo->buildDate.toString() : "?" });
t.add_row({ package->packageInfo ? package->arch : dbInfo.arch, dbInfo.name, package->name, package->version, package->description,
package->packageInfo && !package->buildDate.isNull() ? package->packageInfo->buildDate.toString() : "?" });
}
t.row(0).format().font_align(tabulate::FontAlign::center).font_style({ tabulate::FontStyle::bold });
configureColumnWidths(t);

View File

@ -240,8 +240,9 @@ void Config::packagesByName(const DatabaseVisitor &databaseVisitor, const Packag
if (databaseVisitor && databaseVisitor(db)) {
continue;
}
db.allPackagesByName(
[&](std::string_view packageName, const std::function<StorageID(PackageBase&)> &getPackage) { return visitor(db, packageName, getPackage); });
db.allPackagesByName([&](std::string_view packageName, const std::function<StorageID(PackageBase &)> &getPackage) {
return visitor(db, packageName, getPackage);
});
}
}
@ -258,7 +259,8 @@ void Config::providingPackages(const Dependency &dependency, bool reverse, const
}
}
void Config::providingPackagesBase(const Dependency &dependency, bool reverse, const DatabaseVisitor &databaseVisitor, const PackageVisitorBase &visitor)
void Config::providingPackagesBase(
const Dependency &dependency, bool reverse, const DatabaseVisitor &databaseVisitor, const PackageVisitorBase &visitor)
{
for (auto &db : databases) {
if (databaseVisitor && databaseVisitor(db)) {

View File

@ -107,12 +107,13 @@ constexpr bool operator&(BuildOrderOptions lhs, BuildOrderOptions rhs)
struct LIBPKG_EXPORT Config : public Lockable, public ReflectiveRapidJSON::BinarySerializable<Config> {
using DatabaseVisitor = std::function<bool(Database &)>;
using PackageVisitorBase = std::function<bool(Database &, StorageID, std::shared_ptr<PackageBase> &&)>; // package is invalidated/reused unless moved from!!!
using PackageVisitorBase
= std::function<bool(Database &, StorageID, std::shared_ptr<PackageBase> &&)>; // package is invalidated/reused unless moved from!!!
using PackageVisitorMove
= std::function<bool(Database &, StorageID, std::shared_ptr<Package> &&)>; // package is invalidated/reused unless moved from!!!
using PackageVisitorConst = std::function<bool(Database &, StorageID, const std::shared_ptr<Package> &)>;
using PackageVisitorByName = std::function<bool(Database &, std::string_view, const std::function<PackageSpec(void)> &)>;
using PackageVisitorByNameBase = std::function<bool(Database &, std::string_view, const std::function<StorageID(PackageBase&)> &)>;
using PackageVisitorByNameBase = std::function<bool(Database &, std::string_view, const std::function<StorageID(PackageBase &)> &)>;
explicit Config();
~Config();
@ -173,7 +174,8 @@ struct LIBPKG_EXPORT Config : public Lockable, public ReflectiveRapidJSON::Binar
void providingPackages(const Dependency &dependency, bool reverse, const DatabaseVisitor &databaseVisitor, const PackageVisitorConst &visitor);
void providingPackagesBase(const Dependency &dependency, bool reverse, const DatabaseVisitor &databaseVisitor, const PackageVisitorBase &visitor);
void providingPackages(const std::string &libraryName, bool reverse, const DatabaseVisitor &databaseVisitor, const PackageVisitorConst &visitor);
void providingPackagesBase(const std::string &libraryName, bool reverse, const DatabaseVisitor &databaseVisitor, const PackageVisitorBase &visitor);
void providingPackagesBase(
const std::string &libraryName, bool reverse, const DatabaseVisitor &databaseVisitor, const PackageVisitorBase &visitor);
std::vector<Database> databases;
Database aur = Database("aur");

View File

@ -325,7 +325,7 @@ void LibPkg::Database::allPackagesByName(const PackageVisitorByNameBase &visitor
auto txn = m_storage->packages.getROTransaction();
for (auto i = txn.begin_idx<0, std::shared_ptr>(); i != txn.end(); ++i) {
const auto packageName = i.getKey().get<string_view>();
if (visitor(packageName, [&txn, &i] (PackageBase &pkg) { return txn.get(i.value(), pkg); })) {
if (visitor(packageName, [&txn, &i](PackageBase &pkg) { return txn.get(i.value(), pkg); })) {
return;
}
}
@ -377,8 +377,7 @@ void Database::providingPackagesBase(const Dependency &dependency, bool reverse,
package = std::make_shared<PackageBase>();
} else {
package->clear();
}
;
};
if (packagesTxn.get<PackageBase>(packageID, *package) && visitor(packageID, std::move(package))) {
return;
}

View File

@ -149,7 +149,7 @@ struct LIBPKG_EXPORT Database : public ReflectiveRapidJSON::JsonSerializable<Dat
using PackageVisitorMove = std::function<bool(StorageID, std::shared_ptr<Package> &&)>; // package is invalidated/reused unless moved from!!!
using PackageVisitorConst = std::function<bool(StorageID, const std::shared_ptr<Package> &)>;
using PackageVisitorByName = std::function<bool(std::string_view, const std::function<PackageSpec(void)> &)>;
using PackageVisitorByNameBase = std::function<bool(std::string_view, const std::function<StorageID(PackageBase&)> &)>;
using PackageVisitorByNameBase = std::function<bool(std::string_view, const std::function<StorageID(PackageBase &)> &)>;
friend struct PackageUpdater;

View File

@ -571,8 +571,8 @@ static void internalPush(
}
template <typename PackageSpecType, Traits::EnableIf<Traits::IsSpecializationOf<PackageSpecType, LibPkg::GenericPackageSpec>> * = nullptr>
static void internalPull(
PackageSpecType &reflectable, const ::RAPIDJSON_NAMESPACE::GenericValue<::RAPIDJSON_NAMESPACE::UTF8<char>>::ConstObject &value, JsonDeserializationErrors *errors)
static void internalPull(PackageSpecType &reflectable,
const ::RAPIDJSON_NAMESPACE::GenericValue<::RAPIDJSON_NAMESPACE::UTF8<char>>::ConstObject &value, JsonDeserializationErrors *errors)
{
// find member
if (const auto pkg = value.FindMember("pkg"); pkg != value.MemberEnd()) {
@ -588,19 +588,20 @@ static void internalPull(
}
template <>
LIBPKG_EXPORT void push<LibPkg::PackageSpec>(const LibPkg::PackageSpec &reflectable, ::RAPIDJSON_NAMESPACE::Value::Object &value, RAPIDJSON_NAMESPACE::Document::AllocatorType &allocator)
LIBPKG_EXPORT void push<LibPkg::PackageSpec>(
const LibPkg::PackageSpec &reflectable, ::RAPIDJSON_NAMESPACE::Value::Object &value, RAPIDJSON_NAMESPACE::Document::AllocatorType &allocator)
{
internalPush(reflectable, value, allocator);
}
template <>
LIBPKG_EXPORT void push<LibPkg::GenericPackageSpec<LibPkg::PackageBase>>(const LibPkg::GenericPackageSpec<LibPkg::PackageBase> &reflectable, ::RAPIDJSON_NAMESPACE::Value::Object &value,
RAPIDJSON_NAMESPACE::Document::AllocatorType &allocator)
LIBPKG_EXPORT void push<LibPkg::GenericPackageSpec<LibPkg::PackageBase>>(const LibPkg::GenericPackageSpec<LibPkg::PackageBase> &reflectable,
::RAPIDJSON_NAMESPACE::Value::Object &value, RAPIDJSON_NAMESPACE::Document::AllocatorType &allocator)
{
internalPush(reflectable, value, allocator);
}
template <>
LIBPKG_EXPORT void pull<LibPkg::PackageSpec>(LibPkg::PackageSpec &reflectable,const ::RAPIDJSON_NAMESPACE::GenericValue<::RAPIDJSON_NAMESPACE::UTF8<char>>::ConstObject &value,
JsonDeserializationErrors *errors)
LIBPKG_EXPORT void pull<LibPkg::PackageSpec>(LibPkg::PackageSpec &reflectable,
const ::RAPIDJSON_NAMESPACE::GenericValue<::RAPIDJSON_NAMESPACE::UTF8<char>>::ConstObject &value, JsonDeserializationErrors *errors)
{
internalPull(reflectable, value, errors);
}
@ -643,13 +644,15 @@ void internalWriteCustomType(BinarySerializer &serializer, const PackageSpecType
}
template <>
LIBPKG_EXPORT BinaryVersion readCustomType<LibPkg::PackageSpec>(BinaryDeserializer &deserializer, LibPkg::PackageSpec &reflectable, BinaryVersion version)
LIBPKG_EXPORT BinaryVersion readCustomType<LibPkg::PackageSpec>(
BinaryDeserializer &deserializer, LibPkg::PackageSpec &reflectable, BinaryVersion version)
{
return internalReadCustomType(deserializer, reflectable, version);
}
template <>
LIBPKG_EXPORT BinaryVersion readCustomType<LibPkg::GenericPackageSpec<LibPkg::PackageBase>>(BinaryDeserializer &deserializer, LibPkg::GenericPackageSpec<LibPkg::PackageBase> &reflectable, BinaryVersion version)
LIBPKG_EXPORT BinaryVersion readCustomType<LibPkg::GenericPackageSpec<LibPkg::PackageBase>>(
BinaryDeserializer &deserializer, LibPkg::GenericPackageSpec<LibPkg::PackageBase> &reflectable, BinaryVersion version)
{
return internalReadCustomType(deserializer, reflectable, version);
}
@ -661,7 +664,8 @@ LIBPKG_EXPORT void writeCustomType<LibPkg::PackageSpec>(BinarySerializer &serial
}
template <>
LIBPKG_EXPORT void writeCustomType<LibPkg::GenericPackageSpec<LibPkg::PackageBase>>(BinarySerializer &serializer, const LibPkg::GenericPackageSpec<LibPkg::PackageBase> &reflectable, BinaryVersion version)
LIBPKG_EXPORT void writeCustomType<LibPkg::GenericPackageSpec<LibPkg::PackageBase>>(
BinarySerializer &serializer, const LibPkg::GenericPackageSpec<LibPkg::PackageBase> &reflectable, BinaryVersion version)
{
internalWriteCustomType(serializer, reflectable, version);
}

View File

@ -27,8 +27,7 @@ void UpdateCheck::run()
if (m_fromAur && !m_packageLookupDone
&& WebClient::queryAurPackagesForDatabase(m_buildAction->log(), m_setup, m_setup.building.ioContext,
&std::get<std::shared_lock<std::shared_mutex>>(configReadLock), **m_destinationDbs.begin(),
[this](std::vector<LibPkg::PackageSpec> &&) {
&std::get<std::shared_lock<std::shared_mutex>>(configReadLock), **m_destinationDbs.begin(), [this](std::vector<LibPkg::PackageSpec> &&) {
m_packageLookupDone = true;
run();
})) {

View File

@ -227,18 +227,20 @@ void getPackages(const Params &params, ResponseHandler &&handler)
const auto dbIterator = dbs.find(db.name);
return dbIterator == dbs.end() || dbIterator->second.find(db.arch) == dbIterator->second.end();
});
const auto pushSharedBasePackage = LibPkg::Config::PackageVisitorBase([&array, &document, &limit](Database &db, LibPkg::StorageID id, const std::shared_ptr<PackageBase> &pkg) {
ReflectiveRapidJSON::JsonReflector::push(LibPkg::PackageBaseSearchResult(db, *pkg, id), array, document.GetAllocator());
return array.Size() >= limit;
});
const auto pushSharedBasePackage = LibPkg::Config::PackageVisitorBase(
[&array, &document, &limit](Database &db, LibPkg::StorageID id, const std::shared_ptr<PackageBase> &pkg) {
ReflectiveRapidJSON::JsonReflector::push(LibPkg::PackageBaseSearchResult(db, *pkg, id), array, document.GetAllocator());
return array.Size() >= limit;
});
const auto pushBasePackage = [&array, &document, &limit](Database &db, LibPkg::StorageID id, const PackageBase &pkg) {
ReflectiveRapidJSON::JsonReflector::push(LibPkg::PackageBaseSearchResult(db, pkg, id), array, document.GetAllocator());
return array.Size() >= limit;
};
const auto pushPackageDetails = !details ? LibPkg::Config::PackageVisitorConst() : [&array, &document, &limit](Database &, LibPkg::StorageID, const std::shared_ptr<Package> &pkg) {
ReflectiveRapidJSON::JsonReflector::push(pkg, array, document.GetAllocator());
ReflectiveRapidJSON::JsonReflector::push(LibPkg::PackageBaseSearchResult(db, pkg, id), array, document.GetAllocator());
return array.Size() >= limit;
};
const auto pushPackageDetails = !details ? LibPkg::Config::PackageVisitorConst()
: [&array, &document, &limit](Database &, LibPkg::StorageID, const std::shared_ptr<Package> &pkg) {
ReflectiveRapidJSON::JsonReflector::push(pkg, array, document.GetAllocator());
return array.Size() >= limit;
};
auto aurPackages = std::vector<PackageSearchResult>();
auto neededAurPackages = std::vector<std::string>();
@ -275,7 +277,7 @@ void getPackages(const Params &params, ResponseHandler &&handler)
case Mode::NameContains: {
auto basePackage = PackageBase();
params.setup.config.packagesByName(
visitDb, [&](LibPkg::Database &db, std::string_view packageName, const std::function<StorageID(PackageBase&)> &getPackage) {
visitDb, [&](LibPkg::Database &db, std::string_view packageName, const std::function<StorageID(PackageBase &)> &getPackage) {
if (packageName.find(name) != std::string_view::npos) {
const auto packageID = getPackage(basePackage);
if (!packageID) {
@ -299,7 +301,7 @@ void getPackages(const Params &params, ResponseHandler &&handler)
const auto regex = std::regex(name.data(), name.size());
auto basePackage = PackageBase();
params.setup.config.packagesByName(
visitDb, [&](LibPkg::Database &db, std::string_view packageName, const std::function<StorageID(PackageBase&)> &getPackage) {
visitDb, [&](LibPkg::Database &db, std::string_view packageName, const std::function<StorageID(PackageBase &)> &getPackage) {
if (std::regex_match(packageName.begin(), packageName.end(), regex)) {
const auto packageID = getPackage(basePackage);
if (!packageID) {