mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 22:16:16 +02:00
Bindings::get(): Add convenience method
This allows writing attribute lookups as if (auto name = value.attrs->get(state.sName)) ...
This commit is contained in:
parent
c02da99757
commit
f216c76c56
2 changed files with 10 additions and 1 deletions
|
@ -62,7 +62,7 @@ CXXFLAGS=
|
||||||
AC_PROG_CC
|
AC_PROG_CC
|
||||||
AC_PROG_CXX
|
AC_PROG_CXX
|
||||||
AC_PROG_CPP
|
AC_PROG_CPP
|
||||||
AX_CXX_COMPILE_STDCXX_14
|
AX_CXX_COMPILE_STDCXX_17
|
||||||
|
|
||||||
|
|
||||||
# Use 64-bit file system calls so that we can support files > 2 GiB.
|
# Use 64-bit file system calls so that we can support files > 2 GiB.
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "symbol-table.hh"
|
#include "symbol-table.hh"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
|
@ -63,6 +64,14 @@ public:
|
||||||
return end();
|
return end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::optional<Attr *> get(const Symbol & name)
|
||||||
|
{
|
||||||
|
Attr key(name, 0);
|
||||||
|
iterator i = std::lower_bound(begin(), end(), key);
|
||||||
|
if (i != end() && i->name == name) return &*i;
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
iterator begin() { return &attrs[0]; }
|
iterator begin() { return &attrs[0]; }
|
||||||
iterator end() { return &attrs[size_]; }
|
iterator end() { return &attrs[size_]; }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue