| 1 | // SPDX-License-Identifier: GPL-3.0-or-latercxx . . $ `<file>/src/core/components/controls/controlmodexmlparser.cpp`/ |
| 2 | // Copyright 2019 Juan Palacios <[email protected]> |
| 3 | |
| 4 | #include "controlmodexmlparser.h"cxx . . $ `<file>/src/core/components/controls/controlmodexmlparser.h`/ |
| 5 | |
| 6 | #include "core/item.h"cxx . . $ `<file>/src/core/item.h`/ |
| 7 | #include <utility> |
| 8 | |
| 9 | class ControlModeXMLParsercxx . . $ ControlModeXMLParser#::Factorycxx . . $ ControlModeXMLParser#Factory# final |
| 10 | : public ProfilePartXMLParsercxx . . $ ProfilePartXMLParser#::Factorycxx . . $ ProfilePartXMLParser#Factory# |
| 11 | , public ControlModeProfilePartcxx . . $ ControlModeProfilePart#::Exportercxx . . $ ControlModeProfilePart#Exporter# |
| 12 | { |
| 13 | public: |
| 14 | Factorycxx . . $ ControlModeXMLParser#Factory#Factory(745f85210429eb8c).(IProfilePartXMLParserProvidercxx . . $ IProfilePartXMLParserProvider# const &profilePartParserProvider, |
| 15 | ControlModeXMLParsercxx . . $ ControlModeXMLParser# &outer) noexcept |
| 16 | : ProfilePartXMLParsercxx . . $ ProfilePartXMLParser#::Factorycxx . . $ ProfilePartXMLParser#Factory#(profilePartParserProvider) |
| 17 | , outer_cxx . . $ ControlModeXMLParser#Factory#outer_.(outer) |
| 18 | { |
| 19 | } |
| 20 | |
| 21 | void takePartParsercxx . . $ ControlModeXMLParser#Factory#takePartParser(4ce663d5ecbeb887).(Itemcxx . . $ Item# const &i, |
| 22 | stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<IProfilePartXMLParsercxx . . $ IProfilePartXMLParser#> &&part) override; |
| 23 | |
| 24 | stdcxx . . $ std/::optionalcxx . . $ std/optional#<stdcxx . . $ std/::reference_wrappercxx . . $ std/reference_wrapper#<Exportablecxx . . $ Exportable#::Exportercxx . . $ Exportable#Exporter#>> |
| 25 | provideExportercxx . . $ ControlModeXMLParser#Factory#provideExporter(3acccbde2694e33a).(Itemcxx . . $ Item# const &i) override; |
| 26 | |
| 27 | void takeActivecxx . . $ ControlModeXMLParser#Factory#takeActive(b45ddcbc8423892c).(bool) override |
| 28 | { |
| 29 | } |
| 30 | |
| 31 | void takeModecxx . . $ ControlModeXMLParser#Factory#takeMode(9c546c94e5fcce4e).(stdcxx . . $ std/::stringcxx . . $ std/string# const &) override |
| 32 | { |
| 33 | } |
| 34 | |
| 35 | private: |
| 36 | ControlModeXMLParsercxx . . $ ControlModeXMLParser# &outer_cxx . . $ ControlModeXMLParser#Factory#outer_.; |
| 37 | }; |
| 38 | |
| 39 | void ControlModeXMLParsercxx . . $ ControlModeXMLParser#::Factorycxx . . $ ControlModeXMLParser#Factory#::takePartParsercxx . . $ ControlModeXMLParser#Factory#takePartParser(4ce663d5ecbeb887).( |
| 40 | Itemcxx . . $ Item# const &i, stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<IProfilePartXMLParsercxx . . $ IProfilePartXMLParser#> &&part) |
| 41 | { |
| 42 | outer_cxx . . $ ControlModeXMLParser#Factory#outer_..parsers_cxx . . $ ControlModeXMLParser#parsers_..emplacecxx . . $ std/unordered_map#emplace(8e800962ae7274b6).(i.IDcxx . . $ Item#ID(f4fff0029955a25f).(), stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(part)); |
| 43 | } |
| 44 | |
| 45 | stdcxx . . $ std/::optionalcxx . . $ std/optional#<stdcxx . . $ std/::reference_wrappercxx . . $ std/reference_wrapper#<Exportablecxx . . $ Exportable#::Exportercxx . . $ Exportable#Exporter#>> |
| 46 | ControlModeXMLParsercxx . . $ ControlModeXMLParser#::Factorycxx . . $ ControlModeXMLParser#Factory#::provideExportercxx . . $ ControlModeXMLParser#Factory#provideExporter(3acccbde2694e33a).(Itemcxx . . $ Item# const &i) |
| 47 | { |
| 48 | if (i.IDcxx . . $ Item#ID(f4fff0029955a25f).() ==cxx . . $ std/`operator==`(5ea818b58063a774). outer_cxx . . $ ControlModeXMLParser#Factory#outer_..IDcxx . . $ ProfilePartXMLParser#ID(f4fff0029955a25f).()) |
| 49 | return *cxx . . $ std/optional#optional(e3f0d6382bd52f24).this; |
| 50 | else |
| 51 | return factorycxx . . $ ProfilePartXMLParser#Factory#factory(3acccbde2694e33a).(i); |
| 52 | } |
| 53 | |
| 54 | class ControlModeXMLParsercxx . . $ ControlModeXMLParser#::Initializercxx . . $ ControlModeXMLParser#Initializer# final |
| 55 | : public ControlModeProfilePartcxx . . $ ControlModeProfilePart#::Exportercxx . . $ ControlModeProfilePart#Exporter# |
| 56 | { |
| 57 | public: |
| 58 | Initializercxx . . $ ControlModeXMLParser#Initializer#Initializer(3a46fc4e57fa28b9).(ControlModeXMLParsercxx . . $ ControlModeXMLParser# &outer) noexcept |
| 59 | : outer_cxx . . $ ControlModeXMLParser#Initializer#outer_.(outer) |
| 60 | { |
| 61 | } |
| 62 | |
| 63 | stdcxx . . $ std/::optionalcxx . . $ std/optional#<stdcxx . . $ std/::reference_wrappercxx . . $ std/reference_wrapper#<Exportablecxx . . $ Exportable#::Exportercxx . . $ Exportable#Exporter#>> |
| 64 | provideExportercxx . . $ ControlModeXMLParser#Initializer#provideExporter(3acccbde2694e33a).(Itemcxx . . $ Item# const &i) override; |
| 65 | |
| 66 | void takeActivecxx . . $ ControlModeXMLParser#Initializer#takeActive(b45ddcbc8423892c).(bool active) override; |
| 67 | void takeModecxx . . $ ControlModeXMLParser#Initializer#takeMode(9c546c94e5fcce4e).(stdcxx . . $ std/::stringcxx . . $ std/string# const &mode) override; |
| 68 | |
| 69 | private: |
| 70 | ControlModeXMLParsercxx . . $ ControlModeXMLParser# &outer_cxx . . $ ControlModeXMLParser#Initializer#outer_.; |
| 71 | 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 . . $ ControlModeXMLParser#Initializer#initializers_.; |
| 72 | }; |
| 73 | |
| 74 | stdcxx . . $ std/::optionalcxx . . $ std/optional#<stdcxx . . $ std/::reference_wrappercxx . . $ std/reference_wrapper#<Exportablecxx . . $ Exportable#::Exportercxx . . $ Exportable#Exporter#>> |
| 75 | ControlModeXMLParsercxx . . $ ControlModeXMLParser#::Initializercxx . . $ ControlModeXMLParser#Initializer#::provideExportercxx . . $ ControlModeXMLParser#Initializer#provideExporter(3acccbde2694e33a).(Itemcxx . . $ Item# const &i) |
| 76 | { |
| 77 | auto &id = i.IDcxx . . $ Item#ID(f4fff0029955a25f).(); |
| 78 | if (outer_cxx . . $ ControlModeXMLParser#Initializer#outer_..parsers_cxx . . $ ControlModeXMLParser#parsers_..countcxx . . $ std/unordered_map#count(b71ff106d381144b).(id) > 0) { |
| 79 | if (initializers_cxx . . $ ControlModeXMLParser#Initializer#initializers_..countcxx . . $ std/unordered_map#count(b71ff106d381144b).(id) > 0) |
| 80 | return *cxx . . $ std/optional#optional(e3f0d6382bd52f24).initializers_cxx . . $ ControlModeXMLParser#Initializer#initializers_..atcxx . . $ std/unordered_map#at(4f10b6009f0ee734).(id); |
| 81 | else { |
| 82 | auto initializer = outer_cxx . . $ ControlModeXMLParser#Initializer#outer_..parsers_cxx . . $ ControlModeXMLParser#parsers_..atcxx . . $ std/unordered_map#at(4f10b6009f0ee734).(id)->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).initializercxx . . $ IProfilePartXMLParser#initializer(6b4e1016740e578).(); |
| 83 | if (initializer != nullptr) { |
| 84 | initializers_cxx . . $ ControlModeXMLParser#Initializer#initializers_..emplacecxx . . $ std/unordered_map#emplace(8e800962ae7274b6).(id, stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(initializer)); |
| 85 | return *cxx . . $ std/optional#optional(e3f0d6382bd52f24).initializers_cxx . . $ ControlModeXMLParser#Initializer#initializers_..atcxx . . $ std/unordered_map#at(4f10b6009f0ee734).(id); |
| 86 | } |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | return {cxx . . $ std/optional#optional(ced63f7c635d850d).}; |
| 91 | } |
| 92 | |
| 93 | void ControlModeXMLParsercxx . . $ ControlModeXMLParser#::Initializercxx . . $ ControlModeXMLParser#Initializer#::takeActivecxx . . $ ControlModeXMLParser#Initializer#takeActive(b45ddcbc8423892c).(bool active) |
| 94 | { |
| 95 | outer_cxx . . $ ControlModeXMLParser#Initializer#outer_..active_cxx . . $ ControlModeXMLParser#active_. = outer_cxx . . $ ControlModeXMLParser#Initializer#outer_..activeDefault_cxx . . $ ControlModeXMLParser#activeDefault_. = active; |
| 96 | } |
| 97 | |
| 98 | void ControlModeXMLParsercxx . . $ ControlModeXMLParser#::Initializercxx . . $ ControlModeXMLParser#Initializer#::takeModecxx . . $ ControlModeXMLParser#Initializer#takeMode(9c546c94e5fcce4e).(stdcxx . . $ std/::stringcxx . . $ std/string# const &mode) |
| 99 | { |
| 100 | outer_cxx . . $ ControlModeXMLParser#Initializer#outer_..mode_cxx . . $ ControlModeXMLParser#mode_. =cxx . . $ std/__cxx11/basic_string#`operator=`(c0b47be1fddc0e75). outer_cxx . . $ ControlModeXMLParser#Initializer#outer_..modeDefault_cxx . . $ ControlModeXMLParser#modeDefault_. =cxx . . $ std/__cxx11/basic_string#`operator=`(c0b47be1fddc0e75). mode; |
| 101 | } |
| 102 | |
| 103 | ControlModeXMLParsercxx . . $ ControlModeXMLParser#::ControlModeXMLParsercxx . . $ ControlModeXMLParser#ControlModeXMLParser(c6e332c41c54746f).(stdcxx . . $ std/::string_viewcxx . . $ std/string_view# id) noexcept |
| 104 | : ProfilePartXMLParsercxx . . $ ProfilePartXMLParser#(idcxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02)., *this, *this) |
| 105 | { |
| 106 | } |
| 107 | |
| 108 | stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<Exportablecxx . . $ Exportable#::Exportercxx . . $ Exportable#Exporter#> ControlModeXMLParsercxx . . $ ControlModeXMLParser#::factorycxx . . $ ControlModeXMLParser#factory(543373651c38a5a4).( |
| 109 | IProfilePartXMLParserProvidercxx . . $ IProfilePartXMLParserProvider# const &profilePartXMLParserProvider) |
| 110 | { |
| 111 | return stdcxx . . $ std/unique_ptr#unique_ptr(8bcafd3b0b660df8).::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<ControlModeXMLParsercxx . . $ ControlModeXMLParser#::Factorycxx . . $ ControlModeXMLParser#Factory#>( |
| 112 | profilePartXMLParserProvider, *this); |
| 113 | } |
| 114 | |
| 115 | stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<Exportablecxx . . $ Exportable#::Exportercxx . . $ Exportable#Exporter#> ControlModeXMLParsercxx . . $ ControlModeXMLParser#::initializercxx . . $ ControlModeXMLParser#initializer(6b4e1016740e578).() |
| 116 | { |
| 117 | return stdcxx . . $ std/unique_ptr#unique_ptr(8bcafd3b0b660df8).::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<ControlModeXMLParsercxx . . $ ControlModeXMLParser#::Initializercxx . . $ ControlModeXMLParser#Initializer#>(*this); |
| 118 | } |
| 119 | |
| 120 | stdcxx . . $ std/::optionalcxx . . $ std/optional#<stdcxx . . $ std/::reference_wrappercxx . . $ std/reference_wrapper#<Exportablecxx . . $ Exportable#::Exportercxx . . $ Exportable#Exporter#>> |
| 121 | ControlModeXMLParsercxx . . $ ControlModeXMLParser#::provideExportercxx . . $ ControlModeXMLParser#provideExporter(3acccbde2694e33a).(Itemcxx . . $ Item# const &i) |
| 122 | { |
| 123 | auto parserIt = parsers_cxx . . $ ControlModeXMLParser#parsers_..findcxx . . $ std/unordered_map#find(f711f2f81556fe93).(i.IDcxx . . $ Item#ID(f4fff0029955a25f).()); |
| 124 | if (parserIt != parsers_cxx . . $ ControlModeXMLParser#parsers_..cendcxx . . $ std/unordered_map#cend(f3c6e12ee1fe7252).()) |
| 125 | return parserItcxx . . $ std/optional#optional(e3f0d6382bd52f24).->cxx . . $ std/__detail/_Node_iterator#`operator->`(35610babf8706b50).secondcxx . . $ std/pair#second.->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 | ControlModeXMLParsercxx . . $ ControlModeXMLParser#::provideImportercxx . . $ ControlModeXMLParser#provideImporter(c13a3bcac0db4745).(Itemcxx . . $ Item# const &i) |
| 132 | { |
| 133 | auto parserIt = parsers_cxx . . $ ControlModeXMLParser#parsers_..findcxx . . $ std/unordered_map#find(f711f2f81556fe93).(i.IDcxx . . $ Item#ID(f4fff0029955a25f).()); |
| 134 | if (parserIt != parsers_cxx . . $ ControlModeXMLParser#parsers_..cendcxx . . $ std/unordered_map#cend(f3c6e12ee1fe7252).()) |
| 135 | return parserItcxx . . $ std/optional#optional(e3f0d6382bd52f24).->cxx . . $ std/__detail/_Node_iterator#`operator->`(35610babf8706b50).secondcxx . . $ std/pair#second.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).profilePartImportercxx . . $ IProfilePartXMLParser#profilePartImporter(c6a8a54be61afbf2).(); |
| 136 | |
| 137 | return {cxx . . $ std/optional#optional(ced63f7c635d850d).}; |
| 138 | } |
| 139 | |
| 140 | void ControlModeXMLParsercxx . . $ ControlModeXMLParser#::takeActivecxx . . $ ControlModeXMLParser#takeActive(b45ddcbc8423892c).(bool active) |
| 141 | { |
| 142 | active_cxx . . $ ControlModeXMLParser#active_. = active; |
| 143 | } |
| 144 | |
| 145 | bool ControlModeXMLParsercxx . . $ ControlModeXMLParser#::provideActivecxx . . $ ControlModeXMLParser#provideActive(50ce9a9e25b4a850).() const |
| 146 | { |
| 147 | return active_cxx . . $ ControlModeXMLParser#active_.; |
| 148 | } |
| 149 | |
| 150 | void ControlModeXMLParsercxx . . $ ControlModeXMLParser#::takeModecxx . . $ ControlModeXMLParser#takeMode(9c546c94e5fcce4e).(stdcxx . . $ std/::stringcxx . . $ std/string# const &mode) |
| 151 | { |
| 152 | mode_cxx . . $ ControlModeXMLParser#mode_. =cxx . . $ std/__cxx11/basic_string#`operator=`(c0b47be1fddc0e75). mode; |
| 153 | } |
| 154 | |
| 155 | stdcxx . . $ std/::stringcxx . . $ std/string# const &ControlModeXMLParsercxx . . $ ControlModeXMLParser#::provideModecxx . . $ ControlModeXMLParser#provideMode(f4fff0029955a25f).() const |
| 156 | { |
| 157 | return mode_cxx . . $ ControlModeXMLParser#mode_.; |
| 158 | } |
| 159 | |
| 160 | void ControlModeXMLParsercxx . . $ ControlModeXMLParser#::appendTocxx . . $ ControlModeXMLParser#appendTo(9a62add8cbc6c333).(pugicxx . . $ pugi/::xml_nodecxx . . $ pugi/xml_node# &parentNode) |
| 161 | { |
| 162 | auto node = parentNode.append_childcxx . . $ pugi/xml_node#append_child(625782b904aa9aa5).(IDcxx . . $ ProfilePartXMLParser#ID(f4fff0029955a25f).().c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).()); |
| 163 | node.append_attributecxx . . $ pugi/xml_node#append_attribute(ebf82b7b6f96d3a9).("active") =cxx . . $ pugi/xml_attribute#`operator=`(e4ef2dfcdb6b654d). active_cxx . . $ ControlModeXMLParser#active_.; |
| 164 | node.append_attributecxx . . $ pugi/xml_node#append_attribute(ebf82b7b6f96d3a9).("mode") =cxx . . $ pugi/xml_attribute#`operator=`(e97dd6b1417bcd5a). mode_cxx . . $ ControlModeXMLParser#mode_..c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).(); |
| 165 | |
| 166 | for (auto &[key, component] : parsers_cxx . . $ ControlModeXMLParser#parsers_.) |
| 167 | component->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).appendTocxx . . $ IProfilePartXMLParser#appendTo(9a62add8cbc6c333).(node); |
| 168 | } |
| 169 | |
| 170 | void ControlModeXMLParsercxx . . $ ControlModeXMLParser#::resetAttributescxx . . $ ControlModeXMLParser#resetAttributes(49f6e7a06ebc5aa8).() |
| 171 | { |
| 172 | active_cxx . . $ ControlModeXMLParser#active_. = activeDefaultcxx . . $ ControlModeXMLParser#activeDefault(50ce9a9e25b4a850).(); |
| 173 | mode_cxx . . $ ControlModeXMLParser#mode_. =cxx . . $ std/__cxx11/basic_string#`operator=`(c0b47be1fddc0e75). modeDefaultcxx . . $ ControlModeXMLParser#modeDefault(f4fff0029955a25f).(); |
| 174 | } |
| 175 | |
| 176 | void ControlModeXMLParsercxx . . $ ControlModeXMLParser#::loadPartFromcxx . . $ ControlModeXMLParser#loadPartFrom(ad773084382c4c72).(pugicxx . . $ pugi/::xml_nodecxx . . $ pugi/xml_node# const &parentNode) |
| 177 | { |
| 178 | auto node = parentNode.find_childcxx . . $ pugi/xml_node#find_child(4699405ca595259d).( |
| 179 | [&](pugicxx . . $ pugi/::xml_nodecxx . . $ pugi/xml_node# const &node) { return node.namecxx . . $ pugi/xml_node#name(a9f41ea0e82d88cf).() == IDcxx . . $ ProfilePartXMLParser#ID(f4fff0029955a25f).(); }); |
| 180 | |
| 181 | active_cxx . . $ ControlModeXMLParser#active_. = node.attributecxx . . $ pugi/xml_node#attribute(760b1819de0561d9).("active").as_boolcxx . . $ pugi/xml_attribute#as_bool(962fae8be55e1d9).(activeDefaultcxx . . $ ControlModeXMLParser#activeDefault(50ce9a9e25b4a850).()); |
| 182 | mode_cxx . . $ ControlModeXMLParser#mode_. =cxx . . $ std/__cxx11/basic_string#`operator=`(978ca1133b5f6e74). node.attributecxx . . $ pugi/xml_node#attribute(760b1819de0561d9).("mode").as_stringcxx . . $ pugi/xml_attribute#as_string(865ea18671f48fc1).(modeDefaultcxx . . $ ControlModeXMLParser#modeDefault(f4fff0029955a25f).().c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).()); |
| 183 | |
| 184 | loadComponentscxx . . $ ControlModeXMLParser#loadComponents(ad773084382c4c72).(node); |
| 185 | } |
| 186 | |
| 187 | void ControlModeXMLParsercxx . . $ ControlModeXMLParser#::loadComponentscxx . . $ ControlModeXMLParser#loadComponents(ad773084382c4c72).(pugicxx . . $ pugi/::xml_nodecxx . . $ pugi/xml_node# const &parentNode) |
| 188 | { |
| 189 | for (auto &[key, component] : parsers_cxx . . $ ControlModeXMLParser#parsers_.) |
| 190 | component->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).loadFromcxx . . $ IProfilePartXMLParser#loadFrom(ad773084382c4c72).(parentNode); |
| 191 | } |
| 192 | |
| 193 | bool ControlModeXMLParsercxx . . $ ControlModeXMLParser#::activeDefaultcxx . . $ ControlModeXMLParser#activeDefault(50ce9a9e25b4a850).() const |
| 194 | { |
| 195 | return activeDefault_cxx . . $ ControlModeXMLParser#activeDefault_.; |
| 196 | } |
| 197 | |
| 198 | stdcxx . . $ std/::stringcxx . . $ std/string# const &ControlModeXMLParsercxx . . $ ControlModeXMLParser#::modeDefaultcxx . . $ ControlModeXMLParser#modeDefault(f4fff0029955a25f).() const |
| 199 | { |
| 200 | return modeDefault_cxx . . $ ControlModeXMLParser#modeDefault_.; |
| 201 | } |