11c3bbb01SEd Maste //===-- NameMatches.cpp -----------------------------------------*- C++ -*-===//
21c3bbb01SEd Maste //
31c3bbb01SEd Maste //                     The LLVM Compiler Infrastructure
41c3bbb01SEd Maste //
51c3bbb01SEd Maste // This file is distributed under the University of Illinois Open Source
61c3bbb01SEd Maste // License. See LICENSE.TXT for details.
71c3bbb01SEd Maste //
81c3bbb01SEd Maste //===----------------------------------------------------------------------===//
91c3bbb01SEd Maste #include "lldb/Utility/NameMatches.h"
10*f678e45dSDimitry Andric #include "lldb/Utility/RegularExpression.h"
111c3bbb01SEd Maste 
121c3bbb01SEd Maste #include "llvm/ADT/StringRef.h"
131c3bbb01SEd Maste 
141c3bbb01SEd Maste using namespace lldb_private;
151c3bbb01SEd Maste 
NameMatches(llvm::StringRef name,NameMatch match_type,llvm::StringRef match)16*f678e45dSDimitry Andric bool lldb_private::NameMatches(llvm::StringRef name, NameMatch match_type,
17435933ddSDimitry Andric                                llvm::StringRef match) {
18435933ddSDimitry Andric   switch (match_type) {
19*f678e45dSDimitry Andric   case NameMatch::Ignore:
201c3bbb01SEd Maste     return true;
21*f678e45dSDimitry Andric   case NameMatch::Equals:
22435933ddSDimitry Andric     return name == match;
23*f678e45dSDimitry Andric   case NameMatch::Contains:
24435933ddSDimitry Andric     return name.contains(match);
25*f678e45dSDimitry Andric   case NameMatch::StartsWith:
26435933ddSDimitry Andric     return name.startswith(match);
27*f678e45dSDimitry Andric   case NameMatch::EndsWith:
28435933ddSDimitry Andric     return name.endswith(match);
29*f678e45dSDimitry Andric   case NameMatch::RegularExpression: {
301c3bbb01SEd Maste     RegularExpression regex(match);
311c3bbb01SEd Maste     return regex.Execute(name);
32*f678e45dSDimitry Andric   }
331c3bbb01SEd Maste   }
341c3bbb01SEd Maste   return false;
351c3bbb01SEd Maste }
36