diff options
Diffstat (limited to 'src/libexpr/value')
-rw-r--r-- | src/libexpr/value/context.cc | 2 | ||||
-rw-r--r-- | src/libexpr/value/context.hh | 94 |
2 files changed, 42 insertions, 54 deletions
diff --git a/src/libexpr/value/context.cc b/src/libexpr/value/context.cc index d8116011e..22361d8fa 100644 --- a/src/libexpr/value/context.cc +++ b/src/libexpr/value/context.cc @@ -99,7 +99,7 @@ std::string NixStringContextElem::to_string() const res += '='; res += d.drvPath.to_string(); }, - }, raw()); + }, raw); return res; } diff --git a/src/libexpr/value/context.hh b/src/libexpr/value/context.hh index a1b71695b..9f1d59317 100644 --- a/src/libexpr/value/context.hh +++ b/src/libexpr/value/context.hh @@ -4,8 +4,7 @@ #include "util.hh" #include "comparator.hh" #include "derived-path.hh" - -#include <variant> +#include "variant-wrapper.hh" #include <nlohmann/json_fwd.hpp> @@ -26,58 +25,47 @@ public: } }; -/** - * Plain opaque path to some store object. - * - * Encoded as just the path: ‘<path>’. - */ -typedef SingleDerivedPath::Opaque NixStringContextElem_Opaque; - -/** - * Path to a derivation and its entire build closure. - * - * The path doesn't just refer to derivation itself and its closure, but - * also all outputs of all derivations in that closure (including the - * root derivation). - * - * Encoded in the form ‘=<drvPath>’. - */ -struct NixStringContextElem_DrvDeep { - StorePath drvPath; - - GENERATE_CMP(NixStringContextElem_DrvDeep, me->drvPath); -}; +struct NixStringContextElem { + /** + * Plain opaque path to some store object. + * + * Encoded as just the path: ‘<path>’. + */ + using Opaque = SingleDerivedPath::Opaque; -/** - * Derivation output. - * - * Encoded in the form ‘!<output>!<drvPath>’. - */ -typedef SingleDerivedPath::Built NixStringContextElem_Built; - -using _NixStringContextElem_Raw = std::variant< - NixStringContextElem_Opaque, - NixStringContextElem_DrvDeep, - NixStringContextElem_Built ->; - -struct NixStringContextElem : _NixStringContextElem_Raw { - using Raw = _NixStringContextElem_Raw; - using Raw::Raw; - - using Opaque = NixStringContextElem_Opaque; - using DrvDeep = NixStringContextElem_DrvDeep; - using Built = NixStringContextElem_Built; - - inline const Raw & raw() const & { - return static_cast<const Raw &>(*this); - } - inline Raw & raw() & { - return static_cast<Raw &>(*this); - } - inline Raw && raw() && { - return static_cast<Raw &&>(*this); - } + /** + * Path to a derivation and its entire build closure. + * + * The path doesn't just refer to derivation itself and its closure, but + * also all outputs of all derivations in that closure (including the + * root derivation). + * + * Encoded in the form ‘=<drvPath>’. + */ + struct DrvDeep { + StorePath drvPath; + + GENERATE_CMP(DrvDeep, me->drvPath); + }; + + /** + * Derivation output. + * + * Encoded in the form ‘!<output>!<drvPath>’. + */ + using Built = SingleDerivedPath::Built; + + using Raw = std::variant< + Opaque, + DrvDeep, + Built + >; + + Raw raw; + + GENERATE_CMP(NixStringContextElem, me->raw); + + MAKE_WRAPPER_CONSTRUCTOR(NixStringContextElem); /** * Decode a context string, one of: |