blob: 8e9678bbd2e66a12c54bf02091fdf2f957ab2a86 [file] [log] [blame]
Shinichiro Hamaji5f57a992015-06-30 19:39:39 +09001// Copyright 2015 Google Inc. All rights reserved
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#ifndef FIND_H_
16#define FIND_H_
17
Shinichiro Hamajia5a5ef62015-07-31 14:45:41 +090018#include <memory>
Shinichiro Hamaji5f57a992015-06-30 19:39:39 +090019#include <string>
Shinichiro Hamajia5a5ef62015-07-31 14:45:41 +090020#include <vector>
21
22#include "string_piece.h"
Shinichiro Hamaji5f57a992015-06-30 19:39:39 +090023
24using namespace std;
25
Shinichiro Hamajia5a5ef62015-07-31 14:45:41 +090026class FindCond;
27
28struct FindCommand {
29 FindCommand();
30 ~FindCommand() = default;
31
Shinichiro Hamaji0876e092015-07-31 15:52:43 +090032 bool Parse(const string& cmd);
33
Shinichiro Hamajia5a5ef62015-07-31 14:45:41 +090034 StringPiece chdir;
35 StringPiece testdir;
36 vector<StringPiece> finddirs;
37 bool follows_symlinks;
38 unique_ptr<FindCond> print_cond;
39 unique_ptr<FindCond> prune_cond;
40 int depth;
41};
42
Shinichiro Hamaji5f57a992015-06-30 19:39:39 +090043class FindEmulator {
44 public:
45 virtual ~FindEmulator() = default;
46
47 virtual bool HandleFind(const string& cmd, string* out) = 0;
48
49 static FindEmulator* Get();
50
51 protected:
52 FindEmulator() = default;
53};
54
55void InitFindEmulator();
56
57#endif // FIND_H_