1 /*
2  *  Copyright (C) 2013-2018 Team Kodi
3  *  This file is part of Kodi - https://kodi.tv
4  *
5  *  SPDX-License-Identifier: GPL-2.0-or-later
6  *  See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include <memory>
12 #include <vector>
13 
14 class CVariant;
15 class CSettingList;
16 class CSetting;
17 
18 class CSettingUtils
19 {
20 public:
21   /*!
22    \brief Gets the values of the given list setting.
23 
24    \param settingList List setting
25    \return List of values of the given list setting
26    */
27   static std::vector<CVariant> GetList(const std::shared_ptr<const CSettingList>& settingList);
28   /*!
29    \brief Sets the values of the given list setting.
30 
31    \param settingList List setting
32    \param value Values to set
33    \return True if setting the values was successful, false otherwise
34    */
35   static bool SetList(const std::shared_ptr<CSettingList>& settingList,
36                       const std::vector<CVariant>& value);
37 
38   static std::vector<CVariant> ListToValues(const std::shared_ptr<const CSettingList>& setting,
39                                             const std::vector<std::shared_ptr<CSetting>>& values);
40   static bool ValuesToList(const std::shared_ptr<const CSettingList>& setting,
41                            const std::vector<CVariant>& values,
42                            std::vector<std::shared_ptr<CSetting>>& newValues);
43 
44   /*!
45    \brief Search in a list of Ints for a given value.
46 
47    \param settingList CSettingList instance
48    \param value value to search for
49    \return True if value was found in list, false otherwise
50   */
51   static bool FindIntInList(const std::shared_ptr<const CSettingList>& settingList, int value);
52 };
53