1 //===-- LogFilterRegex.h ----------------------------------------*- C++ -*-===// 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 9 #ifndef LLDB_TOOLS_DEBUGSERVER_SOURCE_MACOSX_DARWINLOG_LOGFILTERREGEX_H 10 #define LLDB_TOOLS_DEBUGSERVER_SOURCE_MACOSX_DARWINLOG_LOGFILTERREGEX_H 11 12 // C includes 13 #include <regex.h> 14 15 // C++ includes 16 #include <string> 17 18 #include "DarwinLogInterfaces.h" 19 #include "DarwinLogTypes.h" 20 #include "LogFilter.h" 21 22 class LogFilterRegex : public LogFilter { 23 public: 24 LogFilterRegex(bool match_accepts, FilterTarget filter_target, 25 const std::string ®ex); 26 27 virtual ~LogFilterRegex(); 28 IsValid()29 bool IsValid() const { return m_is_valid; } 30 GetErrorAsCString()31 const char *GetErrorAsCString() const { return m_error_text.c_str(); } 32 33 bool DoesMatch(const LogMessage &message) const override; 34 35 private: 36 const FilterTarget m_filter_target; 37 const std::string m_regex_text; 38 regex_t m_regex; 39 bool m_is_valid; 40 std::string m_error_text; 41 }; 42 43 #endif // LLDB_TOOLS_DEBUGSERVER_SOURCE_MACOSX_DARWINLOG_LOGFILTERREGEX_H 44