Integrate review changes
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user