mirror of
https://github.com/NixOS/nix.git
synced 2025-12-14 21:11:04 +01:00
Improve OutputsSpec slightly
A few little changes preparing for the rest.
This commit is contained in:
parent
a3ba80357d
commit
a8f45b5e5a
7 changed files with 46 additions and 32 deletions
|
|
@ -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;
|
||||
|
||||
/* 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);
|
||||
struct OutputsSpec : _OutputsSpecRaw {
|
||||
using Raw = _OutputsSpecRaw;
|
||||
using Raw::Raw;
|
||||
|
||||
std::string printOutputsSpec(const OutputsSpec & outputsSpec);
|
||||
using Names = OutputNames;
|
||||
using All = AllOutputs;
|
||||
using Default = DefaultOutputs;
|
||||
|
||||
inline const Raw & raw() const {
|
||||
return static_cast<const Raw &>(*this);
|
||||
}
|
||||
|
||||
/* 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 &);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue