18#include <unordered_map>
19#include <unordered_set>
23#include <nix/config.hh>
24#include <nix/globals.hh>
25#include <nlohmann/json.hpp>
62 "invalid package query argument" )
77 std::optional<std::string> name;
78 std::optional<std::string> pname;
79 std::optional<std::string> version;
80 std::optional<std::string> semver;
83 std::optional<std::string> partialMatch;
86 std::optional<std::string> partialNameMatch;
89 std::optional<std::string> pnameOrAttrName;
96 std::optional<std::vector<std::string>> licenses;
99 bool allowBroken =
false;
102 bool allowUnfree =
true;
105 bool preferPreReleases =
false;
113 std::optional<std::vector<Subtree>> subtrees;
116 std::vector<System> systems = { nix::settings.thisSystem.get() };
124 std::optional<flox::AttrPath> relPath;
154to_json( nlohmann::json & jto,
const PkgQueryArgs & descriptor );
186 std::unordered_map<std::string, std::string>
binds;
240 [[nodiscard]] std::unordered_set<std::string>
278 explicit PkgQuery(
const PkgQueryArgs & params ) : PkgQueryArgs( params )
283 PkgQuery(
const PkgQueryArgs & params,
298 [[nodiscard]] std::string
308 [[nodiscard]] std::shared_ptr<sqlite3pp::query>
309 bind( sqlite3pp::database & pdb )
const;
317 [[nodiscard]] std::vector<row_id>
318 execute( sqlite3pp::database & pdb )
const;
Indicates invalid arguments were set in a flox::resolver::PkgQueryArgs struct.
A query used to lookup packages in a database.
Definition: pkg-query.hh:166
std::stringstream orders
Definition: pkg-query.hh:176
std::shared_ptr< sqlite3pp::query > bind(sqlite3pp::database &pdb) const
Create a bound SQLite query ready for execution.
Definition: pkg-query.cc:532
std::stringstream wheres
Definition: pkg-query.hh:181
void clearBuilt()
Clear member PkgQuery member variables of any state from past initialization runs.
Definition: pkg-query.cc:169
std::vector< row_id > execute(sqlite3pp::database &pdb) const
Query a given database returning an ordered list of satisfactory Packages.ids.
Definition: pkg-query.cc:548
void initMatch()
A helper of init() which handles match filtering/ranking.
Definition: pkg-query.cc:201
void init()
Translate floco::pkgdb::PkgQueryArgs parameters to a built SQL statement held in std::stringstream me...
Definition: pkg-query.cc:406
std::unordered_map< std::string, std::string > binds
Definition: pkg-query.hh:186
std::stringstream selects
Definition: pkg-query.hh:171
void initSubtrees()
A helper of init() which handles subtrees filtering/ranking.
Definition: pkg-query.cc:275
void addOrderBy(std::string_view order)
Appends the ORDER BY block.
Definition: pkg-query.cc:150
bool firstSelect
Definition: pkg-query.hh:173
std::string str() const
Produce an unbound SQL statement from various member variables.
Definition: pkg-query.cc:483
void addSelection(std::string_view column)
Add a new column to the inner SELECT statement.
Definition: pkg-query.cc:142
std::vector< std::string > exportedColumns
Definition: pkg-query.hh:197
void addWhere(std::string_view cond)
Appends the WHERE block with a new AND ( <COND> ) statement.
Definition: pkg-query.cc:158
std::unordered_set< std::string > filterSemvers(const std::unordered_set< std::string > &versions) const
Filter a set of semantic version numbers by the range indicated in the semvers member variable.
Definition: pkg-query.cc:508
void initOrderBy()
A helper of init() which constructs the ORDER BY block.
Definition: pkg-query.cc:353
bool firstOrder
Definition: pkg-query.hh:178
void initSystems()
A helper of init() which handles systems filtering/ranking.
Definition: pkg-query.cc:319
bool firstWhere
Definition: pkg-query.hh:183
Provides backports of some concepts features that are missing in Clang v11.
Definitions of various std::exception children used for throwing errors with nice messages and typed ...
#define FLOX_DEFINE_EXCEPTION(NAME, ERROR_CODE, CATEGORY_MSG)
Generate a class definition with an error code and category message.
Definition: exceptions.hh:206
Interfaces for caching package metadata in SQLite3 databases.
Definition: command.cc:44
uint64_t row_id
Definition: pkg-query.hh:48
void to_json(nlohmann::json &jto, const PkgQueryArgs &args)
Convert an flox::pkgdb::PkgQueryArgs to a JSON object.
Definition: pkg-query.cc:97
@ EC_INVALID_PKG_QUERY_ARG
Definition: exceptions.hh:41
Interfaces for analyzing version numbers.
Definition: versions.cc:31
Miscellaneous typedefs and aliases.