aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/outputs-spec.hh
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2023-08-16 12:29:23 -0400
committerJohn Ericson <John.Ericson@Obsidian.Systems>2023-08-18 11:44:00 -0400
commit9121fed4b4d02c286166373fe9805773afb13694 (patch)
tree195ec159fde2c2b2e81b8270101f2c37f38e097c /src/libstore/outputs-spec.hh
parent284c18073233b3c7e7e027d696465a0e773dc881 (diff)
Fixing #7479
Types converted: - `NixStringContextElem` - `OutputsSpec` - `ExtendedOutputsSpec` - `DerivationOutput` - `DerivationType` Existing ones mostly conforming the pattern cleaned up: - `ContentAddressMethod` - `ContentAddressWithReferences` The `DerivationGoal::derivationType` field had a bogus initialization, now caught, so I made it `std::optional`. I think #8829 can make it non-optional again because it will ensure we always have the derivation when we construct a `DerivationGoal`. See that issue (#7479) for details on the general goal. `git grep 'Raw::Raw'` indicates the two types I didn't yet convert `DerivedPath` and `BuiltPath` (and their `Single` variants) . This is because @roberth and I (can't find issue right now...) plan on reworking them somewhat, so I didn't want to churn them more just yet. Co-authored-by: Eelco Dolstra <edolstra@gmail.com>
Diffstat (limited to 'src/libstore/outputs-spec.hh')
-rw-r--r--src/libstore/outputs-spec.hh93
1 files changed, 45 insertions, 48 deletions
diff --git a/src/libstore/outputs-spec.hh b/src/libstore/outputs-spec.hh
index 5a726fe90..ae19f1040 100644
--- a/src/libstore/outputs-spec.hh
+++ b/src/libstore/outputs-spec.hh
@@ -6,62 +6,57 @@
#include <set>
#include <variant>
+#include "comparator.hh"
#include "json-impls.hh"
+#include "comparator.hh"
+#include "variant-wrapper.hh"
namespace nix {
-/**
- * A non-empty set of outputs, specified by name
- */
-struct OutputNames : std::set<std::string> {
- using std::set<std::string>::set;
+struct OutputsSpec {
+ /**
+ * A non-empty set of outputs, specified by name
+ */
+ struct Names : std::set<std::string> {
+ using std::set<std::string>::set;
+
+ /* These need to be "inherited manually" */
+
+ Names(const std::set<std::string> & s)
+ : std::set<std::string>(s)
+ { assert(!empty()); }
- /* These need to be "inherited manually" */
+ /**
+ * Needs to be "inherited manually"
+ */
+ Names(std::set<std::string> && s)
+ : std::set<std::string>(s)
+ { assert(!empty()); }
- OutputNames(const std::set<std::string> & s)
- : std::set<std::string>(s)
- { assert(!empty()); }
+ /* This set should always be non-empty, so we delete this
+ constructor in order make creating empty ones by mistake harder.
+ */
+ Names() = delete;
+ };
/**
- * Needs to be "inherited manually"
+ * The set of all outputs, without needing to name them explicitly
*/
- OutputNames(std::set<std::string> && s)
- : std::set<std::string>(s)
- { assert(!empty()); }
-
- /* This set should always be non-empty, so we delete this
- constructor in order make creating empty ones by mistake harder.
- */
- OutputNames() = delete;
-};
+ struct All : std::monostate { };
+
+ typedef std::variant<All, Names> Raw;
-/**
- * The set of all outputs, without needing to name them explicitly
- */
-struct AllOutputs : std::monostate { };
+ Raw raw;
-typedef std::variant<AllOutputs, OutputNames> _OutputsSpecRaw;
+ GENERATE_CMP(OutputsSpec, me->raw);
-struct OutputsSpec : _OutputsSpecRaw {
- using Raw = _OutputsSpecRaw;
- using Raw::Raw;
+ MAKE_WRAPPER_CONSTRUCTOR(OutputsSpec);
/**
* Force choosing a variant
*/
OutputsSpec() = delete;
- using Names = OutputNames;
- using All = AllOutputs;
-
- inline const Raw & raw() const {
- return static_cast<const Raw &>(*this);
- }
-
- inline Raw & raw() {
- return static_cast<Raw &>(*this);
- }
-
bool contains(const std::string & output) const;
/**
@@ -84,20 +79,22 @@ struct OutputsSpec : _OutputsSpecRaw {
std::string to_string() const;
};
-struct DefaultOutputs : std::monostate { };
+struct ExtendedOutputsSpec {
+ struct Default : std::monostate { };
+ using Explicit = OutputsSpec;
+
+ typedef std::variant<Default, Explicit> Raw;
-typedef std::variant<DefaultOutputs, OutputsSpec> _ExtendedOutputsSpecRaw;
+ Raw raw;
-struct ExtendedOutputsSpec : _ExtendedOutputsSpecRaw {
- using Raw = _ExtendedOutputsSpecRaw;
- using Raw::Raw;
+ GENERATE_CMP(ExtendedOutputsSpec, me->raw);
- using Default = DefaultOutputs;
- using Explicit = OutputsSpec;
+ MAKE_WRAPPER_CONSTRUCTOR(ExtendedOutputsSpec);
- inline const Raw & raw() const {
- return static_cast<const Raw &>(*this);
- }
+ /**
+ * Force choosing a variant
+ */
+ ExtendedOutputsSpec() = delete;
/**
* Parse a string of the form 'prefix^output1,...outputN' or