LogViewer
A modern log viewer with AI-assisted analysis (Qt 6)
Loading...
Searching...
No Matches
ui::qt::utils::SearchEngine Class Reference

Advanced search engine supporting multiple search modes. More...

#include <SearchEngine.hpp>

Collaboration diagram for ui::qt::utils::SearchEngine:
Collaboration graph

Classes

struct  AdvancedQuery
 

Public Member Functions

 SearchEngine ()
 
void SetMode (SearchMode mode)
 Set search mode.
 
SearchMode GetMode () const
 
void SetCaseSensitive (bool sensitive)
 Set case sensitivity for substring/advanced modes.
 
bool IsCaseSensitive () const
 
bool CompilePattern (const std::string &pattern, std::string &outError)
 Compile a search pattern (validates regex, parses advanced syntax)
 
bool Matches (const std::string &text) const
 Check if a string matches the current search pattern.
 
std::vector< SearchMatch > FindMatches (const std::string &text) const
 Find all matches in a string (for highlighting)
 
const std::string & GetPattern () const
 Get compiled pattern (for display/logging)
 
void Clear ()
 Clear current pattern.
 
void AddToHistory (const std::string &term)
 Add to search history.
 
const std::vector< std::string > & GetHistory () const
 Get search history (most recent first)
 
void ClearHistory ()
 Clear history.
 
std::vector< std::string > GetSuggestions (const std::string &prefix) const
 Get suggestions based on current input (for autocomplete)
 

Private Member Functions

bool compileSimple (const std::string &pattern)
 
bool compileRegex (const std::string &pattern, std::string &outError)
 
bool compileAdvanced (const std::string &pattern, std::string &outError)
 
bool matchesSimple (const std::string &text) const
 
bool matchesRegex (const std::string &text) const
 
bool matchesAdvanced (const std::string &text) const
 
std::vector< SearchMatch > findSimpleMatches (const std::string &text) const
 
std::vector< SearchMatch > findRegexMatches (const std::string &text) const
 

Private Attributes

SearchMode m_mode {SearchMode::Substring}
 
bool m_caseSensitive {false}
 
std::string m_pattern
 
std::optional< std::regex > m_compiledRegex {std::nullopt}
 
std::optional< AdvancedQuery > m_advancedQuery {std::nullopt}
 
std::vector< std::string > m_history
 
std::string m_normalizedPattern
 
bool m_normalizedPatternValid {false}
 

Static Private Attributes

static constexpr size_t kMaxHistorySize = 50
 

Detailed Description

Advanced search engine supporting multiple search modes.

Supports:

  • Simple substring search
  • Case-sensitive search
  • Regex patterns
  • Advanced syntax: "term1 AND term2", "term1 OR term2", "NOT term1"

Constructor & Destructor Documentation

◆ SearchEngine()

ui::qt::utils::SearchEngine::SearchEngine ( )
default

Member Function Documentation

◆ AddToHistory()

void ui::qt::utils::SearchEngine::AddToHistory ( const std::string &  term)

Add to search history.

◆ Clear()

void ui::qt::utils::SearchEngine::Clear ( )

Clear current pattern.

◆ ClearHistory()

void ui::qt::utils::SearchEngine::ClearHistory ( )
inline

Clear history.

◆ compileAdvanced()

bool ui::qt::utils::SearchEngine::compileAdvanced ( const std::string &  pattern,
std::string &  outError 
)
private
Here is the caller graph for this function:

◆ CompilePattern()

bool ui::qt::utils::SearchEngine::CompilePattern ( const std::string &  pattern,
std::string &  outError 
)

Compile a search pattern (validates regex, parses advanced syntax)

Here is the call graph for this function:
Here is the caller graph for this function:

◆ compileRegex()

bool ui::qt::utils::SearchEngine::compileRegex ( const std::string &  pattern,
std::string &  outError 
)
private
Here is the caller graph for this function:

◆ compileSimple()

bool ui::qt::utils::SearchEngine::compileSimple ( const std::string &  pattern)
private
Here is the caller graph for this function:

◆ FindMatches()

std::vector< SearchMatch > ui::qt::utils::SearchEngine::FindMatches ( const std::string &  text) const

Find all matches in a string (for highlighting)

Here is the call graph for this function:
Here is the caller graph for this function:

◆ findRegexMatches()

std::vector< SearchMatch > ui::qt::utils::SearchEngine::findRegexMatches ( const std::string &  text) const
private
Here is the caller graph for this function:

◆ findSimpleMatches()

std::vector< SearchMatch > ui::qt::utils::SearchEngine::findSimpleMatches ( const std::string &  text) const
private
Here is the caller graph for this function:

◆ GetHistory()

const std::vector< std::string > & ui::qt::utils::SearchEngine::GetHistory ( ) const
inline

Get search history (most recent first)

◆ GetMode()

SearchMode ui::qt::utils::SearchEngine::GetMode ( ) const
inline

◆ GetPattern()

const std::string & ui::qt::utils::SearchEngine::GetPattern ( ) const
inline

Get compiled pattern (for display/logging)

◆ GetSuggestions()

std::vector< std::string > ui::qt::utils::SearchEngine::GetSuggestions ( const std::string &  prefix) const

Get suggestions based on current input (for autocomplete)

◆ IsCaseSensitive()

bool ui::qt::utils::SearchEngine::IsCaseSensitive ( ) const
inline

◆ Matches()

bool ui::qt::utils::SearchEngine::Matches ( const std::string &  text) const

Check if a string matches the current search pattern.

Here is the call graph for this function:

◆ matchesAdvanced()

bool ui::qt::utils::SearchEngine::matchesAdvanced ( const std::string &  text) const
private
Here is the caller graph for this function:

◆ matchesRegex()

bool ui::qt::utils::SearchEngine::matchesRegex ( const std::string &  text) const
private
Here is the caller graph for this function:

◆ matchesSimple()

bool ui::qt::utils::SearchEngine::matchesSimple ( const std::string &  text) const
private
Here is the caller graph for this function:

◆ SetCaseSensitive()

void ui::qt::utils::SearchEngine::SetCaseSensitive ( bool  sensitive)
inline

Set case sensitivity for substring/advanced modes.

Here is the caller graph for this function:

◆ SetMode()

void ui::qt::utils::SearchEngine::SetMode ( SearchMode  mode)

Set search mode.

Here is the caller graph for this function:

Member Data Documentation

◆ kMaxHistorySize

constexpr size_t ui::qt::utils::SearchEngine::kMaxHistorySize = 50
staticconstexprprivate

◆ m_advancedQuery

std::optional<AdvancedQuery> ui::qt::utils::SearchEngine::m_advancedQuery {std::nullopt}
private

◆ m_caseSensitive

bool ui::qt::utils::SearchEngine::m_caseSensitive {false}
private

◆ m_compiledRegex

std::optional<std::regex> ui::qt::utils::SearchEngine::m_compiledRegex {std::nullopt}
private

◆ m_history

std::vector<std::string> ui::qt::utils::SearchEngine::m_history
private

◆ m_mode

SearchMode ui::qt::utils::SearchEngine::m_mode {SearchMode::Substring}
private

◆ m_normalizedPattern

std::string ui::qt::utils::SearchEngine::m_normalizedPattern
mutableprivate

◆ m_normalizedPatternValid

bool ui::qt::utils::SearchEngine::m_normalizedPatternValid {false}
mutableprivate

◆ m_pattern

std::string ui::qt::utils::SearchEngine::m_pattern
private

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