aboutsummaryrefslogtreecommitdiffstats
path: root/document/src/vespa/document/select/bodyfielddetector.h
blob: cb2019771e47928552297a8b5833516377029c97 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include "traversingvisitor.h"

namespace document {
    class DocumentTypeRepo;
    class DocumentType;
}

namespace document::select {

class BodyFieldDetector : public TraversingVisitor
{
    const DocumentTypeRepo &_repo;

    void detectFieldType(const FieldValueNode *expr, const DocumentType &type);

public:
    BodyFieldDetector(const DocumentTypeRepo &repo)
        : _repo(repo), foundBodyField(false), foundHeaderField(false)
    {
    }

    bool foundBodyField;
    bool foundHeaderField;

    void visitDocumentType(const DocType&) override {
            // Need to deserialize header to know document type
        foundHeaderField = true;
    }

    void visitFieldValueNode(const FieldValueNode& expr) override;
};

}