forked from adeharo9/cpp-dotenv
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdotenv.h
More file actions
54 lines (34 loc) · 1.22 KB
/
dotenv.h
File metadata and controls
54 lines (34 loc) · 1.22 KB
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
#pragma once
#include <string>
namespace dotenv
{
class dotenv
{
public:
using key_type = std::string;
using value_type = std::string;
public:
dotenv& load_dotenv(const std::string& dotenv_path = ".env",
const bool overwrite = false,
const bool interpolate = true);
const value_type operator[](const key_type& k) const;
public:
virtual ~dotenv() = default;
dotenv(const dotenv&) = delete;
void operator=(const dotenv&) = delete;
static dotenv& instance();
private:
dotenv() = default;
private:
// Declare static members (definitions are inline after the class)
// NOTE: env_filename is kept for backward compatibility; external code
// may reference dotenv::dotenv::env_filename directly.
static const std::string env_filename;
static dotenv _instance;
};
// C++17 inline variable definitions after class is complete
// Note: _instance cannot be inline inside the class due to incomplete type
inline const std::string dotenv::env_filename = ".env";
inline dotenv dotenv::_instance;
extern dotenv& env;
}