-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIniReader.h
executable file
·79 lines (63 loc) · 2.4 KB
/
IniReader.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/****************************************************************************
* DRAMSim2: A Cycle Accurate DRAM simulator
*
* Copyright (C) 2010 Elliott Cooper-Balis
* Paul Rosenfeld
* Bruce Jacob
* University of Maryland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*****************************************************************************/
#ifndef INIREADER_H
#define INIREADER_H
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include "SystemConfiguration.h"
using namespace std;
// Uhhh, apparently the #name equals "name" -- HOORAY MACROS!
#define DEFINE_UINT_PARAM(name, paramtype) {#name, &name, UINT, paramtype, false}
#define DEFINE_STRING_PARAM(name, paramtype) {#name, &name, STRING, paramtype, false}
#define DEFINE_FLOAT_PARAM(name,paramtype) {#name, &name, FLOAT, paramtype, false}
#define DEFINE_BOOL_PARAM(name, paramtype) {#name, &name, BOOL, paramtype, false}
#define DEFINE_UINT64_PARAM(name, paramtype) {#name, &name, UINT64, paramtype, false}
namespace DRAMSim
{
typedef enum _variableType {STRING, UINT, UINT64, FLOAT, BOOL} varType;
typedef enum _paramType {SYS_PARAM, DEV_PARAM} paramType;
typedef struct _configMap
{
string iniKey; //for example "tRCD"
void *variablePtr;
varType variableType;
paramType parameterType;
bool wasSet;
} ConfigMap;
class IniReader
{
public:
static void SetKey(string key, string value, bool isSystemParam = false, size_t lineNumber = 0);
static void OverrideKeys(vector<string> keys, vector<string> values);
static void ReadIniFile(string filename, bool isSystemParam);
static void InitEnumsFromStrings();
static bool CheckIfAllSet();
static void WriteValuesOut(std::ofstream &visDataOut);
private:
static void WriteParams(std::ofstream &visDataOut, paramType t);
static void Trim(string &str);
};
}
#endif