LogViewer
A modern log viewer with AI-assisted analysis (Qt 6)
Loading...
Searching...
No Matches
filters::RegexFilterStrategy Class Reference

Regex-based matching using std::regex. More...

#include <IFilterStrategy.hpp>

Inheritance diagram for filters::RegexFilterStrategy:
Inheritance graph
Collaboration diagram for filters::RegexFilterStrategy:
Collaboration graph

Public Member Functions

 RegexFilterStrategy ()=default
 
 RegexFilterStrategy (const RegexFilterStrategy &) noexcept
 
RegexFilterStrategy & operator= (const RegexFilterStrategy &) noexcept
 
bool matches (const std::string &value, const std::string &pattern, bool caseSensitive) const override
 Match a value against the pattern.
 
bool isValidPattern (const std::string &pattern) const override
 Validate pattern syntax.
 
std::string getName () const override
 Get strategy name for serialization/debugging.
 
std::unique_ptr< IFilterStrategy > clone () const override
 Clone this strategy (for copy semantics)
 

Private Attributes

std::mutex m_cacheMutex
 
std::string m_cachedPattern
 
bool m_cachedCaseSensitive {false}
 
bool m_hasCachedRegex {false}
 
std::regex m_cachedRegex
 

Detailed Description

Regex-based matching using std::regex.

Default strategy providing full regex support. Patterns are compiled once for efficiency.

Performance:
  • Compilation: O(m) where m = pattern length
  • Matching: O(n) where n = value length
  • Memory: Stores compiled regex state machine

Constructor & Destructor Documentation

◆ RegexFilterStrategy() [1/2]

filters::RegexFilterStrategy::RegexFilterStrategy ( )
default

◆ RegexFilterStrategy() [2/2]

filters::RegexFilterStrategy::RegexFilterStrategy ( const RegexFilterStrategy &  )
inlinenoexcept

Member Function Documentation

◆ clone()

std::unique_ptr< IFilterStrategy > filters::RegexFilterStrategy::clone ( ) const
inlineoverridevirtual

Clone this strategy (for copy semantics)

Returns
Unique pointer to cloned strategy

Implements filters::IFilterStrategy.

◆ getName()

std::string filters::RegexFilterStrategy::getName ( ) const
inlineoverridevirtual

Get strategy name for serialization/debugging.

Returns
Strategy identifier (e.g., "regex", "exact", "fuzzy")

Implements filters::IFilterStrategy.

◆ isValidPattern()

bool filters::RegexFilterStrategy::isValidPattern ( const std::string &  pattern) const
overridevirtual

Validate pattern syntax.

Parameters
patternThe pattern to validate
Returns
true if pattern is valid for this strategy, false otherwise

Used to provide early feedback when constructing filters.

Implements filters::IFilterStrategy.

◆ matches()

bool filters::RegexFilterStrategy::matches ( const std::string &  value,
const std::string &  pattern,
bool  caseSensitive 
) const
overridevirtual

Match a value against the pattern.

Parameters
valueThe string to test
patternThe pattern to match against
caseSensitiveWhether matching should be case-sensitive
Returns
true if value matches pattern, false otherwise
Thread Safety:
Must be thread-safe for concurrent calls.

Implements filters::IFilterStrategy.

Here is the call graph for this function:

◆ operator=()

RegexFilterStrategy & filters::RegexFilterStrategy::operator= ( const RegexFilterStrategy &  )
inlinenoexcept

Member Data Documentation

◆ m_cachedCaseSensitive

bool filters::RegexFilterStrategy::m_cachedCaseSensitive {false}
mutableprivate

◆ m_cachedPattern

std::string filters::RegexFilterStrategy::m_cachedPattern
mutableprivate

◆ m_cachedRegex

std::regex filters::RegexFilterStrategy::m_cachedRegex
mutableprivate

◆ m_cacheMutex

std::mutex filters::RegexFilterStrategy::m_cacheMutex
mutableprivate

◆ m_hasCachedRegex

bool filters::RegexFilterStrategy::m_hasCachedRegex {false}
mutableprivate

The documentation for this class was generated from the following files: