KNewStuff

tagsfilterchecker.h
1/*
2 SPDX-FileCopyrightText: 2018 Dan Leinir Turthra Jensen <admin@leinir.dk>
3
4 SPDX-License-Identifier: LGPL-2.1-or-later
5*/
6
7#ifndef KNSCORE_TAGSFILTERCHECKER_H
8#define KNSCORE_TAGSFILTERCHECKER_H
9
10#include "knewstuffcore_export.h"
11#include <QStringList>
12
13#include <memory>
14
15namespace KNSCore
16{
17class TagsFilterCheckerPrivate;
18/**
19 * @brief Apply simple filtering logic to a list of tags
20 *
21 * == Examples of specifying tag filters ==
22 * Value for tag "tagname" must be exactly "tagdata":
23 * tagname==tagdata
24 *
25 * Value for tag "tagname" must be different from "tagdata":
26 * tagname!=tagdata
27 *
28 * == Tag filter list ==
29 * A tag filter list is a string list of filters as shown above, and a combination
30 * of which might look like:
31 *
32 * - ghns_excluded!=1
33 * - data##mimetype==application/cbr+zip
34 * - data##mimetype==application/cbr+rar
35 *
36 * which would filter out anything which has ghns_excluded set to 1, and
37 * anything where the value of data##mimetype does not equal either
38 * "application/cbr+zip" or "application/cbr+rar".
39 * Notice in particular the two data##mimetype entries. Use this
40 * for when a tag may have multiple values.
41 *
42 * The value does not current support wildcards. The list should be considered
43 * a binary AND operation (that is, all filter entries must match for the data
44 * entry to be included in the return data)
45 * @since 5.51
46 */
48{
49public:
50 /**
51 * Constructs an instance of the tags filter checker, prepopulated
52 * with the list of tag filters in the tagFilter parameter.
53 *
54 * @param tagFilter The list of tag filters
55 * @since 5.51
56 */
57 explicit TagsFilterChecker(const QStringList &tagFilter);
59
60 TagsFilterChecker(const TagsFilterChecker &) = delete;
61 TagsFilterChecker &operator=(const TagsFilterChecker &) = delete;
62
63 /**
64 * Check whether the filter list accepts the passed list of tags
65 *
66 * @param tags A list of tags in the form of key=value strings
67 * @return True if the filter accepts the list, false if not
68 * @since 5.51
69 */
70 bool filterAccepts(const QStringList &tags);
71
72private:
73 const std::unique_ptr<TagsFilterCheckerPrivate> d;
74};
75
76}
77
78#endif // KNSCORE_TAGSFILTERCHECKER_H
Apply simple filtering logic to a list of tags.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:21:35 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.