diff --git a/cli/main.cpp b/cli/main.cpp index c6d885a..170f2c8 100644 --- a/cli/main.cpp +++ b/cli/main.cpp @@ -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(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); diff --git a/libpkg/algo/search.cpp b/libpkg/algo/search.cpp index d854d94..7382637 100644 --- a/libpkg/algo/search.cpp +++ b/libpkg/algo/search.cpp @@ -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 &getPackage) { return visitor(db, packageName, getPackage); }); + db.allPackagesByName([&](std::string_view packageName, const std::function &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)) { diff --git a/libpkg/data/config.h b/libpkg/data/config.h index 36211b8..0473137 100644 --- a/libpkg/data/config.h +++ b/libpkg/data/config.h @@ -107,12 +107,13 @@ constexpr bool operator&(BuildOrderOptions lhs, BuildOrderOptions rhs) struct LIBPKG_EXPORT Config : public Lockable, public ReflectiveRapidJSON::BinarySerializable { using DatabaseVisitor = std::function; - using PackageVisitorBase = std::function &&)>; // package is invalidated/reused unless moved from!!! + using PackageVisitorBase + = std::function &&)>; // package is invalidated/reused unless moved from!!! using PackageVisitorMove = std::function &&)>; // package is invalidated/reused unless moved from!!! using PackageVisitorConst = std::function &)>; using PackageVisitorByName = std::function &)>; - using PackageVisitorByNameBase = std::function &)>; + using PackageVisitorByNameBase = std::function &)>; 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 databases; Database aur = Database("aur"); diff --git a/libpkg/data/database.cpp b/libpkg/data/database.cpp index f8a10f8..4c41ee2 100644 --- a/libpkg/data/database.cpp +++ b/libpkg/data/database.cpp @@ -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(); - 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(); } else { package->clear(); - } - ; + }; if (packagesTxn.get(packageID, *package) && visitor(packageID, std::move(package))) { return; } diff --git a/libpkg/data/database.h b/libpkg/data/database.h index 8ba7f1e..295cd63 100644 --- a/libpkg/data/database.h +++ b/libpkg/data/database.h @@ -149,7 +149,7 @@ struct LIBPKG_EXPORT Database : public ReflectiveRapidJSON::JsonSerializable &&)>; // package is invalidated/reused unless moved from!!! using PackageVisitorConst = std::function &)>; using PackageVisitorByName = std::function &)>; - using PackageVisitorByNameBase = std::function &)>; + using PackageVisitorByNameBase = std::function &)>; friend struct PackageUpdater; diff --git a/libpkg/data/package.cpp b/libpkg/data/package.cpp index 71785a7..70b3e48 100644 --- a/libpkg/data/package.cpp +++ b/libpkg/data/package.cpp @@ -571,8 +571,8 @@ static void internalPush( } template > * = nullptr> -static void internalPull( - PackageSpecType &reflectable, const ::RAPIDJSON_NAMESPACE::GenericValue<::RAPIDJSON_NAMESPACE::UTF8>::ConstObject &value, JsonDeserializationErrors *errors) +static void internalPull(PackageSpecType &reflectable, + const ::RAPIDJSON_NAMESPACE::GenericValue<::RAPIDJSON_NAMESPACE::UTF8>::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(const LibPkg::PackageSpec &reflectable, ::RAPIDJSON_NAMESPACE::Value::Object &value, RAPIDJSON_NAMESPACE::Document::AllocatorType &allocator) +LIBPKG_EXPORT void push( + const LibPkg::PackageSpec &reflectable, ::RAPIDJSON_NAMESPACE::Value::Object &value, RAPIDJSON_NAMESPACE::Document::AllocatorType &allocator) { internalPush(reflectable, value, allocator); } template <> -LIBPKG_EXPORT void push>(const LibPkg::GenericPackageSpec &reflectable, ::RAPIDJSON_NAMESPACE::Value::Object &value, - RAPIDJSON_NAMESPACE::Document::AllocatorType &allocator) +LIBPKG_EXPORT void push>(const LibPkg::GenericPackageSpec &reflectable, + ::RAPIDJSON_NAMESPACE::Value::Object &value, RAPIDJSON_NAMESPACE::Document::AllocatorType &allocator) { internalPush(reflectable, value, allocator); } template <> -LIBPKG_EXPORT void pull(LibPkg::PackageSpec &reflectable,const ::RAPIDJSON_NAMESPACE::GenericValue<::RAPIDJSON_NAMESPACE::UTF8>::ConstObject &value, - JsonDeserializationErrors *errors) +LIBPKG_EXPORT void pull(LibPkg::PackageSpec &reflectable, + const ::RAPIDJSON_NAMESPACE::GenericValue<::RAPIDJSON_NAMESPACE::UTF8>::ConstObject &value, JsonDeserializationErrors *errors) { internalPull(reflectable, value, errors); } @@ -643,13 +644,15 @@ void internalWriteCustomType(BinarySerializer &serializer, const PackageSpecType } template <> -LIBPKG_EXPORT BinaryVersion readCustomType(BinaryDeserializer &deserializer, LibPkg::PackageSpec &reflectable, BinaryVersion version) +LIBPKG_EXPORT BinaryVersion readCustomType( + BinaryDeserializer &deserializer, LibPkg::PackageSpec &reflectable, BinaryVersion version) { return internalReadCustomType(deserializer, reflectable, version); } template <> -LIBPKG_EXPORT BinaryVersion readCustomType>(BinaryDeserializer &deserializer, LibPkg::GenericPackageSpec &reflectable, BinaryVersion version) +LIBPKG_EXPORT BinaryVersion readCustomType>( + BinaryDeserializer &deserializer, LibPkg::GenericPackageSpec &reflectable, BinaryVersion version) { return internalReadCustomType(deserializer, reflectable, version); } @@ -661,7 +664,8 @@ LIBPKG_EXPORT void writeCustomType(BinarySerializer &serial } template <> -LIBPKG_EXPORT void writeCustomType>(BinarySerializer &serializer, const LibPkg::GenericPackageSpec &reflectable, BinaryVersion version) +LIBPKG_EXPORT void writeCustomType>( + BinarySerializer &serializer, const LibPkg::GenericPackageSpec &reflectable, BinaryVersion version) { internalWriteCustomType(serializer, reflectable, version); } diff --git a/librepomgr/buildactions/updatecheck.cpp b/librepomgr/buildactions/updatecheck.cpp index de0699d..bfd4f14 100644 --- a/librepomgr/buildactions/updatecheck.cpp +++ b/librepomgr/buildactions/updatecheck.cpp @@ -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>(configReadLock), **m_destinationDbs.begin(), - [this](std::vector &&) { + &std::get>(configReadLock), **m_destinationDbs.begin(), [this](std::vector &&) { m_packageLookupDone = true; run(); })) { diff --git a/librepomgr/webapi/routes.cpp b/librepomgr/webapi/routes.cpp index 3f272ca..1c73bc3 100644 --- a/librepomgr/webapi/routes.cpp +++ b/librepomgr/webapi/routes.cpp @@ -227,18 +227,20 @@ void getPackages(const Params ¶ms, 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 &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 &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 &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 &pkg) { + ReflectiveRapidJSON::JsonReflector::push(pkg, array, document.GetAllocator()); + return array.Size() >= limit; + }; auto aurPackages = std::vector(); auto neededAurPackages = std::vector(); @@ -275,7 +277,7 @@ void getPackages(const Params ¶ms, ResponseHandler &&handler) case Mode::NameContains: { auto basePackage = PackageBase(); params.setup.config.packagesByName( - visitDb, [&](LibPkg::Database &db, std::string_view packageName, const std::function &getPackage) { + visitDb, [&](LibPkg::Database &db, std::string_view packageName, const std::function &getPackage) { if (packageName.find(name) != std::string_view::npos) { const auto packageID = getPackage(basePackage); if (!packageID) { @@ -299,7 +301,7 @@ void getPackages(const Params ¶ms, 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 &getPackage) { + visitDb, [&](LibPkg::Database &db, std::string_view packageName, const std::function &getPackage) { if (std::regex_match(packageName.begin(), packageName.end(), regex)) { const auto packageID = getPackage(basePackage); if (!packageID) {