blob: 768c5d86b92575886d69f90e02975d9e123c08cd (
plain)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
/*-------------------------------------------------------------------------
*
* pgenv.h
*
*
* DESCRIPTION
* Postgres Environment Class: manages and stores all the required
* connection variables.
*
* NOTES
* Currently under construction.
*
* Copyright (c) 1994, Regents of the University of California
*
*-------------------------------------------------------------------------
*/
#ifndef PGENV_H
#define PGENV_H
#include <string>
//
// these are the environment variables used for getting defaults
//
#define ENV_DEFAULT_AUTH "PGAUTH"
#define ENV_DEFAULT_DBASE "PGDATABASE"
#define ENV_DEFAULT_HOST "PGHOST"
#define ENV_DEFAULT_OPTION "PGOPTION"
#define ENV_DEFAULT_PORT "PGPORT"
#define ENV_DEFAULT_TTY "PGTTY"
// ****************************************************************
//
// PgEnv - the environment for setting up a connection to postgres
//
// ****************************************************************
class PgEnv {
private:
string pgAuth;
string pgHost;
string pgPort;
string pgOption;
string pgTty;
public:
PgEnv(); // default ctor will use reasonable defaults
// will use environment variables PGHOST, PGPORT,
// PGOPTION, PGTTY
PgEnv(const string& auth, const string& host, const string& port,
const string& option, const string& tty);
// Access methods to all the environment variables
const char* Auth() { return pgAuth.c_str(); }
void Auth(const string& auth) { pgAuth = auth; }
const char* Host() { return pgHost.c_str(); }
void Host(const string& host) { pgHost = host; }
const char* Port() { return pgPort.c_str(); }
void Port(const string& port) { pgPort = port; }
const char* Option() { return pgOption.c_str(); }
void Option(const string& option) { pgOption = option; }
const char* TTY() { return pgTty.c_str(); }
void TTY(const string& tty) { pgTty = tty; }
void SetValues(const string& auth, const string& host, const string& port,
const string& option, const string& tty);
protected:
string getenv(const char*);
};
#endif // PGENV_H
|