Qore Programming Language  0.8.9
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
SystemEnvironment.h
1 /* -*- mode: c++; indent-tabs-mode: nil -*- */
2 /*
3  SystemEnvironment.h
4 
5  Qore Programming Language
6 
7  Copyright 2003 - 2013 David Nichols
8 
9  This library is free software; you can redistribute it and/or
10  modify it under the terms of the GNU Lesser General Public
11  License as published by the Free Software Foundation; either
12  version 2.1 of the License, or (at your option) any later version.
13 
14  This library is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public
20  License along with this library; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23 
24 #ifndef _QORE_SYSTEMENVIRONMENT_H
25 
26 #define _QORE_SYSTEMENVIRONMENT_H
27 
29 
39  friend class AtomicEnvironmentSetter;
40 
41  private:
43  DLLLOCAL SystemEnvironment(const SystemEnvironment&);
44 
46  DLLLOCAL SystemEnvironment& operator=(const SystemEnvironment&);
47 
48  protected:
50 
55  DLLLOCAL static int set_intern(const char *name, const char *value, bool overwrite = 1);
56 
58 
62  DLLLOCAL static class QoreString *get_intern(const char *name);
63 
65 
69  DLLLOCAL static class QoreStringNode *get_as_string_node_intern(const char *name);
70 
72 
77  DLLLOCAL static int get_intern(const char *name, class QoreString &str);
78 
80 
84  DLLLOCAL static int unset_intern(const char *name);
85 
86  public:
87  DLLLOCAL SystemEnvironment();
88  DLLLOCAL ~SystemEnvironment();
89 
91 
96  DLLEXPORT static int set(const char *name, const char *value, bool overwrite = 1);
97 
99 
103  DLLEXPORT static class QoreString *get(const char *name);
104 
106 
110  DLLEXPORT static class QoreStringNode *getAsStringNode(const char *name);
111 
113 
118  DLLEXPORT static int get(const char *name, class QoreString &str);
119 
121 
125  DLLEXPORT static int unset(const char *name);
126 
128 
132  DLLEXPORT static bool valueExists(const char* name); // true if exists and is not empty
133 };
134 
135 DLLEXPORT extern SystemEnvironment SysEnv;
136 
138 
143 {
144  private:
147 
149  DLLLOCAL AtomicEnvironmentSetter& operator=(const AtomicEnvironmentSetter&);
150 
152  DLLLOCAL void* operator new(size_t); // not implemented, make sure it is not new'ed
153 
154  public:
155  DLLEXPORT AtomicEnvironmentSetter();
156  DLLEXPORT ~AtomicEnvironmentSetter();
157 
159 
164  DLLEXPORT int set(const char *name, const char *value, bool overwrite = 1);
165 
167 
171  DLLEXPORT class QoreString *get(const char *name);
172 
174 
178  DLLEXPORT class QoreStringNode *getAsStringNode(const char *name);
179 
181 
186  DLLEXPORT int get(const char *name, class QoreString &str);
187 
189 
193  DLLEXPORT int unset(const char *name);
194 
196 
200  DLLEXPORT bool valueExists(const char* name); // true if exists and is not empty
201 };
202 
203 #endif
class allowing for multiple updates to the system environment within a single lock in a thread-safe w...
Definition: SystemEnvironment.h:142
static DLLEXPORT bool valueExists(const char *name)
returns true if the environment variable exists and has a value, false if not
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...
DLLEXPORT int unset(const char *name)
unsets the given environment variable
class used to safely manipulate the system environment
Definition: SystemEnvironment.h:38
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 ...
Qore's string type supported by the QoreEncoding class.
Definition: QoreString.h:42
Qore's string value type, reference counted, dynamically-allocated only.
Definition: QoreStringNode.h:40
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 int unset(const char *name)
unsets the given environment variable
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...
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 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 bool valueExists(const char *name)
returns true if the environment variable exists and has a value, false if not