Flox Package Database 1
CRUD Operations on Nix Package Metadata
Loading...
Searching...
No Matches
params.hh
Go to the documentation of this file.
1/* ========================================================================== *
2 *
3 * @file flox/search/params.hh
4 *
5 * @brief A set of user inputs used to set input preferences and query
6 * parameters during search.
7 *
8 *
9 * -------------------------------------------------------------------------- */
10
11#pragma once
12
13#include <filesystem>
14#include <nlohmann/json_fwd.hpp>
15#include <optional>
16#include <string>
17#include <string_view>
18#include <variant>
19
21#include "flox/core/types.hh"
22#include "flox/core/util.hh"
24#include "flox/registry.hh"
28
29
30/* -------------------------------------------------------------------------- */
31
32namespace flox::search {
33
34/* -------------------------------------------------------------------------- */
35
43{
44
45 std::optional<std::string> name;
46 std::optional<std::string> pname;
47 std::optional<std::string> version;
48 std::optional<std::string> semver;
51 std::optional<std::string> partialMatch;
52
54 std::optional<std::string> partialNameMatch;
55
57 void
58 clear();
59
61 void
62 check() const;
63
73 pkgdb::PkgQueryArgs &
74 fillPkgQueryArgs( pkgdb::PkgQueryArgs & pqa ) const;
75
76
77}; /* End struct "SearchQuery' */
78
79
80/* -------------------------------------------------------------------------- */
81
91 "error parsing search query" )
95/* -------------------------------------------------------------------------- */
96
97
98void
99from_json( const nlohmann::json & jfrom, SearchQuery & qry );
100
102void
103to_json( nlohmann::json & jto, const SearchQuery & qry );
104
105
106/* -------------------------------------------------------------------------- */
107
109{
110
115 std::optional<
116 std::variant<std::filesystem::path, resolver::GlobalManifestRaw>>
118
123 std::optional<std::variant<std::filesystem::path, resolver::ManifestRaw>>
125
130 std::optional<std::variant<std::filesystem::path, resolver::LockfileRaw>>
132
138
139
144 [[nodiscard]] std::optional<std::filesystem::path>
145 getGlobalManifestPath();
146
151 [[nodiscard]] std::optional<flox::resolver::GlobalManifestRaw>
152 getGlobalManifestRaw();
153
158 [[nodiscard]] std::optional<std::filesystem::path>
159 getManifestPath();
160
166 [[nodiscard]] flox::resolver::ManifestRaw
167 getManifestRaw();
168
173 [[nodiscard]] std::optional<std::filesystem::path>
174 getLockfilePath();
175
180 [[nodiscard]] std::optional<flox::resolver::LockfileRaw>
181 getLockfileRaw();
182
183
184}; /* End struct `SearchParams' */
185
186
187/* -------------------------------------------------------------------------- */
188
190void
191from_json( const nlohmann::json & jfrom, SearchParams & params );
192
194void
195to_json( nlohmann::json & jto, const SearchParams & params );
196
197
198/* -------------------------------------------------------------------------- */
199
200} // namespace flox::search
201
202
203/* -------------------------------------------------------------------------- *
204 *
205 *
206 *
207 * ========================================================================== */
An exception thrown when parsing flox::search::SearchQuery from JSON.
A collection of files associated with an environment.
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
A lockfile representing a resolved environment.
An abstract description of an environment in its unresolved state.
Interfaces used to search for packages in flakes.
Definition: command.cc:38
void to_json(nlohmann::json &jto, const SearchQuery &qry)
Convert a JSON object to a flox::search::SearchQuery.
Definition: params.cc:118
@ EC_PARSE_SEARCH_QUERY
Definition: exceptions.hh:61
void from_json(const nlohmann::json &jfrom, RawPackage &pkg)
Convert a JSON object to a flox::RawPackage.
Definition: raw-package.cc:27
Extension to the ‘nlohmann::json’ serializer to support additional Argument Dependent Lookup (ADL) ty...
Definition: util.hh:54
Interfaces for constructing complex ‘Packages’ queries.
A set of user inputs used to set input preferences during search and resolution.
A raw description of an environment to be read from a file.
Definition: manifest-raw.hh:264
Definition: params.hh:109
std::optional< std::variant< std::filesystem::path, resolver::LockfileRaw > > lockfile
The absolute std::filesystem::path to a lockfile or an inline flox::resolver::LockfileRaw.
Definition: params.hh:131
std::optional< std::variant< std::filesystem::path, resolver::ManifestRaw > > manifest
The absolute std::filesystem::path to a manifest file or an inline flox::resolver::ManifestRaw.
Definition: params.hh:124
std::optional< std::variant< std::filesystem::path, resolver::GlobalManifestRaw > > globalManifest
The absolute std::filesystem::path to a manifest file or an inline flox::resolver::GlobalManifestRaw.
Definition: params.hh:117
SearchQuery query
The flox::search::SearchQuery specifying the package to search for.
Definition: params.hh:137
A set of query parameters.
Definition: params.hh:43
std::optional< std::string > pname
Definition: params.hh:46
std::optional< std::string > partialNameMatch
Definition: params.hh:54
pkgdb::PkgQueryArgs & fillPkgQueryArgs(pkgdb::PkgQueryArgs &pqa) const
Fill a flox::pkgdb::PkgQueryArgs struct with preferences to lookup packages filtered by SearchQuery r...
Definition: params.cc:132
std::optional< std::string > name
Definition: params.hh:45
void clear()
Reset to default state.
Definition: params.cc:21
std::optional< std::string > semver
Definition: params.hh:48
std::optional< std::string > partialMatch
Definition: params.hh:51
std::optional< std::string > version
Definition: params.hh:47
void check() const
Check validity of fields, throwing an exception if invalid.
Definition: params.cc:35
Miscellaneous typedefs and aliases.
Miscellaneous helper functions.