yql_res_expr_nodes.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #pragma once
  2. #include <yql/essentials/providers/result/expr_nodes/yql_res_expr_nodes.gen.h>
  3. #include <yql/essentials/providers/common/provider/yql_provider_names.h>
  4. #include <yql/essentials/core/expr_nodes/yql_expr_nodes.h>
  5. namespace NYql {
  6. namespace NNodes {
  7. #include <yql/essentials/providers/result/expr_nodes/yql_res_expr_nodes.decl.inl.h>
  8. class TResultDataSink: public NGenerated::TResultDataSinkStub<TExprBase, TCallable, TCoAtom> {
  9. public:
  10. explicit TResultDataSink(const TExprNode* node)
  11. : TResultDataSinkStub(node)
  12. {
  13. }
  14. explicit TResultDataSink(const TExprNode::TPtr& node)
  15. : TResultDataSinkStub(node)
  16. {
  17. }
  18. static bool Match(const TExprNode* node) {
  19. if (!TResultDataSinkStub::Match(node)) {
  20. return false;
  21. }
  22. if (node->Child(0)->Content() != ResultProviderName) {
  23. return false;
  24. }
  25. return true;
  26. }
  27. };
  28. #include <yql/essentials/providers/result/expr_nodes/yql_res_expr_nodes.defs.inl.h>
  29. template<typename TParent>
  30. class TNodeBuilder<TParent, TResultDataSink> : TNodeBuilderBase
  31. {
  32. public:
  33. typedef std::function<TParent& (const TResultDataSink&)> BuildFuncType;
  34. typedef std::function<TExprBase (const TStringBuf& arg)> GetArgFuncType;
  35. typedef TResultDataSink ResultType;
  36. TNodeBuilder(TExprContext& ctx, TPositionHandle pos, BuildFuncType buildFunc, GetArgFuncType getArgFunc)
  37. : TNodeBuilderBase(ctx, pos, getArgFunc)
  38. , BuildFunc(buildFunc) {}
  39. TParent& Build() {
  40. auto atom = this->Ctx.NewAtom(this->Pos, ResultProviderName);
  41. auto node = this->Ctx.NewCallable(this->Pos, "DataSink", { atom });
  42. return BuildFunc(TResultDataSink(node));
  43. }
  44. private:
  45. BuildFuncType BuildFunc;
  46. };
  47. } // namespace NNodes
  48. } // namespace NYql