Access Python blueprints with bounds checking

This commit is contained in:
nsubiron 2018-07-25 11:45:16 +02:00
parent a1158c6ca8
commit 60d866d5b6
2 changed files with 5 additions and 1 deletions

View File

@ -47,6 +47,10 @@ namespace client {
return _blueprints[pos];
}
const_reference at(size_type pos) const {
return _blueprints.at(pos);
}
const_iterator begin() const /*noexcept*/ {
return _blueprints.begin();
}

View File

@ -106,7 +106,7 @@ void export_blueprint() {
class_<cc::BlueprintLibrary, boost::noncopyable, boost::shared_ptr<cc::BlueprintLibrary>>("BlueprintLibrary", no_init)
.def("filter", &cc::BlueprintLibrary::Filter)
.def("__getitem__", +[](const cc::BlueprintLibrary &self, size_t pos) -> cc::ActorBlueprint {
return self[pos];
return self.at(pos);
})
.def("__len__", &cc::BlueprintLibrary::size)
.def("__iter__", range(&cc::BlueprintLibrary::begin, &cc::BlueprintLibrary::end))