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

Last change on this file since 5771 was 5771, checked in by nmedfort, 17 months ago

Minor changes and hopefully a fix for bug exposed by base64 test

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