#pragma once #include "types.hh" #include #include namespace nix::fetchers { /* Wrap bools to prevent string literals (i.e. 'char *') from being cast to a bool in Attr. */ template struct Explicit { T t; }; typedef std::variant> Attr; typedef std::map Attrs; Attrs jsonToAttrs(const nlohmann::json & json); nlohmann::json attrsToJson(const Attrs & attrs); std::optional maybeGetStrAttr(const Attrs & attrs, const std::string & name); std::string getStrAttr(const Attrs & attrs, const std::string & name); std::optional maybeGetIntAttr(const Attrs & attrs, const std::string & name); int64_t getIntAttr(const Attrs & attrs, const std::string & name); std::optional maybeGetBoolAttr(const Attrs & attrs, const std::string & name); bool getBoolAttr(const Attrs & attrs, const std::string & name); std::map attrsToQuery(const Attrs & attrs); }