Loading...
Searching...
No Matches
Descriptor.hpp
1#pragma once
2
3#include <Process/ProcessMetadata.hpp>
4
5#include <QFile>
6#include <QRegularExpression>
7namespace Faust
8{
9
11{
12 QString prettyName;
13 QString author;
14 QString category;
15 QString license;
16 QString copyright;
17 QString version;
18 QString reference;
19 QString description;
20};
21
22inline FoundKeys initDescriptor(const QString& data)
23{
24 static const QRegularExpression nameExpr{R"_(declare\s*name\s*"(.*)";)_"};
25 static const QRegularExpression authorExpr{R"_(declare\s*author?\s*"(.*)";)_"};
26 static const QRegularExpression descExpr{R"_(declare\s*description\s*"(.*)";)_"};
27 static const QRegularExpression licenseExpr{R"_(declare\s*licen[sc]e\s*"(.*)";)_"};
28 static const QRegularExpression copyrightExpr{R"_(declare\s*copyright\s*"(.*)";)_"};
29 static const QRegularExpression referenceExpr{R"_(declare\s*reference\s*"(.*)";)_"};
30 static const QRegularExpression versionExpr{R"_(declare\s*version\s*"(.*)";)_"};
31
32 FoundKeys d;
33 QString txt = data;
34
35 QFile f(txt);
36 if(f.exists())
37 {
38 f.open(QIODevice::ReadOnly);
39 txt = f.readAll();
40 }
41
42 if(auto matches = nameExpr.match(txt); matches.hasMatch())
43 d.prettyName = matches.captured(1);
44
45 if(auto matches = authorExpr.match(txt); matches.hasMatch())
46 d.author = matches.captured(1);
47
48 if(auto matches = descExpr.match(txt); matches.hasMatch())
49 d.description = matches.captured(1);
50
51 if(auto matches = licenseExpr.match(txt); matches.hasMatch())
52 d.license = matches.captured(1);
53 if(auto matches = copyrightExpr.match(txt); matches.hasMatch())
54 d.copyright = matches.captured(1);
55 if(auto matches = versionExpr.match(txt); matches.hasMatch())
56 d.version = matches.captured(1);
57 if(auto matches = referenceExpr.match(txt); matches.hasMatch())
58 d.reference = matches.captured(1);
59
60 return d;
61}
62
63}
Definition Descriptor.hpp:11
Definition ObjectMatches.hpp:6