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

Last change on this file since 5695 was 5695, checked in by cameron, 20 months ago

Complete the scanmatch kernel conversion to use MatchAccumulator? objects

File size: 1.9 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 <grep_type.h>  // for GrepType, GrepType::Normal
10#include <toolchain/grep_pipeline.h>
11#include <string>       // for string
12#include <vector>
13#include <re/re_parser.h>
14#include <re/re_multiplex.h>
15#include <sstream>
16#include <mutex>
17
18namespace re { class CC; }
19namespace re { class RE; }
20namespace llvm { namespace cl { class OptionCategory; } }
21class Driver;
22
23
24namespace grep {
25
26// Thread function only.
27void *DoGrepThreadFunction(void *args);
28   
29   
30   
31    class NonNormalizingReportMatch : public MatchAccumulator {
32    public:
33        NonNormalizingReportMatch(std::string linePrefix) : mLineCount(0), mPrevious_line_end(nullptr) {}
34        void accumulate_match(const size_t lineNum, char * line_start, char * line_end) override;
35        void finalize_match(char * buffer_end) override;
36        std::string mLinePrefix;
37        size_t mLineCount;
38        char * mPrevious_line_end;
39        std::stringstream mResultStr;
40       
41    };
42   
43   
44   
45class GrepEngine {
46public:
47
48    GrepEngine() : mGrepDriver(nullptr), grepMatchFound(false), fileCount(0) {}
49
50
51    ~GrepEngine();
52   
53    void initFileResult(std::vector<std::string> filenames);
54   
55    void grepCodeGen(std::vector<re::RE *> REs, GrepModeType grepMode);
56
57    uint64_t doGrep(const std::string & fileName, const uint32_t fileIdx);
58
59    uint64_t doGrep(const int32_t fileDescriptor, const uint32_t fileIdx);
60   
61    void PrintResults();
62   
63   
64
65    Driver * mGrepDriver;
66    bool grepMatchFound;
67
68    std::vector<NonNormalizingReportMatch *> resultAccums;
69    std::vector<std::string> inputFiles;
70   
71    std::mutex count_mutex;
72    size_t fileCount;
73   
74};
75
76   
77}
78
79#endif
Note: See TracBrowser for help on using the repository browser.