All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
SystemEnvironment.h
/* -*- mode: c++; indent-tabs-mode: nil -*- */
/*
SystemEnvironment.h
Qore Programming Language
Copyright 2003 - 2013 David Nichols
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _QORE_SYSTEMENVIRONMENT_H
#define _QORE_SYSTEMENVIRONMENT_H
class SystemEnvironment {
friend class AtomicEnvironmentSetter;
private:
DLLLOCAL SystemEnvironment(const SystemEnvironment&);
DLLLOCAL SystemEnvironment& operator=(const SystemEnvironment&);
protected:
DLLLOCAL static int set_intern(const char *name, const char *value, bool overwrite = 1);
DLLLOCAL static class QoreString *get_intern(const char *name);
DLLLOCAL static class QoreStringNode *get_as_string_node_intern(const char *name);
DLLLOCAL static int get_intern(const char *name, class QoreString &str);
DLLLOCAL static int unset_intern(const char *name);
public:
DLLLOCAL SystemEnvironment();
DLLLOCAL ~SystemEnvironment();
DLLEXPORT static int set(const char *name, const char *value, bool overwrite = 1);
DLLEXPORT static class QoreString *get(const char *name);
DLLEXPORT static class QoreStringNode *getAsStringNode(const char *name);
DLLEXPORT static int get(const char *name, class QoreString &str);
DLLEXPORT static int unset(const char *name);
DLLEXPORT static bool valueExists(const char* name); // true if exists and is not empty
};
DLLEXPORT extern SystemEnvironment SysEnv;
class AtomicEnvironmentSetter
{
private:
DLLLOCAL AtomicEnvironmentSetter(const AtomicEnvironmentSetter&);
DLLLOCAL AtomicEnvironmentSetter& operator=(const AtomicEnvironmentSetter&);
DLLLOCAL void* operator new(size_t); // not implemented, make sure it is not new'ed
public:
DLLEXPORT AtomicEnvironmentSetter();
DLLEXPORT ~AtomicEnvironmentSetter();
DLLEXPORT int set(const char *name, const char *value, bool overwrite = 1);
DLLEXPORT class QoreString *get(const char *name);
DLLEXPORT class QoreStringNode *getAsStringNode(const char *name);
DLLEXPORT int get(const char *name, class QoreString &str);
DLLEXPORT int unset(const char *name);
DLLEXPORT bool valueExists(const char* name); // true if exists and is not empty
};
#endif