FlightGear next
AddonMetadataParser.hxx
Go to the documentation of this file.
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
21class SGPropertyNode;
22
23namespace flightgear::addons {
24
26{
27public:
28 // Comments about these fields can be found in Addon.hxx
29 std::string id;
30 std::string name;
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;
41 std::string licenseUrl;
42
43 std::vector<std::string> tags;
44
47
48 std::string homePage;
49 std::string downloadUrl;
50 std::string supportUrl;
51 std::string codeRepositoryUrl;
52};
53
55{
56public:
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
64private:
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
static SGPath getMetadataFile(const SGPath &addonPath)
static Addon::Metadata parseMetadataFile(const SGPath &addonPath)
std::vector< MaintainerRef > maintainers