Qore Programming Language 1.19.2
Loading...
Searching...
No Matches
SystemEnvironment.h
1/* -*- mode: c++; indent-tabs-mode: nil -*- */
2/*
3 SystemEnvironment.h
4
5 Qore Programming Language
6
7 Copyright (C) 2003 - 2023 David Nichols
8
9 Permission is hereby granted, free of charge, to any person obtaining a
10 copy of this software and associated documentation files (the "Software"),
11 to deal in the Software without restriction, including without limitation
12 the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 and/or sell copies of the Software, and to permit persons to whom the
14 Software is furnished to do so, subject to the following conditions:
15
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 DEALINGS IN THE SOFTWARE.
26
27 Note that the Qore library is released under a choice of three open-source
28 licenses: MIT (as above), LGPL 2+, or GPL 2+; see README-LICENSE for more
29 information.
30*/
31
32#ifndef _QORE_SYSTEMENVIRONMENT_H
33
34#define _QORE_SYSTEMENVIRONMENT_H
35
37
47 friend class AtomicEnvironmentSetter;
48
49 private:
51 DLLLOCAL SystemEnvironment(const SystemEnvironment&);
52
54 DLLLOCAL SystemEnvironment& operator=(const SystemEnvironment&);
55
56 protected:
58
63 DLLLOCAL static int set_intern(const char *name, const char *value, bool overwrite = 1);
64
66
70 DLLLOCAL static class QoreString *get_intern(const char *name);
71
73
77 DLLLOCAL static class QoreStringNode *get_as_string_node_intern(const char *name);
78
80
85 DLLLOCAL static int get_intern(const char *name, class QoreString &str);
86
88
92 DLLLOCAL static int unset_intern(const char *name);
93
94 public:
95 DLLLOCAL SystemEnvironment();
96 DLLLOCAL ~SystemEnvironment();
97
99
104 DLLEXPORT static int set(const char *name, const char *value, bool overwrite = 1);
105
107
111 DLLEXPORT static class QoreString *get(const char *name);
112
114
118 DLLEXPORT static class QoreStringNode *getAsStringNode(const char *name);
119
121
126 DLLEXPORT static int get(const char *name, class QoreString &str);
127
129
133 DLLEXPORT static int unset(const char *name);
134
136
140 DLLEXPORT static bool valueExists(const char* name); // true if exists and is not empty
141};
142
143DLLEXPORT extern SystemEnvironment SysEnv;
144
146
151{
152 private:
155
157 DLLLOCAL AtomicEnvironmentSetter& operator=(const AtomicEnvironmentSetter&);
158
160 DLLLOCAL void* operator new(size_t); // not implemented, make sure it is not new'ed
161
162 public:
163 DLLEXPORT AtomicEnvironmentSetter();
164 DLLEXPORT ~AtomicEnvironmentSetter();
165
167
172 DLLEXPORT int set(const char *name, const char *value, bool overwrite = 1);
173
175
179 DLLEXPORT class QoreString *get(const char *name);
180
182
186 DLLEXPORT class QoreStringNode *getAsStringNode(const char *name);
187
189
194 DLLEXPORT int get(const char *name, class QoreString &str);
195
197
201 DLLEXPORT int unset(const char *name);
202
204
208 DLLEXPORT bool valueExists(const char* name); // true if exists and is not empty
209};
210
211#endif
class allowing for multiple updates to the system environment within a single lock in a thread-safe w...
Definition: SystemEnvironment.h:151
DLLEXPORT int set(const char *name, const char *value, bool overwrite=1)
sets the given environment variable to the value passed, respecting the overwrite flag
DLLEXPORT int unset(const char *name)
unsets the given environment variable
DLLEXPORT bool valueExists(const char *name)
returns true if the environment variable exists and has a value, false if not
DLLEXPORT int get(const char *name, class QoreString &str)
appends the value of the given environment variable to a QoreString, returns 0 for OK,...
DLLEXPORT class QoreStringNode * getAsStringNode(const char *name)
returns the value of the environment variable as a new QoreStringNode object, 0 if not present,...
DLLEXPORT class QoreString * get(const char *name)
returns the value of the environment variable as a new QoreString object, 0 if not present,...
Qore's string type supported by the QoreEncoding class.
Definition: QoreString.h:93
Qore's string value type, reference counted, dynamically-allocated only.
Definition: QoreStringNode.h:50
class used to safely manipulate the system environment
Definition: SystemEnvironment.h:46
static DLLLOCAL int unset_intern(const char *name)
unsets the given environment variable
static DLLEXPORT class QoreStringNode * getAsStringNode(const char *name)
returns the value of the environment variable as a new QoreStringNode object, 0 if not present,...
static DLLEXPORT bool valueExists(const char *name)
returns true if the environment variable exists and has a value, false if not
static DLLLOCAL int get_intern(const char *name, class QoreString &str)
appends the value of the given environment variable to a QoreString, returns 0 for OK,...
static DLLEXPORT int set(const char *name, const char *value, bool overwrite=1)
sets the given environment variable to the value passed, respecting the overwrite flag
static DLLEXPORT int unset(const char *name)
unsets the given environment variable
static DLLEXPORT int get(const char *name, class QoreString &str)
appends the value of the given environment variable to a QoreString, returns 0 for OK,...
static DLLLOCAL class QoreString * get_intern(const char *name)
returns the value of the environment variable as a new QoreString object, 0 if not present,...
static DLLEXPORT class QoreString * get(const char *name)
returns the value of the environment variable as a new QoreString object, 0 if not present,...
static DLLLOCAL int set_intern(const char *name, const char *value, bool overwrite=1)
sets the given environment variable to the value passed, respecting the overwrite flag
static DLLLOCAL class QoreStringNode * get_as_string_node_intern(const char *name)
returns the value of the environment variable as a new QoreStringNode object, 0 if not present,...