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

Fuzzy matching using Levenshtein distance. More...

#include <IFilterStrategy.hpp>

Inheritance diagram for filters::FuzzyMatchStrategy:
Inheritance graph
Collaboration diagram for filters::FuzzyMatchStrategy:
Collaboration graph

Public Member Functions

 FuzzyMatchStrategy (int maxDistance=2)
 Construct fuzzy matcher with max edit distance.
 
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)
 
int getMaxDistance () const
 

Static Private Member Functions

static int levenshteinDistance (const std::string &s1, const std::string &s2)
 Calculate Levenshtein distance between two strings.
 

Private Attributes

int m_maxDistance
 

Detailed Description

Fuzzy matching using Levenshtein distance.

Matches strings within a specified edit distance. Useful for typo-tolerant filtering.

Performance:
  • Matching: O(n*m) dynamic programming
  • Memory: O(min(n,m)) with optimized algorithm

Constructor & Destructor Documentation

◆ FuzzyMatchStrategy()

filters::FuzzyMatchStrategy::FuzzyMatchStrategy ( int  maxDistance = 2)
inlineexplicit

Construct fuzzy matcher with max edit distance.

Parameters
maxDistanceMaximum Levenshtein distance (default 2)

Member Function Documentation

◆ clone()

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

Clone this strategy (for copy semantics)

Returns
Unique pointer to cloned strategy

Implements filters::IFilterStrategy.

◆ getMaxDistance()

int filters::FuzzyMatchStrategy::getMaxDistance ( ) const
inline

◆ getName()

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

Get strategy name for serialization/debugging.

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

Implements filters::IFilterStrategy.

◆ isValidPattern()

bool filters::FuzzyMatchStrategy::isValidPattern ( const std::string &  pattern) const
inlineoverridevirtual

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.

◆ levenshteinDistance()

int filters::FuzzyMatchStrategy::levenshteinDistance ( const std::string &  s1,
const std::string &  s2 
)
staticprivate

Calculate Levenshtein distance between two strings.

Parameters
s1First string
s2Second string
Returns
Edit distance (insertions, deletions, substitutions)
Here is the caller graph for this function:

◆ matches()

bool filters::FuzzyMatchStrategy::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:

Member Data Documentation

◆ m_maxDistance

int filters::FuzzyMatchStrategy::m_maxDistance
private

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