Bindings: Add convenience method for requiring an attribute

This commit is contained in:
Eelco Dolstra 2019-05-31 23:44:42 +02:00
parent a2f86ac647
commit fb692e5f7b
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE

View file

@ -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_]; }