Unravel Engine C++ Reference
Loading...
Searching...
No Matches
fs::pattern_filter Class Reference

A filter that combines include and exclude patterns for file/directory filtering. More...

#include <pattern_filter.h>

Public Member Functions

 pattern_filter ()=default
 Default constructor creates a filter that accepts everything.
 
 pattern_filter (const std::string &include_pattern)
 Constructs a filter with include patterns only (for backward compatibility)
 
 pattern_filter (const std::vector< std::string > &include_patterns, const std::vector< std::string > &exclude_patterns={})
 Constructs a filter with multiple include and exclude patterns.
 
void add_include_pattern (const std::string &pattern)
 Adds an include pattern to the filter.
 
void add_exclude_pattern (const std::string &pattern)
 Adds an exclude pattern to the filter.
 
auto should_include (const fs::path &path) const -> bool
 Tests if a path should be included based on the filter rules Logic: (matches any include pattern OR no include patterns) AND (matches no exclude patterns)
 
auto should_include_filename (const std::string &filename) const -> bool
 Tests if a filename should be included based on the filter rules.
 
auto has_patterns () const -> bool
 Checks if this filter has any patterns.
 
auto is_wildcard () const -> bool
 Checks if this filter is effectively a wildcard (no restrictions)
 
auto get_include_patterns () const -> const std::vector< wildcard_pattern > &
 Gets all include patterns.
 
auto get_exclude_patterns () const -> const std::vector< wildcard_pattern > &
 Gets all exclude patterns.
 

Detailed Description

A filter that combines include and exclude patterns for file/directory filtering.

Definition at line 47 of file pattern_filter.h.

Constructor & Destructor Documentation

◆ pattern_filter() [1/3]

fs::pattern_filter::pattern_filter ( )
default

Default constructor creates a filter that accepts everything.

◆ pattern_filter() [2/3]

fs::pattern_filter::pattern_filter ( const std::string & include_pattern)
explicit

Constructs a filter with include patterns only (for backward compatibility)

Parameters
include_patternSingle include pattern

Definition at line 70 of file pattern_filter.cpp.

◆ pattern_filter() [3/3]

fs::pattern_filter::pattern_filter ( const std::vector< std::string > & include_patterns,
const std::vector< std::string > & exclude_patterns = {} )

Constructs a filter with multiple include and exclude patterns.

Parameters
include_patternsList of include patterns (OR logic)
exclude_patternsList of exclude patterns (NOT logic)

Definition at line 78 of file pattern_filter.cpp.

Member Function Documentation

◆ add_exclude_pattern()

void fs::pattern_filter::add_exclude_pattern ( const std::string & pattern)

Adds an exclude pattern to the filter.

Parameters
patternPattern to add to excludes

Definition at line 99 of file pattern_filter.cpp.

◆ add_include_pattern()

void fs::pattern_filter::add_include_pattern ( const std::string & pattern)

Adds an include pattern to the filter.

Parameters
patternPattern to add to includes

Definition at line 91 of file pattern_filter.cpp.

◆ get_exclude_patterns()

auto fs::pattern_filter::get_exclude_patterns ( ) const -> const std::vector<wildcard_pattern>&

Gets all exclude patterns.

Definition at line 170 of file pattern_filter.cpp.

◆ get_include_patterns()

auto fs::pattern_filter::get_include_patterns ( ) const -> const std::vector<wildcard_pattern>&

Gets all include patterns.

Definition at line 165 of file pattern_filter.cpp.

◆ has_patterns()

auto fs::pattern_filter::has_patterns ( ) const -> bool

Checks if this filter has any patterns.

Definition at line 142 of file pattern_filter.cpp.

◆ is_wildcard()

auto fs::pattern_filter::is_wildcard ( ) const -> bool

Checks if this filter is effectively a wildcard (no restrictions)

Definition at line 147 of file pattern_filter.cpp.

◆ should_include()

auto fs::pattern_filter::should_include ( const fs::path & path) const -> bool

Tests if a path should be included based on the filter rules Logic: (matches any include pattern OR no include patterns) AND (matches no exclude patterns)

Parameters
pathPath to test
Returns
True if the path should be included

Definition at line 107 of file pattern_filter.cpp.

◆ should_include_filename()

auto fs::pattern_filter::should_include_filename ( const std::string & filename) const -> bool

Tests if a filename should be included based on the filter rules.

Parameters
filenameFilename to test
Returns
True if the filename should be included

Definition at line 112 of file pattern_filter.cpp.


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