aboutsummaryrefslogtreecommitdiffstats
path: root/searchsummary/src/vespa/searchsummary/docsummary/slime_filler_filter.h
diff options
context:
space:
mode:
Diffstat (limited to 'searchsummary/src/vespa/searchsummary/docsummary/slime_filler_filter.h')
-rw-r--r--searchsummary/src/vespa/searchsummary/docsummary/slime_filler_filter.h42
1 files changed, 34 insertions, 8 deletions
diff --git a/searchsummary/src/vespa/searchsummary/docsummary/slime_filler_filter.h b/searchsummary/src/vespa/searchsummary/docsummary/slime_filler_filter.h
index a9f441dc505..8bdc683fbb8 100644
--- a/searchsummary/src/vespa/searchsummary/docsummary/slime_filler_filter.h
+++ b/searchsummary/src/vespa/searchsummary/docsummary/slime_filler_filter.h
@@ -8,28 +8,54 @@
namespace search::docsummary {
-/*
+/**
* Class filtering which fields to render in a struct field.
*/
class SlimeFillerFilter {
+public:
+ /**
+ * Iterator used to step through the sub fields of a struct field
+ * to find out which parts to render.
+ */
+ class Iterator {
+ private:
+ friend class SlimeFillerFilter;
+ bool _should_render;
+ const SlimeFillerFilter* _next;
+ explicit Iterator(bool should_render_in) noexcept;
+ explicit Iterator(const SlimeFillerFilter* next) noexcept;
+ public:
+ Iterator check_field(vespalib::stringref field_name) const;
+ bool should_render() const noexcept { return _should_render; }
+ };
+
+private:
vespalib::hash_map<vespalib::string, std::unique_ptr<SlimeFillerFilter>> _filter;
- std::optional<const SlimeFillerFilter*> get_filter(vespalib::stringref field_name) const;
+ Iterator check_field(vespalib::stringref field_name) const;
+
public:
SlimeFillerFilter();
~SlimeFillerFilter();
- /*
- * If field is blocked by the filter then the return value is not set,
- * otherwise it is set to the filter for the next level.
- */
- static std::optional<const SlimeFillerFilter*> get_filter(const SlimeFillerFilter* filter, vespalib::stringref field_name);
+
+ Iterator begin() const;
+
bool empty() const;
+
+ /**
+ * Add a field path (e.g 'my_field.my_subfield') that should be rendered.
+ */
SlimeFillerFilter& add(vespalib::stringref field_path);
- /*
+ /**
* Called by DocsumFilter::prepareFieldSpec() with each input field name as field_path. First component
* is assumed to be the same as the output field name.
*/
static void add_remaining(std::unique_ptr<SlimeFillerFilter>& filter, vespalib::stringref field_path);
+
+ /**
+ * Returns a pass-through filter iterator that renders all parts of a struct field.
+ */
+ static Iterator all();
};
}