aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Functions/JSONPath/Generator/IVisitor.h
blob: 1a94106a435ae5c314498b6608eea6d6ca046e8a (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
37
38
39
40
41
42
43
44
45
46
#pragma once

#include <Functions/JSONPath/Generator/VisitorStatus.h>

namespace DB
{
template <typename JSONParser>
class IVisitor
{
public:
    virtual const char * getName() const = 0;

    /**
     * Applies this visitor to document and mutates its state
     * @param element simdjson element
     */
    virtual VisitorStatus visit(typename JSONParser::Element & element) = 0;

    /**
     * Applies this visitor to document, but does not mutate state
     * @param element simdjson element
     */
    virtual VisitorStatus apply(typename JSONParser::Element & element) const = 0;

    /**
     * Restores visitor's initial state for later use
     */
    virtual void reinitialize() = 0;

    virtual void updateState() = 0;

    bool isExhausted() { return is_exhausted; }

    void setExhausted(bool exhausted) { is_exhausted = exhausted; }

    virtual ~IVisitor() = default;

private:
    /**
     * This variable is for detecting whether a visitor's next visit will be able
     *  to yield a new item.
     */
    bool is_exhausted = false;
};

}