diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 18:07:22 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 18:07:22 +0000 |
commit | c04dcc2e7d834218ef2d4194331e383402495ae1 (patch) | |
tree | 7333e38d10d75386e60f336b80c2443c1166031d /xbmc/addons/addoninfo/AddonExtensions.cpp | |
parent | Initial commit. (diff) | |
download | kodi-c04dcc2e7d834218ef2d4194331e383402495ae1.tar.xz kodi-c04dcc2e7d834218ef2d4194331e383402495ae1.zip |
Adding upstream version 2:20.4+dfsg.upstream/2%20.4+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'xbmc/addons/addoninfo/AddonExtensions.cpp')
-rw-r--r-- | xbmc/addons/addoninfo/AddonExtensions.cpp | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/xbmc/addons/addoninfo/AddonExtensions.cpp b/xbmc/addons/addoninfo/AddonExtensions.cpp new file mode 100644 index 0000000..b0bc3c5 --- /dev/null +++ b/xbmc/addons/addoninfo/AddonExtensions.cpp @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#include "AddonExtensions.h" + +#include "utils/StringUtils.h" + +using namespace ADDON; + +bool SExtValue::asBoolean() const +{ + return StringUtils::EqualsNoCase(str, "true"); +} + +const SExtValue CAddonExtensions::GetValue(const std::string& id) const +{ + for (const auto& values : m_values) + { + for (const auto& value : values.second) + { + if (value.first == id) + return value.second; + } + } + return SExtValue(""); +} + +const EXT_VALUES& CAddonExtensions::GetValues() const +{ + return m_values; +} + +const CAddonExtensions* CAddonExtensions::GetElement(const std::string& id) const +{ + for (const auto& child : m_children) + { + if (child.first == id) + return &child.second; + } + + return nullptr; +} + +const EXT_ELEMENTS CAddonExtensions::GetElements(const std::string& id) const +{ + if (id.empty()) + return m_children; + + EXT_ELEMENTS children; + for (const auto& child : m_children) + { + if (child.first == id) + children.push_back(std::make_pair(child.first, child.second)); + } + return children; +} + +void CAddonExtensions::Insert(const std::string& id, const std::string& value) +{ + EXT_VALUE extension; + extension.push_back(std::make_pair(id, SExtValue(value))); + m_values.push_back(std::make_pair(id, extension)); +} |