forked from KDE/licensedigger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
licenseregistry.h
59 lines (47 loc) · 1.72 KB
/
licenseregistry.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
* SPDX-FileCopyrightText: 2019 Andreas Cord-Landwehr <[email protected]>
*
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
#ifndef LICENSEREGISTRY_H
#define LICENSEREGISTRY_H
#include <QMap>
#include <QObject>
#include <QRegularExpression>
#include <QVector>
class LicenseRegistry : public QObject
{
Q_OBJECT
public:
using SpdxIdentifier = QString;
using SpdxExpression = QString;
const static QString ToClarifyLicense;
const static QString UnknownLicense;
const static QString MissingLicense;
const static QString AmbigiousLicense;
const static QString MissingLicenseForGeneratedFile;
explicit LicenseRegistry(QObject *parent = nullptr);
/**
* @brief list of all detectable SPDX expressions
*/
QVector<SpdxExpression> expressions() const;
/**
* @brief list of all known SPDX identifiers
*/
QVector<SpdxIdentifier> identifiers() const;
QMap<SpdxIdentifier, QString> licenseFiles() const;
QVector<QString> headerTexts(const SpdxExpression &identifier) const;
QVector<QRegularExpression> headerTextRegExps(const SpdxExpression &identifier) const;
/**
* @param expression is the expression to check against license strings (this does not support syntax parameters like "OR"
* @return true if this is a non-license, e.g. "TO-CLARIFY" string"
*/
bool isFakeLicenseMarker(const QString &expression) const;
private:
void loadLicenseHeaders();
void loadLicenseFiles();
QMap<SpdxExpression, QVector<QString>> m_registry;
mutable QMap<SpdxExpression, QVector<QRegularExpression>> m_regexpsCache;
mutable QMap<SpdxIdentifier, QString> m_licenseFiles;
};
#endif // LICENSEREGISTRY_H