2023-01-10 16:27:19 +00:00
|
|
|
#pragma once
|
|
|
|
|
2023-01-11 06:51:14 +00:00
|
|
|
#include <set>
|
2023-01-10 16:27:19 +00:00
|
|
|
#include <variant>
|
|
|
|
|
|
|
|
#include "nlohmann/json_fwd.hpp"
|
|
|
|
|
|
|
|
namespace nix {
|
|
|
|
|
|
|
|
typedef std::set<std::string> OutputNames;
|
|
|
|
|
|
|
|
struct AllOutputs {
|
|
|
|
bool operator < (const AllOutputs & _) const { return false; }
|
|
|
|
};
|
|
|
|
|
|
|
|
struct DefaultOutputs {
|
|
|
|
bool operator < (const DefaultOutputs & _) const { return false; }
|
|
|
|
};
|
|
|
|
|
2023-01-11 07:00:44 +00:00
|
|
|
typedef std::variant<DefaultOutputs, AllOutputs, OutputNames> _ExtendedOutputsSpecRaw;
|
2023-01-11 06:51:14 +00:00
|
|
|
|
2023-01-11 07:00:44 +00:00
|
|
|
struct ExtendedOutputsSpec : _ExtendedOutputsSpecRaw {
|
|
|
|
using Raw = _ExtendedOutputsSpecRaw;
|
2023-01-11 06:51:14 +00:00
|
|
|
using Raw::Raw;
|
|
|
|
|
|
|
|
using Names = OutputNames;
|
|
|
|
using All = AllOutputs;
|
|
|
|
using Default = DefaultOutputs;
|
2023-01-10 16:27:19 +00:00
|
|
|
|
2023-01-11 06:51:14 +00:00
|
|
|
inline const Raw & raw() const {
|
|
|
|
return static_cast<const Raw &>(*this);
|
|
|
|
}
|
2023-01-10 16:27:19 +00:00
|
|
|
|
2023-01-11 06:51:14 +00:00
|
|
|
/* Parse a string of the form 'prefix^output1,...outputN' or
|
|
|
|
'prefix^*', returning the prefix and the outputs spec. */
|
2023-01-11 07:00:44 +00:00
|
|
|
static std::pair<std::string, ExtendedOutputsSpec> parse(std::string s);
|
2023-01-11 06:51:14 +00:00
|
|
|
|
|
|
|
std::string to_string() const;
|
|
|
|
};
|
2023-01-10 16:27:19 +00:00
|
|
|
|
2023-01-11 07:00:44 +00:00
|
|
|
void to_json(nlohmann::json &, const ExtendedOutputsSpec &);
|
|
|
|
void from_json(const nlohmann::json &, ExtendedOutputsSpec &);
|
2023-01-10 16:27:19 +00:00
|
|
|
|
|
|
|
}
|