aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/providers/result/expr_nodes/yql_res_expr_nodes.h
blob: ec0868d9415f9c0e2377fe745759807f8369be41 (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#pragma once

#include <yql/essentials/providers/result/expr_nodes/yql_res_expr_nodes.gen.h>
#include <yql/essentials/providers/common/provider/yql_provider_names.h>

#include <yql/essentials/core/expr_nodes/yql_expr_nodes.h>

namespace NYql {
namespace NNodes {

#include <yql/essentials/providers/result/expr_nodes/yql_res_expr_nodes.decl.inl.h>

class TResultDataSink: public NGenerated::TResultDataSinkStub<TExprBase, TCallable, TCoAtom> {
public:
    explicit TResultDataSink(const TExprNode* node)
        : TResultDataSinkStub(node)
    {
    }

    explicit TResultDataSink(const TExprNode::TPtr& node)
        : TResultDataSinkStub(node)
    {
    }

    static bool Match(const TExprNode* node) {
        if (!TResultDataSinkStub::Match(node)) {
            return false;
        }

        if (node->Child(0)->Content() != ResultProviderName) {
            return false;
        }

        return true;
    }
};

#include <yql/essentials/providers/result/expr_nodes/yql_res_expr_nodes.defs.inl.h>

template<typename TParent>
class TNodeBuilder<TParent, TResultDataSink> : TNodeBuilderBase
{
public:
    typedef std::function<TParent& (const TResultDataSink&)> BuildFuncType;
    typedef std::function<TExprBase (const TStringBuf& arg)> GetArgFuncType;
    typedef TResultDataSink ResultType;

    TNodeBuilder(TExprContext& ctx, TPositionHandle pos, BuildFuncType buildFunc, GetArgFuncType getArgFunc)
        : TNodeBuilderBase(ctx, pos, getArgFunc)
        , BuildFunc(buildFunc) {}

    TParent& Build() {
        auto atom = this->Ctx.NewAtom(this->Pos, ResultProviderName);
        auto node = this->Ctx.NewCallable(this->Pos, "DataSink", { atom });
        return BuildFunc(TResultDataSink(node));
    }

private:
    BuildFuncType BuildFunc;
};

} // namespace NNodes
} // namespace NYql