Nix
2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Toggle main menu visibility
Loading...
Searching...
No Matches
outputs-spec.hh
Go to the documentation of this file.
1
#pragma once
3
4
#include <cassert>
5
#include <optional>
6
#include <set>
7
#include <variant>
8
9
#include "
nix/util/json-impls.hh
"
10
#include "
nix/util/variant-wrapper.hh
"
11
12
namespace
nix {
13
18
typedef
std::string
OutputName
;
19
24
typedef
std::string_view
OutputNameView
;
25
26
struct
OutputsSpec
27
{
31
struct
Names : std::set<OutputName, std::less<>>
32
{
33
private
:
34
using
BaseType = std::set<OutputName, std::less<>>;
35
36
public
:
37
using
BaseType::BaseType;
38
39
/* These need to be "inherited manually" */
40
41
Names(
const
BaseType & s)
42
: BaseType(s)
43
{
44
assert(!empty());
45
}
46
50
Names
(BaseType && s)
51
: BaseType(std::move(s))
52
{
53
assert(!empty());
54
}
55
56
/* This set should always be non-empty, so we delete this
57
constructor in order make creating empty ones by mistake harder.
58
*/
59
Names
() =
delete
;
60
};
61
65
struct
All
: std::monostate
66
{};
67
68
typedef
std::variant<All, Names> Raw;
69
70
Raw raw;
71
72
bool
operator==(
const
OutputsSpec
&)
const
=
default
;
73
74
// TODO libc++ 16 (used by darwin) missing `std::set::operator <=>`, can't do yet.
75
bool
operator<(
const
OutputsSpec
& other)
const
76
{
77
return
raw < other.raw;
78
}
79
80
MAKE_WRAPPER_CONSTRUCTOR
(
OutputsSpec
);
81
85
OutputsSpec
() =
delete
;
86
87
bool
contains(
const
OutputName
& output)
const
;
88
92
OutputsSpec
union_
(
const
OutputsSpec
& that)
const
;
93
97
bool
isSubsetOf
(
const
OutputsSpec
& outputs)
const
;
98
103
static
OutputsSpec
parse
(std::string_view s);
104
static
std::optional<OutputsSpec> parseOpt(std::string_view s);
105
106
std::string to_string()
const
;
107
};
108
109
struct
ExtendedOutputsSpec
110
{
111
struct
Default
: std::monostate
112
{};
113
114
using
Explicit =
OutputsSpec
;
115
116
typedef
std::variant<Default, Explicit> Raw;
117
118
Raw raw;
119
120
bool
operator==(
const
ExtendedOutputsSpec
&)
const
=
default
;
121
// TODO libc++ 16 (used by darwin) missing `std::set::operator <=>`, can't do yet.
122
bool
operator<(
const
ExtendedOutputsSpec
&)
const
;
123
124
MAKE_WRAPPER_CONSTRUCTOR(
ExtendedOutputsSpec
);
125
129
ExtendedOutputsSpec
() =
delete
;
130
135
static
std::pair<std::string_view, ExtendedOutputsSpec>
parse
(std::string_view s);
136
static
std::optional<std::pair<std::string_view, ExtendedOutputsSpec>> parseOpt(std::string_view s);
137
138
std::string to_string()
const
;
139
};
140
141
}
// namespace nix
142
143
JSON_IMPL(
nix::OutputsSpec
)
144
JSON_IMPL(
nix::ExtendedOutputsSpec
)
json-impls.hh
nix::OutputNameView
std::string_view OutputNameView
Definition
outputs-spec.hh:24
nix::OutputName
std::string OutputName
Definition
outputs-spec.hh:18
nix::ExtendedOutputsSpec::Default
Definition
outputs-spec.hh:112
nix::ExtendedOutputsSpec
Definition
outputs-spec.hh:110
nix::ExtendedOutputsSpec::ExtendedOutputsSpec
ExtendedOutputsSpec()=delete
nix::ExtendedOutputsSpec::parse
static std::pair< std::string_view, ExtendedOutputsSpec > parse(std::string_view s)
Definition
outputs-spec.cc:58
nix::OutputsSpec::All
Definition
outputs-spec.hh:66
nix::OutputsSpec::Names
Definition
outputs-spec.hh:32
nix::OutputsSpec::Names::Names
Names(BaseType &&s)
Definition
outputs-spec.hh:50
nix::OutputsSpec
Definition
outputs-spec.hh:27
nix::OutputsSpec::isSubsetOf
bool isSubsetOf(const OutputsSpec &outputs) const
Definition
outputs-spec.cc:109
nix::OutputsSpec::union_
OutputsSpec union_(const OutputsSpec &that) const
Definition
outputs-spec.cc:88
nix::OutputsSpec::OutputsSpec
OutputsSpec()=delete
nix::OutputsSpec::parse
static OutputsSpec parse(std::string_view s)
Definition
outputs-spec.cc:31
variant-wrapper.hh
MAKE_WRAPPER_CONSTRUCTOR
#define MAKE_WRAPPER_CONSTRUCTOR(CLASS_NAME)
Definition
variant-wrapper.hh:49
libstore
include
nix
store
outputs-spec.hh
Generated by
1.18.0