LLDB  mainline
RegularExpression.cpp
Go to the documentation of this file.
1 //===-- RegularExpression.cpp ---------------------------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8 
10 
11 #include <string>
12 
13 using namespace lldb_private;
14 
16  : m_regex_text(std::string(str)),
17  // m_regex does not reference str anymore after it is constructed.
18  m_regex(llvm::Regex(str)) {}
19 
21  : RegularExpression(rhs.GetText()) {}
22 
24  llvm::StringRef str,
26  if (!IsValid())
27  return false;
28  return m_regex.match(str, matches);
29 }
30 
31 bool RegularExpression::IsValid() const { return m_regex.isValid(); }
32 
33 llvm::StringRef RegularExpression::GetText() const { return m_regex_text; }
34 
37  if (!m_regex.isValid(error))
38  return llvm::make_error<llvm::StringError>(error,
39  llvm::inconvertibleErrorCode());
40  return llvm::Error::success();
41 }
RegularExpression.h
llvm
Definition: Debugger.h:49
lldb_private::RegularExpression
Definition: RegularExpression.h:18
lldb_private::RegularExpression::m_regex_text
std::string m_regex_text
A copy of the original regular expression text.
Definition: RegularExpression.h:87
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb_private::RegularExpression::IsValid
bool IsValid() const
Test if this object contains a valid regular expression.
Definition: RegularExpression.cpp:31
lldb_private::RegularExpression::m_regex
llvm::Regex m_regex
The compiled regular expression.
Definition: RegularExpression.h:89
lldb_private::RegularExpression::RegularExpression
RegularExpression()=default
The default constructor that initializes the object state such that it contains no compiled regular e...
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
lldb_private::RegularExpression::GetError
llvm::Error GetError() const
Return an error if the regular expression failed to compile.
Definition: RegularExpression.cpp:35
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
Error
llvm::Error Error
Definition: UdtRecordCompleter.cpp:29
lldb_private::RegularExpression::Execute
bool Execute(llvm::StringRef string, llvm::SmallVectorImpl< llvm::StringRef > *matches=nullptr) const
Execute a regular expression match using the compiled regular expression that is already in this obje...
Definition: RegularExpression.cpp:23
llvm::SmallVectorImpl
Definition: Disassembler.h:42
lldb_private::RegularExpression::GetText
llvm::StringRef GetText() const
Access the regular expression text.
Definition: RegularExpression.cpp:33