Debian Codegraph @

src/Add-ons/AddonMetadataParser.hxx

raw symbols SCIP
1 /*
2 * SPDX-FileName: AddonMetadataParser.hxx
3 * SPDX-FileComment: Parser for FlightGear add-on metadata files
4 * SPDX-FileCopyrightText: Copyright (C) 2018 Florent Rougon
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 */
7
8 #pragma once
9
10 #include <string>
11 #include <tuple>
12 #include <vector>
13
14 #include <simgear/misc/sg_path.hxx>
15
16 #include "addon_fwd.hxx"
17 #include "Addon.hxx"
18 #include "AddonVersion.hxx"
19 #include "contacts.hxx"
20
21 class SGPropertyNode;
22
23 namespace flightgear::addons {
24
25 class Addon::Metadata
26 {
27 public:
28 // Comments about these fields can be found in Addon.hxx
29 std::string id;
30 std::string name;
31 AddonVersion version;
32
33 std::vector<AuthorRef> authors;
34 std::vector<MaintainerRef> maintainers;
35
36 std::string shortDescription;
37 std::string longDescription;
38
39 std::string licenseDesignation;
40 SGPath licenseFile;
41 std::string licenseUrl;
42
43 std::vector<std::string> tags;
44
45 std::string minFGVersionRequired;
46 std::string maxFGVersionRequired;
47
48 std::string homePage;
49 std::string downloadUrl;
50 std::string supportUrl;
51 std::string codeRepositoryUrl;
52 };
53
54 class Addon::MetadataParser
55 {
56 public:
57 // “Compute” a path to the metadata file from the add-on base path
58 static SGPath getMetadataFile(const SGPath& addonPath);
59
60 // Parse the add-on metadata file inside 'addonPath' (as defined by
61 // getMetadataFile()) and return the corresponding Addon::Metadata instance.
62 static Addon::Metadata parseMetadataFile(const SGPath& addonPath);
63
64 private:
65 static std::tuple<std::string, SGPath, std::string>
66 parseLicenseNode(const SGPath& addonPath, SGPropertyNode* addonNode);
67
68 // Parse an addon-metadata.xml node such as <authors> or <maintainers>.
69 // Return the corresponding vector<AuthorRef> or vector<MaintainerRef>. If
70 // the 'mainNode' argument is nullptr, return an empty vector.
71 template <class T>
72 static std::vector<typename contact_traits<T>::strong_ref>
73 parseContactsNode(const SGPath& metadataFile, SGPropertyNode* mainNode);
74 };
75
76 } // namespace flightgear::addons