| 1 | // SPDX-License-Identifier: GPL-3.0-or-latercxx . . $ `<file>/src/core/components/controls/controlgroupxmlparser.cpp`/ |
| 2 | // Copyright 2019 Juan Palacios <[email protected]> |
| 3 | |
| 4 | #include "controlgroupxmlparser.h"cxx . . $ `<file>/src/core/components/controls/controlgroupxmlparser.h`/ |
| 5 | |
| 6 | #include <algorithm> |
| 7 | #include <pugixml.hpp> |
| 8 | #include <utility> |
| 9 | |
| 10 | class ControlGroupXMLParsercxx . . $ ControlGroupXMLParser#::Factorycxx . . $ ControlGroupXMLParser#Factory# final |
| 11 | : public ProfilePartXMLParsercxx . . $ ProfilePartXMLParser#::Factorycxx . . $ ProfilePartXMLParser#Factory# |
| 12 | , public ControlGroupProfilePartcxx . . $ ControlGroupProfilePart#::Exportercxx . . $ ControlGroupProfilePart#Exporter# |
| 13 | { |
| 14 | public: |
| 15 | Factorycxx . . $ ControlGroupXMLParser#Factory#Factory(717ce1341ce58c1a).(IProfilePartXMLParserProvidercxx . . $ IProfilePartXMLParserProvider# const &profilePartParserProvider, |
| 16 | ControlGroupXMLParsercxx . . $ ControlGroupXMLParser# &outer) noexcept |
| 17 | : ProfilePartXMLParsercxx . . $ ProfilePartXMLParser#::Factorycxx . . $ ProfilePartXMLParser#Factory#(profilePartParserProvider) |
| 18 | , outer_cxx . . $ ControlGroupXMLParser#Factory#outer_.(outer) |
| 19 | { |
| 20 | } |
| 21 | |
| 22 | void takePartParsercxx . . $ ControlGroupXMLParser#Factory#takePartParser(4ce663d5ecbeb887).(Itemcxx . . $ Item# const &i, |
| 23 | stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<IProfilePartXMLParsercxx . . $ IProfilePartXMLParser#> &&part) override; |
| 24 | |
| 25 | stdcxx . . $ std/::optionalcxx . . $ std/optional#<stdcxx . . $ std/::reference_wrappercxx . . $ std/reference_wrapper#<Exportablecxx . . $ Exportable#::Exportercxx . . $ Exportable#Exporter#>> |
| 26 | provideExportercxx . . $ ControlGroupXMLParser#Factory#provideExporter(3acccbde2694e33a).(Itemcxx . . $ Item# const &i) override; |
| 27 | |
| 28 | void takeActivecxx . . $ ControlGroupXMLParser#Factory#takeActive(b45ddcbc8423892c).(bool) override |
| 29 | { |
| 30 | } |
| 31 | |
| 32 | private: |
| 33 | ControlGroupXMLParsercxx . . $ ControlGroupXMLParser# &outer_cxx . . $ ControlGroupXMLParser#Factory#outer_.; |
| 34 | }; |
| 35 | |
| 36 | void ControlGroupXMLParsercxx . . $ ControlGroupXMLParser#::Factorycxx . . $ ControlGroupXMLParser#Factory#::takePartParsercxx . . $ ControlGroupXMLParser#Factory#takePartParser(4ce663d5ecbeb887).( |
| 37 | Itemcxx . . $ Item# const &, stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<IProfilePartXMLParsercxx . . $ IProfilePartXMLParser#> &&part) |
| 38 | { |
| 39 | outer_cxx . . $ ControlGroupXMLParser#Factory#outer_..parsers_cxx . . $ ControlGroupXMLParser#parsers_..emplace_backcxx . . $ std/vector#emplace_back(a1bcdfdabc3a37df).(stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(part)); |
| 40 | } |
| 41 | |
| 42 | stdcxx . . $ std/::optionalcxx . . $ std/optional#<stdcxx . . $ std/::reference_wrappercxx . . $ std/reference_wrapper#<Exportablecxx . . $ Exportable#::Exportercxx . . $ Exportable#Exporter#>> |
| 43 | ControlGroupXMLParsercxx . . $ ControlGroupXMLParser#::Factorycxx . . $ ControlGroupXMLParser#Factory#::provideExportercxx . . $ ControlGroupXMLParser#Factory#provideExporter(3acccbde2694e33a).(Itemcxx . . $ Item# const &i) |
| 44 | { |
| 45 | return factorycxx . . $ ProfilePartXMLParser#Factory#factory(3acccbde2694e33a).(i); |
| 46 | } |
| 47 | |
| 48 | class ControlGroupXMLParsercxx . . $ ControlGroupXMLParser#::Initializercxx . . $ ControlGroupXMLParser#Initializer# final |
| 49 | : public ControlGroupProfilePartcxx . . $ ControlGroupProfilePart#::Exportercxx . . $ ControlGroupProfilePart#Exporter# |
| 50 | { |
| 51 | public: |
| 52 | Initializercxx . . $ ControlGroupXMLParser#Initializer#Initializer(c3ed2153102822b3).(ControlGroupXMLParsercxx . . $ ControlGroupXMLParser# &outer) noexcept |
| 53 | : outer_cxx . . $ ControlGroupXMLParser#Initializer#outer_.(outer) |
| 54 | { |
| 55 | } |
| 56 | |
| 57 | stdcxx . . $ std/::optionalcxx . . $ std/optional#<stdcxx . . $ std/::reference_wrappercxx . . $ std/reference_wrapper#<Exportablecxx . . $ Exportable#::Exportercxx . . $ Exportable#Exporter#>> |
| 58 | provideExportercxx . . $ ControlGroupXMLParser#Initializer#provideExporter(3acccbde2694e33a).(Itemcxx . . $ Item# const &i) override; |
| 59 | |
| 60 | void takeActivecxx . . $ ControlGroupXMLParser#Initializer#takeActive(b45ddcbc8423892c).(bool active) override; |
| 61 | |
| 62 | private: |
| 63 | ControlGroupXMLParsercxx . . $ ControlGroupXMLParser# &outer_cxx . . $ ControlGroupXMLParser#Initializer#outer_.; |
| 64 | stdcxx . . $ std/::unordered_mapcxx . . $ std/unordered_map#<stdcxx . . $ std/::stringcxx . . $ std/string#, stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<Exportablecxx . . $ Exportable#::Exportercxx . . $ Exportable#Exporter#>> initializers_cxx . . $ ControlGroupXMLParser#Initializer#initializers_.; |
| 65 | }; |
| 66 | |
| 67 | stdcxx . . $ std/::optionalcxx . . $ std/optional#<stdcxx . . $ std/::reference_wrappercxx . . $ std/reference_wrapper#<Exportablecxx . . $ Exportable#::Exportercxx . . $ Exportable#Exporter#>> |
| 68 | ControlGroupXMLParsercxx . . $ ControlGroupXMLParser#::Initializercxx . . $ ControlGroupXMLParser#Initializer#::provideExportercxx . . $ ControlGroupXMLParser#Initializer#provideExporter(3acccbde2694e33a).(Itemcxx . . $ Item# const &i) |
| 69 | { |
| 70 | for (auto &parser : outer_cxx . . $ ControlGroupXMLParser#Initializer#outer_..parsers_cxx . . $ ControlGroupXMLParser#parsers_.) { |
| 71 | if (parser->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).IDcxx . . $ Item#ID(f4fff0029955a25f).() ==cxx . . $ std/`operator==`(5ea818b58063a774). i.IDcxx . . $ Item#ID(f4fff0029955a25f).() && (parser->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).instanceIDcxx . . $ Item#instanceID(f4fff0029955a25f).() ==cxx . . $ std/`operator==`(5ea818b58063a774). i.instanceIDcxx . . $ Item#instanceID(f4fff0029955a25f).() || |
| 72 | parser->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).instanceIDcxx . . $ Item#instanceID(f4fff0029955a25f).().emptycxx . . $ std/__cxx11/basic_string#empty(3482b152b9333168).())) { |
| 73 | |
| 74 | // Each item instance must have its own initializer |
| 75 | auto const id = i.IDcxx . . $ Item#ID(f4fff0029955a25f).() != i.instanceIDcxx . . $ Item#instanceID(f4fff0029955a25f).() ? i.IDcxx . . $ Item#ID(f4fff0029955a25f).() +cxx . . $ std/operator+(2764d1739bf7913d). i.instanceIDcxx . . $ Item#instanceID(f4fff0029955a25f).() |
| 76 | : icxx . . $ std/__cxx11/basic_string#basic_string(a47f53d4115f6ce5)..IDcxx . . $ Item#ID(f4fff0029955a25f).(); |
| 77 | if (initializers_cxx . . $ ControlGroupXMLParser#Initializer#initializers_..countcxx . . $ std/unordered_map#count(b71ff106d381144b).(id) > 0) |
| 78 | return *cxx . . $ std/optional#optional(e3f0d6382bd52f24).initializers_cxx . . $ ControlGroupXMLParser#Initializer#initializers_..atcxx . . $ std/unordered_map#at(4f10b6009f0ee734).(id); |
| 79 | else { |
| 80 | auto initializer = parser->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).initializercxx . . $ IProfilePartXMLParser#initializer(6b4e1016740e578).(); |
| 81 | if (initializer != nullptr) { |
| 82 | initializers_cxx . . $ ControlGroupXMLParser#Initializer#initializers_..emplacecxx . . $ std/unordered_map#emplace(8e800962ae7274b6).(id, stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(initializer)); |
| 83 | return *cxx . . $ std/optional#optional(e3f0d6382bd52f24).initializers_cxx . . $ ControlGroupXMLParser#Initializer#initializers_..atcxx . . $ std/unordered_map#at(4f10b6009f0ee734).(id); |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | break; |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | return {cxx . . $ std/optional#optional(ced63f7c635d850d).}; |
| 92 | } |
| 93 | |
| 94 | void ControlGroupXMLParsercxx . . $ ControlGroupXMLParser#::Initializercxx . . $ ControlGroupXMLParser#Initializer#::takeActivecxx . . $ ControlGroupXMLParser#Initializer#takeActive(b45ddcbc8423892c).(bool active) |
| 95 | { |
| 96 | outer_cxx . . $ ControlGroupXMLParser#Initializer#outer_..active_cxx . . $ ControlGroupXMLParser#active_. = outer_cxx . . $ ControlGroupXMLParser#Initializer#outer_..activeDefault_cxx . . $ ControlGroupXMLParser#activeDefault_. = active; |
| 97 | } |
| 98 | |
| 99 | ControlGroupXMLParsercxx . . $ ControlGroupXMLParser#::ControlGroupXMLParsercxx . . $ ControlGroupXMLParser#ControlGroupXMLParser(c6e332c41c54746f).(stdcxx . . $ std/::string_viewcxx . . $ std/string_view# id) noexcept |
| 100 | : ProfilePartXMLParsercxx . . $ ProfilePartXMLParser#(idcxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02)., *this, *this) |
| 101 | { |
| 102 | } |
| 103 | |
| 104 | stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<Exportablecxx . . $ Exportable#::Exportercxx . . $ Exportable#Exporter#> ControlGroupXMLParsercxx . . $ ControlGroupXMLParser#::factorycxx . . $ ControlGroupXMLParser#factory(543373651c38a5a4).( |
| 105 | IProfilePartXMLParserProvidercxx . . $ IProfilePartXMLParserProvider# const &profilePartXMLParserProvider) |
| 106 | { |
| 107 | return stdcxx . . $ std/unique_ptr#unique_ptr(8bcafd3b0b660df8).::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<ControlGroupXMLParsercxx . . $ ControlGroupXMLParser#::Factorycxx . . $ ControlGroupXMLParser#Factory#>( |
| 108 | profilePartXMLParserProvider, *this); |
| 109 | } |
| 110 | |
| 111 | stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<Exportablecxx . . $ Exportable#::Exportercxx . . $ Exportable#Exporter#> ControlGroupXMLParsercxx . . $ ControlGroupXMLParser#::initializercxx . . $ ControlGroupXMLParser#initializer(6b4e1016740e578).() |
| 112 | { |
| 113 | return stdcxx . . $ std/unique_ptr#unique_ptr(8bcafd3b0b660df8).::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<ControlGroupXMLParsercxx . . $ ControlGroupXMLParser#::Initializercxx . . $ ControlGroupXMLParser#Initializer#>(*this); |
| 114 | } |
| 115 | |
| 116 | stdcxx . . $ std/::optionalcxx . . $ std/optional#<stdcxx . . $ std/::reference_wrappercxx . . $ std/reference_wrapper#<Exportablecxx . . $ Exportable#::Exportercxx . . $ Exportable#Exporter#>> |
| 117 | ControlGroupXMLParsercxx . . $ ControlGroupXMLParser#::provideExportercxx . . $ ControlGroupXMLParser#provideExporter(3acccbde2694e33a).(Itemcxx . . $ Item# const &i) |
| 118 | { |
| 119 | auto parserIt = stdcxx . . $ std/::find_ifcxx . . $ std/find_if(f0a0a4f94ee5cb00).( |
| 120 | parsers_cxx . . $ ControlGroupXMLParser#parsers_..cbegincxx . . $ std/vector#cbegin(d1e1699016b9d7e6).(), parsers_cxx . . $ ControlGroupXMLParser#parsers_..cendcxx . . $ std/vector#cend(d1e1699016b9d7e6).(), [&](auto const &part) { |
| 121 | return part->ID() == i.IDcxx . . $ Item#ID(f4fff0029955a25f).() && part->instanceID() == i.instanceIDcxx . . $ Item#instanceID(f4fff0029955a25f).(); |
| 122 | }); |
| 123 | |
| 124 | if (parserIt != parsers_cxx . . $ ControlGroupXMLParser#parsers_..cendcxx . . $ std/vector#cend(d1e1699016b9d7e6).()) |
| 125 | return (cxx . . $ std/optional#optional(e3f0d6382bd52f24).*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(f9c37c6e427d43d6).parserIt)->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).profilePartExportercxx . . $ IProfilePartXMLParser#profilePartExporter(611f04e96fb8b68a).(); |
| 126 | |
| 127 | return {cxx . . $ std/optional#optional(ced63f7c635d850d).}; |
| 128 | } |
| 129 | |
| 130 | stdcxx . . $ std/::optionalcxx . . $ std/optional#<stdcxx . . $ std/::reference_wrappercxx . . $ std/reference_wrapper#<Importablecxx . . $ Importable#::Importercxx . . $ Importable#Importer#>> |
| 131 | ControlGroupXMLParsercxx . . $ ControlGroupXMLParser#::provideImportercxx . . $ ControlGroupXMLParser#provideImporter(c13a3bcac0db4745).(Itemcxx . . $ Item# const &i) |
| 132 | { |
| 133 | auto parserIt = stdcxx . . $ std/::find_ifcxx . . $ std/find_if(f0a0a4f94ee5cb00).( |
| 134 | parsers_cxx . . $ ControlGroupXMLParser#parsers_..cbegincxx . . $ std/vector#cbegin(d1e1699016b9d7e6).(), parsers_cxx . . $ ControlGroupXMLParser#parsers_..cendcxx . . $ std/vector#cend(d1e1699016b9d7e6).(), [&](auto const &part) { |
| 135 | return part->ID() == i.IDcxx . . $ Item#ID(f4fff0029955a25f).() && part->instanceID() == i.instanceIDcxx . . $ Item#instanceID(f4fff0029955a25f).(); |
| 136 | }); |
| 137 | |
| 138 | if (parserIt != parsers_cxx . . $ ControlGroupXMLParser#parsers_..cendcxx . . $ std/vector#cend(d1e1699016b9d7e6).()) |
| 139 | return (cxx . . $ std/optional#optional(e3f0d6382bd52f24).*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(f9c37c6e427d43d6).parserIt)->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).profilePartImportercxx . . $ IProfilePartXMLParser#profilePartImporter(c6a8a54be61afbf2).(); |
| 140 | |
| 141 | return {cxx . . $ std/optional#optional(ced63f7c635d850d).}; |
| 142 | } |
| 143 | |
| 144 | void ControlGroupXMLParsercxx . . $ ControlGroupXMLParser#::takeActivecxx . . $ ControlGroupXMLParser#takeActive(b45ddcbc8423892c).(bool active) |
| 145 | { |
| 146 | active_cxx . . $ ControlGroupXMLParser#active_. = active; |
| 147 | } |
| 148 | |
| 149 | bool ControlGroupXMLParsercxx . . $ ControlGroupXMLParser#::provideActivecxx . . $ ControlGroupXMLParser#provideActive(50ce9a9e25b4a850).() const |
| 150 | { |
| 151 | return active_cxx . . $ ControlGroupXMLParser#active_.; |
| 152 | } |
| 153 | |
| 154 | void ControlGroupXMLParsercxx . . $ ControlGroupXMLParser#::appendTocxx . . $ ControlGroupXMLParser#appendTo(9a62add8cbc6c333).(pugicxx . . $ pugi/::xml_nodecxx . . $ pugi/xml_node# &parentNode) |
| 155 | { |
| 156 | auto node = parentNode.append_childcxx . . $ pugi/xml_node#append_child(625782b904aa9aa5).(IDcxx . . $ ProfilePartXMLParser#ID(f4fff0029955a25f).().c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).()); |
| 157 | node.append_attributecxx . . $ pugi/xml_node#append_attribute(ebf82b7b6f96d3a9).("active") =cxx . . $ pugi/xml_attribute#`operator=`(e4ef2dfcdb6b654d). active_cxx . . $ ControlGroupXMLParser#active_.; |
| 158 | |
| 159 | for (auto &parser : parsers_cxx . . $ ControlGroupXMLParser#parsers_.) |
| 160 | parser->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).appendTocxx . . $ IProfilePartXMLParser#appendTo(9a62add8cbc6c333).(node); |
| 161 | } |
| 162 | |
| 163 | void ControlGroupXMLParsercxx . . $ ControlGroupXMLParser#::resetAttributescxx . . $ ControlGroupXMLParser#resetAttributes(49f6e7a06ebc5aa8).() |
| 164 | { |
| 165 | active_cxx . . $ ControlGroupXMLParser#active_. = activeDefaultcxx . . $ ControlGroupXMLParser#activeDefault(50ce9a9e25b4a850).(); |
| 166 | } |
| 167 | |
| 168 | void ControlGroupXMLParsercxx . . $ ControlGroupXMLParser#::loadPartFromcxx . . $ ControlGroupXMLParser#loadPartFrom(ad773084382c4c72).(pugicxx . . $ pugi/::xml_nodecxx . . $ pugi/xml_node# const &parentNode) |
| 169 | { |
| 170 | auto node = parentNode.find_childcxx . . $ pugi/xml_node#find_child(4699405ca595259d).( |
| 171 | [&](pugicxx . . $ pugi/::xml_nodecxx . . $ pugi/xml_node# const &node) { return node.namecxx . . $ pugi/xml_node#name(a9f41ea0e82d88cf).() == IDcxx . . $ ProfilePartXMLParser#ID(f4fff0029955a25f).(); }); |
| 172 | |
| 173 | active_cxx . . $ ControlGroupXMLParser#active_. = node.attributecxx . . $ pugi/xml_node#attribute(760b1819de0561d9).("active").as_boolcxx . . $ pugi/xml_attribute#as_bool(962fae8be55e1d9).(activeDefaultcxx . . $ ControlGroupXMLParser#activeDefault(50ce9a9e25b4a850).()); |
| 174 | loadComponentscxx . . $ ControlGroupXMLParser#loadComponents(ad773084382c4c72).(node); |
| 175 | } |
| 176 | |
| 177 | void ControlGroupXMLParsercxx . . $ ControlGroupXMLParser#::loadComponentscxx . . $ ControlGroupXMLParser#loadComponents(ad773084382c4c72).(pugicxx . . $ pugi/::xml_nodecxx . . $ pugi/xml_node# const &parentNode) |
| 178 | { |
| 179 | for (auto &parser : parsers_cxx . . $ ControlGroupXMLParser#parsers_.) |
| 180 | parser->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).loadFromcxx . . $ IProfilePartXMLParser#loadFrom(ad773084382c4c72).(parentNode); |
| 181 | } |
| 182 | |
| 183 | bool ControlGroupXMLParsercxx . . $ ControlGroupXMLParser#::activeDefaultcxx . . $ ControlGroupXMLParser#activeDefault(50ce9a9e25b4a850).() const |
| 184 | { |
| 185 | return activeDefault_cxx . . $ ControlGroupXMLParser#activeDefault_.; |
| 186 | } |