1 //===-- GlobPattern.h - glob pattern matcher implementation -*- C++ -*-----===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements a glob pattern matcher. The glob pattern is the
11 // rule used by the shell.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_SUPPORT_GLOB_PATTERN_H
16 #define LLVM_SUPPORT_GLOB_PATTERN_H
18 #include "llvm/ADT/BitVector.h"
19 #include "llvm/ADT/Optional.h"
20 #include "llvm/ADT/StringRef.h"
21 #include "llvm/Support/Error.h"
24 // This class represents a glob pattern. Supported metacharacters
25 // are "*", "?", "[<chars>]" and "[^<chars>]".
28 template <typename T> class ArrayRef;
32 static Expected<GlobPattern> create(StringRef Pat);
33 bool match(StringRef S) const;
36 bool matchOne(ArrayRef<BitVector> Pat, StringRef S) const;
38 // Parsed glob pattern.
39 std::vector<BitVector> Tokens;
41 // The following members are for optimization.
42 Optional<StringRef> Exact;
43 Optional<StringRef> Prefix;
44 Optional<StringRef> Suffix;
48 #endif // LLVM_SUPPORT_GLOB_PATTERN_H