1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-12-14 21:11:04 +01:00

Remove default constructor from OutputsSpec

This forces us to be explicit.

It also requires to rework how `from_json` works. A `JSON_IMPL` is added
to assist with this.
This commit is contained in:
John Ericson 2023-01-11 16:32:30 -05:00
parent 114a6e2b09
commit 5ba6e5d0d9
12 changed files with 103 additions and 49 deletions

View file

@ -4,7 +4,7 @@
#include <set>
#include <variant>
#include "nlohmann/json_fwd.hpp"
#include "json-impls.hh"
namespace nix {
@ -35,6 +35,9 @@ struct OutputsSpec : _OutputsSpecRaw {
using Raw = _OutputsSpecRaw;
using Raw::Raw;
/* Force choosing a variant */
OutputsSpec() = delete;
using Names = OutputNames;
using All = AllOutputs;
@ -85,11 +88,7 @@ struct ExtendedOutputsSpec : _ExtendedOutputsSpecRaw {
std::string to_string() const;
};
void to_json(nlohmann::json &, const OutputsSpec &);
void from_json(const nlohmann::json &, OutputsSpec &);
void to_json(nlohmann::json &, const ExtendedOutputsSpec &);
void from_json(const nlohmann::json &, ExtendedOutputsSpec &);
}
JSON_IMPL(OutputsSpec)
JSON_IMPL(ExtendedOutputsSpec)