summaryrefslogtreecommitdiffstats
path: root/yql/essentials/tools/yql_highlight/generator.cpp
blob: 45f9562476032f188b024c9e75a47d2e830a0491 (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
#include "generator.h"

#include <util/stream/file.h>

namespace NSQLHighlight {

    class TOnlyFunctionGenerator: public IGenerator {
    public:
        explicit TOnlyFunctionGenerator(TGeneratorFunction function)
            : Function_(std::move(function))
        {
        }

        void Write(IOutputStream& out, const THighlighting& highlighting, bool ansi) override {
            Function_(out, highlighting, ansi);
        }

        void Write(const TFsPath& path, const THighlighting& highlighting, bool ansi) override {
            TFileOutput out(path);
            Write(out, highlighting, ansi);
        }

    private:
        TGeneratorFunction Function_;
    };

    IGenerator::TPtr MakeOnlyFileGenerator(TGeneratorFunction function) {
        return new TOnlyFunctionGenerator(std::move(function));
    }

} // namespace NSQLHighlight