aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/outputs-spec.hh
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2023-01-11 16:32:30 -0500
committerJohn Ericson <John.Ericson@Obsidian.Systems>2023-01-11 19:08:19 -0500
commit5ba6e5d0d9bed2806ddb59c8a3305b3cb5784d53 (patch)
tree065e7eccec8a228a4045a434c4d5a1de5aa0cf3b /src/libstore/outputs-spec.hh
parent114a6e2b09eda7f23e7776e1cdf77715044e073e (diff)
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.
Diffstat (limited to 'src/libstore/outputs-spec.hh')
-rw-r--r--src/libstore/outputs-spec.hh15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/libstore/outputs-spec.hh b/src/libstore/outputs-spec.hh
index 9c477ee2b..babf29d16 100644
--- a/src/libstore/outputs-spec.hh
+++ b/src/libstore/outputs-spec.hh
@@ -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)