blob: 4ce67aa3c33776c330c274d1361a4204907a77d9 [file] [log] [blame]
Ethan Yonker1b7a31b2014-07-03 15:09:22 -05001/*
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
26using namespace std;
27
28class InfoManager
29{
30public:
Ethan Yonkerfe916112016-03-14 14:54:37 -050031 InfoManager();
32 explicit InfoManager(const string& filename);
Ethan Yonker1b7a31b2014-07-03 15:09:22 -050033 virtual ~InfoManager();
Ethan Yonkerfe916112016-03-14 14:54:37 -050034 void SetFile(const string& filename);
35 void SetFileVersion(int version);
36 void SetConst();
37 void Clear();
Ethan Yonker1b7a31b2014-07-03 15:09:22 -050038 int LoadValues();
39 int SaveValues();
40
41 // Core get routines
Ethan Yonkerfe916112016-03-14 14:54:37 -050042 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 Yonker1b7a31b2014-07-03 15:09:22 -050046
Ethan Yonkerfe916112016-03-14 14:54:37 -050047 string GetStrValue(const string& varName);
48 int GetIntValue(const string& varName);
Ethan Yonker1b7a31b2014-07-03 15:09:22 -050049
50 // Core set routines
Ethan Yonkerfe916112016-03-14 14:54:37 -050051 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 Yonker1b7a31b2014-07-03 15:09:22 -050055
56private:
57 string File;
58 map<string, string> mValues;
Ethan Yonkerfe916112016-03-14 14:54:37 -050059 int file_version;
60 bool is_const;
Ethan Yonker1b7a31b2014-07-03 15:09:22 -050061
62};
63
64#endif // _DATAMANAGER_HPP_HEADER
65