1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4#include "logging.h"
5#include "packagefilter.h"
6#include <iostream>
7
8PackageFilter::PackageFilter(const QString &expression)
9 : type(InvalidFilter)
10{
11 const QLatin1String filter("QDocModule=");
12 if (expression.startsWith(s: filter)) {
13 type = QDocModuleFilter;
14 this->expression = expression.mid(position: filter.size());
15 } else {
16 std::cerr << qPrintable(tr("Invalid filter expression \"%1\"").arg(expression)) << std::endl;
17 std::cerr << qPrintable(tr("Currently only \"QDocModule=*\" is supported.")) << std::endl;
18 }
19}
20
21bool PackageFilter::operator()(const Package &p)
22{
23 switch (type) {
24 case InvalidFilter:
25 return true;
26 case QDocModuleFilter:
27 return p.qdocModule == expression;
28 }
29 return false;
30}
31

source code of qttools/src/qtattributionsscanner/packagefilter.cpp