AFHBA404
AFHBA404 connects ACQ2106 to PCI-Express
Env.cpp
Go to the documentation of this file.
1 /*
2  * Env.cpp
3  *
4  * Created on: 19 Sep 2019
5  * Author: pgm
6  */
7 
8 
9 // @@todo : DO not enforce namespace on client
10 
11 
12 #include "Env.h"
13 
14 using namespace std;
15 
16 Env::Env(const char* fname) {
17  ifstream fs(fname);
18  string line;
19  while(getline(fs, line)){
20  // cout << line << endl;
21  if (line.find("#") == 0){
22 // cerr << line << " skip comment" <<endl;
23  continue;
24  }
25  size_t pos;
26  if ((pos = line.find("=")) != std::string::npos ){
27  string key = line.substr(0, pos);
28  string value = line.substr(pos+1);
29  value.erase(std::remove(value.begin(), value.end(), '"'), value.end());
30 
31 // cerr << "k:" << key << " v:" << value << endl;
32  _env[key] = value;
33  }
34  }
35  fs.close();
36 }
37 
38 string& Env::operator() (std::string key) {
39  return _env[key];
40 }
Env::Env
Env(const char *fname)
Definition: Env.cpp:16
Env::operator()
std::string & operator()(std::string key)
Definition: Env.cpp:38
Env.h