Debian Codegraph @

src/core/profilexmlparser.h

raw symbols SCIP
1 // SPDX-License-Identifier: GPL-3.0-or-later
2 // Copyright 2019 Juan Palacios <[email protected]>
3
4 #pragma once
5
6 #include "iprofile.h"
7 #include "iprofileparser.h"
8 #include "profilepartxmlparser.h"
9 #include <memory>
10 #include <string>
11 #include <unordered_map>
12
13 class IProfilePartXMLParser;
14 class IProfilePartXMLParserProvider;
15
16 class ProfileXMLParser final
17 : public IProfileParser
18 , public IProfile::Importer
19 , public IProfile::Exporter
20 {
21 public:
22 ProfileXMLParser() noexcept;
23
24 std::string const &format() override;
25 std::unique_ptr<Exportable::Exporter> initializer() override;
26 bool load(std::vector<char> const &data, IProfile &profile) override;
27 bool save(std::vector<char> &data, IProfile const &profile) override;
28
29 std::optional<std::reference_wrapper<Exportable::Exporter>>
30 provideExporter(Item const &i) override;
31 std::optional<std::reference_wrapper<Importable::Importer>>
32 provideImporter(Item const &i) override;
33
34 void takeActive(bool active) override;
35 void takeInfo(IProfile::Info const &info) override;
36
37 bool provideActive() const override;
38 IProfile::Info const &provideInfo() const override;
39
40 class Factory final
41 : public ProfilePartXMLParser::Factory
42 , public IProfile::Exporter
43 {
44 public:
45 Factory(IProfilePartXMLParserProvider const &profilePartParserProvider,
46 ProfileXMLParser &outer) noexcept;
47
48 void takePartParser(Item const &i,
49 std::unique_ptr<IProfilePartXMLParser> &&part) override;
50
51 std::optional<std::reference_wrapper<Exportable::Exporter>>
52 provideExporter(Item const &i) override;
53
54 void takeActive(bool) override
55 {
56 }
57
58 void takeInfo(IProfile::Info const &) override
59 {
60 }
61
62 private:
63 ProfileXMLParser &outer_;
64 };
65
66 private:
67 class Initializer;
68
69 std::string const format_;
70 std::string profileNodeName_;
71 std::unordered_map<std::string, std::unique_ptr<IProfilePartXMLParser>> parsers_;
72
73 IProfile::Info info_;
74 IProfile::Info infoDefault_;
75
76 bool active_;
77 bool activeDefault_;
78 };