forked from petermilne/ACQ420FMC
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathEnv.cpp
More file actions
40 lines (32 loc) · 752 Bytes
/
Env.cpp
File metadata and controls
40 lines (32 loc) · 752 Bytes
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
/*
* Env.cpp
*
* Created on: 19 Sep 2019
* Author: pgm
*/
// @@todo : DO not enforce namespace on client
#include "Env.h"
using namespace std;
Env::Env(const char* fname) {
ifstream fs(fname);
string line;
while(getline(fs, line)){
// cout << line << endl;
if (line.find("#") == 0){
// cerr << line << " skip comment" <<endl;
continue;
}
size_t pos;
if ((pos = line.find("=")) != std::string::npos ){
string key = line.substr(0, pos);
string value = line.substr(pos+1);
value.erase(std::remove(value.begin(), value.end(), '"'), value.end());
// cerr << "k:" << key << " v:" << value << endl;
_env[key] = value;
}
}
fs.close();
}
string& Env::operator() (std::string key) {
return _env[key];
}