-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.H
70 lines (43 loc) · 1.41 KB
/
search.H
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#ifndef SEARCH_H
#define SEARCH_H
#include "filter.H"
#include <stdio.h>
#include <string>
class Args;
/// Generic file search class
class Search {
public:
/// Returns a platform-specific instance
static Search & instance(Args const & args);
/// Destroys the global instance
static void destroyInstance();
/// Disabled default constructor
Search() = delete;
/// Disabled copy constructor
Search(Search const &) = delete;
/// Disabled move constructor
Search(Search &&) = delete;
/// Disabled assignment operators
Search & operator=(Search const &) = delete;
Search & operator=(Search &&) = delete;
/// Performs the search
/// @param[in] args Command line arguments
void search() const;
protected:
Args const & _args;
Filter _filter;
static void fclose(FILE * f);
/// Constructor
explicit Search(Args const & args);
/// Destructor
virtual ~Search();
bool excludeFileByContent(std::string const & path) const;
void findInFile(std::string const & path) const;
virtual size_t printMatch(char const * buf, Match const & pmatch, bool nocolor) const;
virtual void findFiles(std::string const & root, std::string const & path, bool dirMatch) const = 0;
virtual void execCmd(std::string const & cmd, std::string const & path) const = 0;
private:
/// Global instance
static Search * _instance;
};
#endif