Shinichiro Hamaji | 5f57a99 | 2015-06-30 19:39:39 +0900 | [diff] [blame] | 1 | // 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 Hamaji | a5a5ef6 | 2015-07-31 14:45:41 +0900 | [diff] [blame] | 18 | #include <memory> |
Shinichiro Hamaji | 5f57a99 | 2015-06-30 19:39:39 +0900 | [diff] [blame] | 19 | #include <string> |
Shinichiro Hamaji | a5a5ef6 | 2015-07-31 14:45:41 +0900 | [diff] [blame] | 20 | #include <vector> |
| 21 | |
| 22 | #include "string_piece.h" |
Shinichiro Hamaji | 5f57a99 | 2015-06-30 19:39:39 +0900 | [diff] [blame] | 23 | |
| 24 | using namespace std; |
| 25 | |
Shinichiro Hamaji | a5a5ef6 | 2015-07-31 14:45:41 +0900 | [diff] [blame] | 26 | class FindCond; |
| 27 | |
| 28 | struct FindCommand { |
| 29 | FindCommand(); |
| 30 | ~FindCommand() = default; |
| 31 | |
Shinichiro Hamaji | 0876e09 | 2015-07-31 15:52:43 +0900 | [diff] [blame^] | 32 | bool Parse(const string& cmd); |
| 33 | |
Shinichiro Hamaji | a5a5ef6 | 2015-07-31 14:45:41 +0900 | [diff] [blame] | 34 | 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 Hamaji | 5f57a99 | 2015-06-30 19:39:39 +0900 | [diff] [blame] | 43 | class 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 | |
| 55 | void InitFindEmulator(); |
| 56 | |
| 57 | #endif // FIND_H_ |