+ [&fields](const lst::field_location& location)
+ -> lookup_field_fn::result_type {
+ if (location.elements_.size() != 1) {
+ LTTNG_THROW_ERROR(fmt::format(
+ "Unexpected field location received during field look-up: location = {}",
+ location));
+ }
+
+ /*
+ * In the context of fields received from LTTng-UST, field
+ * look-up is extremely naive as the protocol can only
+ * express empty structures. It is safe to assume that
+ * location has a depth of 1 and directly refers to a field
+ * in the 'fields' vector.
+ */
+ const auto field_it = std::find_if(fields.begin(),
+ fields.end(),
+ [&location](decltype(fields)::value_type&
+ field) {
+ return field->name ==
+ location.elements_[0];
+ });
+
+ if (field_it == fields.end()) {
+ LTTNG_THROW_PROTOCOL_ERROR(fmt::format(
+ "Failed to look-up field: location = {}",
+ location));
+ }
+
+ return **field_it;
+ },
+ lookup_root, current_field_location_elements);