Merge pull request #26220 from 78andyp/blurayfixes
[xbmc.git] / xbmc / addons / addoninfo / AddonExtensions.cpp
blob496373ff88951de72d92a4700e351894d0d5481c
1 /*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #include "AddonExtensions.h"
11 #include "utils/StringUtils.h"
13 using namespace ADDON;
15 bool SExtValue::asBoolean() const
17 return StringUtils::EqualsNoCase(str, "true");
20 const SExtValue CAddonExtensions::GetValue(const std::string& id) const
22 for (const auto& values : m_values)
24 for (const auto& value : values.second)
26 if (value.first == id)
27 return value.second;
30 return SExtValue("");
33 const EXT_VALUES& CAddonExtensions::GetValues() const
35 return m_values;
38 const CAddonExtensions* CAddonExtensions::GetElement(const std::string& id) const
40 for (const auto& child : m_children)
42 if (child.first == id)
43 return &child.second;
46 return nullptr;
49 const EXT_ELEMENTS CAddonExtensions::GetElements(const std::string& id) const
51 if (id.empty())
52 return m_children;
54 EXT_ELEMENTS children;
55 for (const auto& child : m_children)
57 if (child.first == id)
58 children.emplace_back(child.first, child.second);
60 return children;
63 void CAddonExtensions::Insert(const std::string& id, const std::string& value)
65 EXT_VALUE extension;
66 extension.emplace_back(id, SExtValue(value));
67 m_values.emplace_back(id, extension);