Qore Programming Language  0.8.3
include/qore/SystemEnvironment.h (4311)
00001 /* -*- mode: c++; indent-tabs-mode: nil -*- */
00002 /*
00003   SystemEnvironment.h
00004 
00005   Qore Programming Language
00006 
00007   Copyright 2003 - 2011 David Nichols
00008 
00009   This library is free software; you can redistribute it and/or
00010   modify it under the terms of the GNU Lesser General Public
00011   License as published by the Free Software Foundation; either
00012   version 2.1 of the License, or (at your option) any later version.
00013 
00014   This library is distributed in the hope that it will be useful,
00015   but WITHOUT ANY WARRANTY; without even the implied warranty of
00016   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017   Lesser General Public License for more details.
00018 
00019   You should have received a copy of the GNU Lesser General Public
00020   License along with this library; if not, write to the Free Software
00021   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00022 */
00023 
00024 #ifndef _QORE_SYSTEMENVIRONMENT_H
00025 
00026 #define _QORE_SYSTEMENVIRONMENT_H
00027 
00029 
00038 class SystemEnvironment {
00039       friend class AtomicEnvironmentSetter;
00040 
00041    private:
00043       DLLLOCAL SystemEnvironment(const SystemEnvironment&);
00044 
00046       DLLLOCAL SystemEnvironment& operator=(const SystemEnvironment&);
00047 
00048    protected:
00050 
00055       DLLLOCAL static int set_intern(const char *name, const char *value, bool overwrite = 1);
00056 
00058 
00062       DLLLOCAL static class QoreString *get_intern(const char *name);
00063 
00065 
00069       DLLLOCAL static class QoreStringNode *get_as_string_node_intern(const char *name);
00070 
00072 
00077       DLLLOCAL static int get_intern(const char *name, class QoreString &str);
00078       
00080 
00084       DLLLOCAL static int unset_intern(const char *name);
00085       
00086    public:
00087       DLLLOCAL SystemEnvironment();
00088       DLLLOCAL ~SystemEnvironment();
00089 
00091 
00096       DLLEXPORT static int set(const char *name, const char *value, bool overwrite = 1);
00097 
00099 
00103       DLLEXPORT static class QoreString *get(const char *name);
00104 
00106 
00110       DLLEXPORT static class QoreStringNode *getAsStringNode(const char *name);
00111 
00113 
00118       DLLEXPORT static int get(const char *name, class QoreString &str);
00119       
00121 
00125       DLLEXPORT static int unset(const char *name);
00126       
00128 
00132       DLLEXPORT static bool valueExists(const char* name); // true if exists and is not empty
00133 };
00134 
00135 DLLEXPORT extern SystemEnvironment SysEnv;
00136 
00138 
00142 class AtomicEnvironmentSetter
00143 {
00144    private:
00146       DLLLOCAL AtomicEnvironmentSetter(const AtomicEnvironmentSetter&);
00147 
00149       DLLLOCAL AtomicEnvironmentSetter& operator=(const AtomicEnvironmentSetter&);
00150 
00152       DLLLOCAL void* operator new(size_t); // not implemented, make sure it is not new'ed
00153 
00154    public:
00155       DLLEXPORT AtomicEnvironmentSetter();
00156       DLLEXPORT ~AtomicEnvironmentSetter();
00157 
00159 
00164       DLLEXPORT int set(const char *name, const char *value, bool overwrite = 1);
00165 
00167 
00171       DLLEXPORT class QoreString *get(const char *name);
00172 
00174 
00178       DLLEXPORT class QoreStringNode *getAsStringNode(const char *name);
00179 
00181 
00186       DLLEXPORT int get(const char *name, class QoreString &str);
00187       
00189 
00193       DLLEXPORT int unset(const char *name);
00194       
00196 
00200       DLLEXPORT bool valueExists(const char* name); // true if exists and is not empty
00201 };
00202 
00203 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines