1 //===-- GlobPattern.h - glob pattern matcher implementation -*- C++ -*-----===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file implements a glob pattern matcher. The glob pattern is the
10 // rule used by the shell.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_SUPPORT_GLOB_PATTERN_H
15 #define LLVM_SUPPORT_GLOB_PATTERN_H
17 #include "llvm/ADT/BitVector.h"
18 #include "llvm/ADT/Optional.h"
19 #include "llvm/ADT/StringRef.h"
20 #include "llvm/Support/Error.h"
23 // This class represents a glob pattern. Supported metacharacters
24 // are "*", "?", "\", "[<chars>]", "[^<chars>]", and "[!<chars>]".
27 template <typename T
> class ArrayRef
;
31 static Expected
<GlobPattern
> create(StringRef Pat
);
32 bool match(StringRef S
) const;
35 bool matchOne(ArrayRef
<BitVector
> Pat
, StringRef S
) const;
37 // Parsed glob pattern.
38 std::vector
<BitVector
> Tokens
;
40 // The following members are for optimization.
41 Optional
<StringRef
> Exact
;
42 Optional
<StringRef
> Prefix
;
43 Optional
<StringRef
> Suffix
;
47 #endif // LLVM_SUPPORT_GLOB_PATTERN_H