ALib C++ Library
Library Version: 2412 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
ffilter.hpp
Go to the documentation of this file.
1//==================================================================================================
2/// \file
3/// This header file is part of module \alib_files of the \aliblong.
4///
5/// \emoji :copyright: 2013-2024 A-Worx GmbH, Germany.
6/// Published under \ref mainpage_license "Boost Software License".
7//==================================================================================================
8#ifndef HPP_ALIB_FILES_FFILTER
9#define HPP_ALIB_FILES_FFILTER 1
10#pragma once
11#include "alib/files/ftree.hpp"
12
13namespace alib { namespace files {
14
15//==================================================================================================
16/// This is a straight forward simple abstract class with just one interface method which has
17/// to return \c true if an file is included (not filtered) or \c false if it is not included and
18/// thus to be filtered out.<br>
19/// Instead of the provision of an \b FInfo object, a cursor of an \b FTree is provided.
20/// This allows more detailed inspection of parent directories, if needed.
21/// In addition the full path string (the real path, all symbolic links translated) is provided.
22/// While this could be assembled from the given cursor \p{node}, the provision is made to allow
23/// highest execution performance, as the string is available during the scan process anyhow.
24///
25/// Instances of derived (non abstract) implementations, can optionally be attached to fields
26/// \alib{files::ScanParameters;FileFilter},
27/// \alib{files::ScanParameters;DirectoryFilterPreRecursion}, and
28/// \alib{files::ScanParameters;DirectoryFilterPostRecursion} of class
29/// \b ScanParameters to filter files during the scan process.
30///
31/// Users of the API might also create code that uses this interface type for post-scan
32/// filtering, but in this case may of course also rely on own implementations/mechanics.
33//==================================================================================================
34struct FFilter
35{
36 /// Destructor
37 virtual ~FFilter() = default;
38
39 /// Abstract virtual method to evaluate the inclusion of the given \b FInfo object.
40 /// @param file The node in the file-tree to examine.
41 /// @param parentPath The absolute path to the parent directory that the file resides in.
42 /// @return The result determines, whether the given file or directory has passed the filter or
43 /// not. Consequently, \c true means "passed" and \c false means "filtered out".
44 virtual bool Includes( const File& file, const lang::system::PathString& parentPath ) = 0;
45
46}; //class FFilter
47
48/// A shared pointer to a filter.
49using SPFileFilter= std::shared_ptr<FFilter>;
50
51} // namespace alib[::files]
52
53
54/// Type alias in namespace \b alib.
56
57/// Type alias in namespace \b alib.
59
60} // namespace [alib]
61
62
63#endif // HPP_ALIB_FILES_FFILTER
64
std::shared_ptr< FFilter > SPFileFilter
A shared pointer to a filter.
Definition ffilter.hpp:49
Definition alib.cpp:69
files::SPFileFilter SPFileFilter
Type alias in namespace alib.
Definition ffilter.hpp:58
virtual ~FFilter()=default
Destructor.
virtual bool Includes(const File &file, const lang::system::PathString &parentPath)=0