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

Last change on this file since 5473 was 5473, checked in by cameron, 2 years ago

Initial support for -q, -l, -L modes, grep options reorganization

File size: 2.1 KB
Line 
1/*
2 *  Copyright (c) 2016 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 DO_GREP_H
7#define DO_GREP_H
8#include <grep_type.h>  // for GrepType, GrepType::Normal
9#include <string>       // for string
10#include <vector>
11#include <re/re_parser.h>  // for
12
13namespace re { class CC; }
14namespace re { class RE; }
15namespace llvm { namespace cl { class OptionCategory; } }
16
17namespace grep {
18
19// Regular expression syntax, interpretation and processing.
20extern re::RE_Syntax RegexpSyntax;
21extern bool IgnoreCaseFlag;
22extern bool InvertMatchFlag;
23extern bool LineRegexpFlag;
24extern bool WordRegexpFlag;
25
26// Grep input sources and interpretation
27extern bool RecursiveFlag;
28extern bool DereferenceRecursiveFlag;
29
30// Grep output modes and flags.
31enum GrepModeType {QuietMode, FilesWithMatch, FilesWithoutMatch, CountOnly, NormalMode};
32extern GrepModeType Mode;
33
34
35const llvm::cl::OptionCategory * grep_regexp_flags();
36const llvm::cl::OptionCategory * grep_input_flags();
37const llvm::cl::OptionCategory * grep_output_flags();
38
39class GrepEngine {
40public:
41
42    GrepEngine();
43
44    void grepCodeGen(std::vector<re::RE *> REs, GrepModeType grepMode, bool UTF_16, GrepSource grepSource, GrepType grepType = GrepType::Normal);
45
46    void grepCodeGen_nvptx(std::vector<re::RE *> REs, GrepModeType grepMode, bool UTF_16);
47
48    void doGrep(const std::string & fileName) const;
49
50        uint64_t doGrep(const std::string & fileName, const uint32_t fileIdx) const;
51
52    uint64_t doGrep(const int32_t fileDescriptor, const uint32_t fileIdx) const;
53   
54    void doGrep(const char * buffer, const uint64_t length, const uint32_t fileIdx) const;
55
56    re::CC * grepCodepoints();
57
58    const std::vector<std::string> & grepPropertyValues(const std::string & propertyName);
59   
60private:
61   
62    void * mGrepFunction;
63};
64
65
66re::CC * getParsedCodePointSet();
67void setParsedCodePointSet();
68
69void setParsedPropertyValues();
70
71void initFileResult(std::vector<std::string> filenames);
72void PrintResult(GrepModeType grepMode, std::vector<size_t> & total_CountOnly);
73}
74
75#endif
Note: See TracBrowser for help on using the repository browser.