aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libexpr/attr-set.hh8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/libexpr/attr-set.hh b/src/libexpr/attr-set.hh
index 6c5fb21ad..d6af99912 100644
--- a/src/libexpr/attr-set.hh
+++ b/src/libexpr/attr-set.hh
@@ -72,6 +72,14 @@ public:
return {};
}
+ Attr & need(const Symbol & name, const Pos & pos = noPos)
+ {
+ auto a = get(name);
+ if (!a)
+ throw Error("attribute '%s' missing, at %s", name, pos);
+ return **a;
+ }
+
iterator begin() { return &attrs[0]; }
iterator end() { return &attrs[size_]; }