ALib C++ Library
Library Version: 2402 R1
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
11#if !defined (HPP_ALIB_FILES_FTREE)
12# include "alib/files/ftree.hpp"
13#endif
14
15
16
17namespace alib { namespace files {
18
19/** ************************************************************************************************
20 * This is a straight forward simple abstract class with just one interface method which has
21 * to return \c true if an file is included (not filtered) or \c false if it is not included and
22 * thus to be filtered out.<br>
23 * Instead of the provision of an \b FInfo object, a cursor of an \b FTree is provided.
24 * This allows more detailed inspection of parent directories, if needed.
25 * In addition the full path string (the real path, all symbolic links translated) is provided.
26 * While this could be assembled from the given cursor \p{node}, the provision is made to allow
27 * highest execution performance, as the string is available during the scan process anyhow.
28 *
29 * Instances of derived (non abstract) implementations, can optionally be attached to fields
30 * \alib{files::ScanParameters;FileFilter},
31 * \alib{files::ScanParameters;DirectoryFilterPreRecursion} and
32 * \alib{files::ScanParameters;DirectoryFilterPostRecursion} of class
33 * \b ScanParameters to filter files during the scan process.
34 *
35 * Users of the API might also create code that uses this interface type for post-scan
36 * filtering, but in this case may of-course also rely on own implementations/mechanics.
37 **************************************************************************************************/
38struct FFilter
39{
40 /** Destructor */
41 virtual ~FFilter() = default;
42
43 /**
44 * Abstract virtual method to evaluate the inclusion of the given \b FInfo object.
45 * @param node The node in the file-tree to examine.
46 * @param parentPath The absolute path to the parent directory that the file resides in.
47 * @return The result determines, whether the given file or directory has passed the filter or
48 * not. Consequently, \c true means "passed" and \c false means "filtered out". */
49 virtual bool Includes( const FTree::ConstCursor& node, const String& parentPath) = 0;
50
51}; //class FFilter
52
53/** A shared pointer to a filter. */
54using SPFileFilter= std::shared_ptr<FFilter>;
55
56} // namespace alib[::files]
57
58
59/// Type alias in namespace \b alib.
61
62/// Type alias in namespace \b alib.
64
65} // namespace [alib]
66
67
68#endif // HPP_ALIB_FILES_FFILTER
std::shared_ptr< FFilter > SPFileFilter
Definition ffilter.hpp:54
Definition alib.cpp:57
files::SPFileFilter SPFileFilter
Type alias in namespace alib.
Definition ffilter.hpp:63
virtual ~FFilter()=default
virtual bool Includes(const FTree::ConstCursor &node, const String &parentPath)=0