aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/outputs-spec.hh
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2023-01-11 01:51:14 -0500
committerJohn Ericson <John.Ericson@Obsidian.Systems>2023-01-11 18:54:50 -0500
commita8f45b5e5a42daa9bdee640255464d4dbb431352 (patch)
tree2acc2850c93f2edd4327918dd4886bbbb138b6e0 /src/libstore/outputs-spec.hh
parenta3ba80357d3a792eb1690011f253c64840c6ae72 (diff)
Improve `OutputsSpec` slightly
A few little changes preparing for the rest.
Diffstat (limited to 'src/libstore/outputs-spec.hh')
-rw-r--r--src/libstore/outputs-spec.hh26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/libstore/outputs-spec.hh b/src/libstore/outputs-spec.hh
index e2cf1d12b..6f886ccb6 100644
--- a/src/libstore/outputs-spec.hh
+++ b/src/libstore/outputs-spec.hh
@@ -1,9 +1,8 @@
#pragma once
+#include <set>
#include <variant>
-#include "util.hh"
-
#include "nlohmann/json_fwd.hpp"
namespace nix {
@@ -18,13 +17,26 @@ struct DefaultOutputs {
bool operator < (const DefaultOutputs & _) const { return false; }
};
-typedef std::variant<DefaultOutputs, AllOutputs, OutputNames> OutputsSpec;
+typedef std::variant<DefaultOutputs, AllOutputs, OutputNames> _OutputsSpecRaw;
+
+struct OutputsSpec : _OutputsSpecRaw {
+ using Raw = _OutputsSpecRaw;
+ using Raw::Raw;
+
+ using Names = OutputNames;
+ using All = AllOutputs;
+ using Default = DefaultOutputs;
-/* Parse a string of the form 'prefix^output1,...outputN' or
- 'prefix^*', returning the prefix and the outputs spec. */
-std::pair<std::string, OutputsSpec> parseOutputsSpec(const std::string & s);
+ inline const Raw & raw() const {
+ return static_cast<const Raw &>(*this);
+ }
-std::string printOutputsSpec(const OutputsSpec & outputsSpec);
+ /* Parse a string of the form 'prefix^output1,...outputN' or
+ 'prefix^*', returning the prefix and the outputs spec. */
+ static std::pair<std::string, OutputsSpec> parse(std::string s);
+
+ std::string to_string() const;
+};
void to_json(nlohmann::json &, const OutputsSpec &);
void from_json(const nlohmann::json &, OutputsSpec &);