1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-27 12:41:15 +02:00

Integrate review changes

This commit is contained in:
Eli Kogan-Wang 2022-05-13 22:02:28 +02:00
parent aefc6c4f41
commit be2b19041e
7 changed files with 50 additions and 18 deletions

View file

@ -621,6 +621,28 @@ bool AttrCursor::getBool()
return v.boolean;
}
NixInt AttrCursor::getInt()
{
if (root->db) {
if (!cachedValue)
cachedValue = root->db->getAttr(getKey());
if (cachedValue && !std::get_if<placeholder_t>(&cachedValue->second)) {
if (auto i = std::get_if<NixInt>(&cachedValue->second)) {
debug("using cached Integer attribute '%s'", getAttrPathStr());
return *i;
} else
throw TypeError("'%s' is not an Integer", getAttrPathStr());
}
}
auto & v = forceValue();
if (v.type() != nInt)
throw TypeError("'%s' is not an Integer", getAttrPathStr());
return v.integer;
}
std::vector<std::string> AttrCursor::getListOfStrings()
{
if (root->db) {

View file

@ -63,6 +63,7 @@ typedef std::variant<
misc_t,
failed_t,
bool,
NixInt,
std::vector<std::string>
> AttrValue;
@ -116,6 +117,8 @@ public:
bool getBool();
NixInt getInt();
std::vector<std::string> getListOfStrings();
std::vector<Symbol> getAttrs();