-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathConVarStorage.cpp
53 lines (40 loc) · 990 Bytes
/
ConVarStorage.cpp
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
#include "ConVarStorage.h"
#include "cuboid_shared.h"
#include <cstdlib>
#include <sstream> //for converting int/float to string
using namespace std;
ConVarStorage::ConVarStorage() {}
ConVarStorage::~ConVarStorage() {
varList.clear();
}
bool ConVarStorage::varExists(string Name) {
return (varList.count(Name) == 1) ? true : false;
}
//get vars
string ConVarStorage::getVarS(string Name) {
if( varList.count(Name) == 1 ){
return varList[Name];
}else{
return string();
}
}
int ConVarStorage::getVarI(string Name) {
return atoi( getVarS(Name).c_str() );
}
float ConVarStorage::getVarF(string Name) {
return atof( getVarS(Name).c_str() );
}
//set vars
void ConVarStorage::setVarS(string Name, string Value) {
varList[Name] = Value;
}
void ConVarStorage::setVarI(string Name, int Value) {
stringstream tmp;
tmp << Value;
varList[Name] = tmp.out;
}
void ConVarStorage::setVarF(string Name, float Value) {
stringstream tmp;
tmp << Value;
varList[Name] = tmp.out;
}