Ethan Yonker | 1b7a31b | 2014-07-03 15:09:22 -0500 | [diff] [blame] | 1 | /* |
| 2 | Copyright 2012 bigbiff/Dees_Troy TeamWin |
| 3 | This file is part of TWRP/TeamWin Recovery Project. |
| 4 | |
| 5 | TWRP is free software: you can redistribute it and/or modify |
| 6 | it under the terms of the GNU General Public License as published by |
| 7 | the Free Software Foundation, either version 3 of the License, or |
| 8 | (at your option) any later version. |
| 9 | |
| 10 | TWRP is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | GNU General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU General Public License |
| 16 | along with TWRP. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | |
| 19 | #ifndef _INFOMANAGER_HPP_HEADER |
| 20 | #define _INFOMANAGER_HPP_HEADER |
| 21 | |
| 22 | #include <string> |
| 23 | #include <utility> |
| 24 | #include <map> |
| 25 | |
| 26 | using namespace std; |
| 27 | |
| 28 | class InfoManager |
| 29 | { |
| 30 | public: |
Ethan Yonker | fe91611 | 2016-03-14 14:54:37 -0500 | [diff] [blame] | 31 | InfoManager(); |
| 32 | explicit InfoManager(const string& filename); |
Ethan Yonker | 1b7a31b | 2014-07-03 15:09:22 -0500 | [diff] [blame] | 33 | virtual ~InfoManager(); |
Ethan Yonker | fe91611 | 2016-03-14 14:54:37 -0500 | [diff] [blame] | 34 | void SetFile(const string& filename); |
| 35 | void SetFileVersion(int version); |
| 36 | void SetConst(); |
| 37 | void Clear(); |
Ethan Yonker | 1b7a31b | 2014-07-03 15:09:22 -0500 | [diff] [blame] | 38 | int LoadValues(); |
| 39 | int SaveValues(); |
| 40 | |
| 41 | // Core get routines |
Ethan Yonker | fe91611 | 2016-03-14 14:54:37 -0500 | [diff] [blame] | 42 | int GetValue(const string& varName, string& value); |
| 43 | int GetValue(const string& varName, int& value); |
| 44 | int GetValue(const string& varName, float& value); |
| 45 | unsigned long long GetValue(const string& varName, unsigned long long& value); |
Ethan Yonker | 1b7a31b | 2014-07-03 15:09:22 -0500 | [diff] [blame] | 46 | |
Ethan Yonker | fe91611 | 2016-03-14 14:54:37 -0500 | [diff] [blame] | 47 | string GetStrValue(const string& varName); |
| 48 | int GetIntValue(const string& varName); |
Ethan Yonker | 1b7a31b | 2014-07-03 15:09:22 -0500 | [diff] [blame] | 49 | |
| 50 | // Core set routines |
Ethan Yonker | fe91611 | 2016-03-14 14:54:37 -0500 | [diff] [blame] | 51 | int SetValue(const string& varName, const string& value); |
| 52 | int SetValue(const string& varName, const int value); |
| 53 | int SetValue(const string& varName, const float value); |
| 54 | int SetValue(const string& varName, const unsigned long long& value); |
Ethan Yonker | 1b7a31b | 2014-07-03 15:09:22 -0500 | [diff] [blame] | 55 | |
| 56 | private: |
| 57 | string File; |
| 58 | map<string, string> mValues; |
Ethan Yonker | fe91611 | 2016-03-14 14:54:37 -0500 | [diff] [blame] | 59 | int file_version; |
| 60 | bool is_const; |
Ethan Yonker | 1b7a31b | 2014-07-03 15:09:22 -0500 | [diff] [blame] | 61 | |
| 62 | }; |
| 63 | |
| 64 | #endif // _DATAMANAGER_HPP_HEADER |
| 65 | |