source: icGREP/icgrep-devel/icgrep/grep_engine.h @ 5732

Last change on this file since 5732 was 5707, checked in by cameron, 19 months ago

Fix for older compilers

File size: 2.2 KB
Line 
1/*
2 *  Copyright (c) 2017 International Characters.
3 *  This software is licensed to the public under the Open Software License 3.0.
4 *  icgrep is a trademark of International Characters.
5 */
6#ifndef GREP_ENGINE_H
7#define GREP_ENGINE_H
8#include <grep_interface.h>
9#include <kernels/streamset.h>
10#include <toolchain/grep_pipeline.h>
11#include <string>       // for string
12#include <vector>
13#include <sstream>
14#include <mutex>
15
16namespace re { class CC; }
17namespace re { class RE; }
18namespace llvm { namespace cl { class OptionCategory; } }
19class Driver;
20
21
22namespace grep {
23
24class GrepEngine {
25public:
26
27    GrepEngine();
28    virtual ~GrepEngine();
29   
30    void initFileResult(std::vector<std::string> & filenames);
31    virtual void grepCodeGen(std::vector<re::RE *> REs);
32    bool searchAllFiles();
33    void writeMatches();
34   
35protected:
36    std::pair<parabix::StreamSetBuffer *, parabix::StreamSetBuffer *> grepPipeline(std::vector<re::RE *> & REs, parabix::StreamSetBuffer * ByteStream);
37
38    static void * DoGrepThreadFunction(void *args);
39    virtual uint64_t doGrep(const std::string & fileName, const uint32_t fileIdx);
40    std::string linePrefix(std::string fileName);
41    int32_t openFile(const std::string & fileName, std::stringstream * msgstrm);
42
43    Driver * mGrepDriver;
44
45    std::vector<std::string> inputFiles;
46    std::vector<std::unique_ptr<std::stringstream>> mResultStrs;
47   
48    std::string mFileSuffix;
49   
50    bool grepMatchFound;
51    std::mutex count_mutex;
52    size_t fileCount;
53    bool mMoveMatchesToEOL;
54};
55
56class EmitMatchesEngine : public GrepEngine {
57public:
58    EmitMatchesEngine();
59    void grepCodeGen(std::vector<re::RE *> REs) override;
60private:
61    uint64_t doGrep(const std::string & fileName, const uint32_t fileIdx) override;
62};
63
64class CountOnlyEngine : public GrepEngine {
65public:
66    CountOnlyEngine();
67private:
68    uint64_t doGrep(const std::string & fileName, const uint32_t fileIdx) override;
69};
70
71class MatchOnlyEngine : public GrepEngine {
72public:
73    MatchOnlyEngine(bool showFilesWithoutMatch);
74private:
75    uint64_t doGrep(const std::string & fileName, const uint32_t fileIdx) override;
76    unsigned mRequiredCount;
77};
78
79class QuietModeEngine : public GrepEngine {
80public:
81    QuietModeEngine();
82};
83
84}
85
86#endif
Note: See TracBrowser for help on using the repository browser.