AFHBA404
AFHBA404 connects ACQ2106 to PCI-Express
Env.h
Go to the documentation of this file.
1 /*
2  * Env.h
3  *
4  * Created on: 19 Sep 2019
5  * Author: pgm
6  */
7 
8 #ifndef ENV_H_
9 #define ENV_H_
10 
11 #include <stdlib.h>
12 
13 #include <iostream>
14 #include <fstream>
15 #include <string>
16 #include <algorithm>
17 #include <map>
18 
19 class Env {
20  std::map<std::string,std::string> _env;
21 public:
22 
23  Env(const char* fname);
24  std::string& operator() (std::string key);
25 
26  static int getenv(const char* key, int def) {
27  const char* sv = ::getenv(key);
28  if (sv){
29  return strtol(sv, 0, 0);
30  }else{
31  return def;
32  }
33  }
34  static const char* getenv(const char* key, const char* def) {
35  const char* sv = ::getenv(key);
36  if (sv){
37  return sv;
38  }else{
39  return def;
40  }
41  }
42 };
43 
44 
45 
46 
47 #endif /* ENV_H_ */
Env::Env
Env(const char *fname)
Definition: Env.cpp:16
Env::operator()
std::string & operator()(std::string key)
Definition: Env.cpp:38
Env::getenv
static int getenv(const char *key, int def)
Definition: Env.h:26
Env
Definition: Env.h:19
Env::getenv
static const char * getenv(const char *key, const char *def)
Definition: Env.h:34