1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 10:41:16 +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) {