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.
18 class CAddonInfoBuilder
;
19 class CAddonDatabaseSerializer
;
23 explicit SExtValue(const std::string
& strValue
) : str(strValue
) { }
24 const std::string
& asString() const { return str
; }
25 bool asBoolean() const;
26 int asInteger() const { return std::atoi(str
.c_str()); }
27 float asFloat() const { return static_cast<float>(std::atof(str
.c_str())); }
28 bool empty() const { return str
.empty(); }
29 const std::string str
;
33 class CAddonExtensions
;
34 typedef std::vector
<std::pair
<std::string
, CAddonExtensions
>> EXT_ELEMENTS
;
35 typedef std::vector
<std::pair
<std::string
, SExtValue
>> EXT_VALUE
;
36 typedef std::vector
<std::pair
<std::string
, CExtValues
>> EXT_VALUES
;
38 class CExtValues
: public EXT_VALUE
41 CExtValues(const EXT_VALUE
& values
) : EXT_VALUE(values
) { }
43 const SExtValue
GetValue(const std::string
& id
) const
45 for (const auto& value
: *this)
47 if (value
.first
== id
)
54 class CAddonExtensions
57 CAddonExtensions() = default;
58 ~CAddonExtensions() = default;
60 const SExtValue
GetValue(const std::string
& id
) const;
61 const EXT_VALUES
& GetValues() const;
62 const CAddonExtensions
* GetElement(const std::string
& id
) const;
63 const EXT_ELEMENTS
GetElements(const std::string
& id
= "") const;
65 void Insert(const std::string
& id
, const std::string
& value
);
68 friend class CAddonInfoBuilder
;
69 friend class CAddonDatabaseSerializer
;
73 EXT_ELEMENTS m_children
;
76 } /* namespace ADDON */