Flox Package Database 1
CRUD Operations on Nix Package Metadata
Loading...
Searching...
No Matches
raw-package.hh
Go to the documentation of this file.
1/* ========================================================================== *
2 *
3 * @file flox/raw-package.hh
4 *
5 * @brief The simplest `Package' implementation comprised of raw values.
6 *
7 *
8 * -------------------------------------------------------------------------- */
9
10#pragma once
11
12#include <optional>
13#include <string>
14#include <string_view>
15#include <vector>
16
17#include <nlohmann/json.hpp>
18
19#include "flox/core/types.hh"
20#include "flox/package.hh"
21
22
23/* -------------------------------------------------------------------------- */
24
25namespace flox {
26
27/* -------------------------------------------------------------------------- */
28
34class RawPackage : public Package
35{
36
37public:
38
39 AttrPath path;
40 std::string name;
41 std::string pname;
42 std::optional<std::string> version;
43 std::optional<std::string> semver;
44 std::optional<std::string> license;
45 std::vector<std::string> outputs;
46 std::vector<std::string> outputsToInstall;
47 std::optional<bool> broken;
48 std::optional<bool> unfree;
49 std::optional<std::string> description;
50
51 RawPackage( const AttrPath & path = {},
52 std::string_view name = {},
53 std::string_view pname = {},
54 std::optional<std::string> version = std::nullopt,
55 std::optional<std::string> semver = std::nullopt,
56 std::optional<std::string> license = std::nullopt,
57 const std::vector<std::string> & outputs = { "out" },
58 const std::vector<std::string> & outputsToInstall = { "out" },
59 std::optional<bool> broken = std::nullopt,
60 std::optional<bool> unfree = std::nullopt,
61 std::optional<std::string> description = std::nullopt )
62 : path( path )
63 , name( name )
64 , pname( pname )
65 , version( version )
66 , semver( semver )
67 , license( license )
68 , outputs( outputs )
69 , outputsToInstall( outputsToInstall )
70 , broken( broken )
71 , unfree( unfree )
72 , description( description )
73 {}
74
75
76 /* --------------------------------------------------------------------------
77 */
78
80 getPathStrs() const override
81 {
82 return this->path;
83 }
84
85 std::string
86 getFullName() const override
87 {
88 return this->name;
89 }
90
91 std::string
92 getPname() const override
93 {
94 return this->pname;
95 }
96
97 std::optional<std::string>
98 getVersion() const override
99 {
100 return this->version;
101 }
102
103 std::optional<std::string>
104 getSemver() const override
105 {
106 return this->semver;
107 }
108
109 std::optional<std::string>
110 getLicense() const override
111 {
112 return this->license;
113 }
114
115 std::vector<std::string>
116 getOutputs() const override
117 {
118 return this->outputs;
119 }
120
121 std::vector<std::string>
122 getOutputsToInstall() const override
123 {
124 return this->outputsToInstall;
125 }
126
127 std::optional<bool>
128 isBroken() const override
129 {
130 return this->broken;
131 }
132
133 std::optional<bool>
134 isUnfree() const override
135 {
136 return this->unfree;
137 }
138
139 std::optional<std::string>
140 getDescription() const override
141 {
142 return this->description;
143 }
144
145
146}; /* End class `RawPackage' */
147
148
149/* -------------------------------------------------------------------------- */
150
152void
153from_json( const nlohmann::json & jfrom, RawPackage & pkg );
154
156void
157to_json( nlohmann::json & jto, const flox::RawPackage & pkg );
158
159
160/* -------------------------------------------------------------------------- */
161
162} // namespace flox
163
164
165/* -------------------------------------------------------------------------- *
166 *
167 *
168 *
169 * ========================================================================== */
Abstract representation of a "package", analogous to a Nix ‘derivation’.
Definition: package.hh:44
The simplest ‘Package’ implementation comprised of raw values.
Definition: raw-package.hh:35
std::optional< std::string > getLicense() const override
Definition: raw-package.hh:110
std::vector< std::string > getOutputs() const override
Definition: raw-package.hh:116
std::optional< std::string > getSemver() const override
Definition: raw-package.hh:104
std::optional< std::string > getVersion() const override
Definition: raw-package.hh:98
std::string getPname() const override
Definition: raw-package.hh:92
std::optional< bool > isBroken() const override
Definition: raw-package.hh:128
std::vector< std::string > getOutputsToInstall() const override
Definition: raw-package.hh:122
AttrPath getPathStrs() const override
Definition: raw-package.hh:80
std::string getFullName() const override
Definition: raw-package.hh:86
std::optional< std::string > getDescription() const override
Definition: raw-package.hh:140
std::optional< bool > isUnfree() const override
Definition: raw-package.hh:134
Interfaces for use by flox.
Definition: command.cc:29
void from_json(const nlohmann::json &jfrom, RawPackage &pkg)
Convert a JSON object to a flox::RawPackage.
Definition: raw-package.cc:27
void to_json(nlohmann::json &jto, const FloxException &err)
Convert a flox::FloxException to a JSON object.
Definition: exceptions.cc:27
std::vector< std::string > AttrPath
A list of key names addressing a location in a nested JSON-like object.
Definition: types.hh:33
Abstract representation of a package.
Miscellaneous typedefs and aliases.