diff options
Diffstat (limited to 'src/libfetchers/attrs.hh')
-rw-r--r-- | src/libfetchers/attrs.hh | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/libfetchers/attrs.hh b/src/libfetchers/attrs.hh index d6e0ae000..e41037633 100644 --- a/src/libfetchers/attrs.hh +++ b/src/libfetchers/attrs.hh @@ -6,29 +6,24 @@ #include <nlohmann/json_fwd.hpp> -namespace nix::fetchers { +#include <optional> -/* Wrap bools to prevent string literals (i.e. 'char *') from being - cast to a bool in Attr. */ -template<typename T> -struct Explicit { - T t; -}; +namespace nix::fetchers { -typedef std::variant<std::string, int64_t, Explicit<bool>> Attr; +typedef std::variant<std::string, uint64_t, Explicit<bool>> Attr; typedef std::map<std::string, Attr> Attrs; Attrs jsonToAttrs(const nlohmann::json & json); -nlohmann::json attrsToJson(const Attrs & attrs); +nlohmann::json attrsToJSON(const Attrs & attrs); std::optional<std::string> maybeGetStrAttr(const Attrs & attrs, const std::string & name); std::string getStrAttr(const Attrs & attrs, const std::string & name); -std::optional<int64_t> maybeGetIntAttr(const Attrs & attrs, const std::string & name); +std::optional<uint64_t> maybeGetIntAttr(const Attrs & attrs, const std::string & name); -int64_t getIntAttr(const Attrs & attrs, const std::string & name); +uint64_t getIntAttr(const Attrs & attrs, const std::string & name); std::optional<bool> maybeGetBoolAttr(const Attrs & attrs, const std::string & name); |