Qore Programming Language: SystemEnvironment Class Reference

Qore Programming Language 0.8.11

- Main Page
- Related Pages
- Modules
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Static Public Member Functions | Static Protected Member Functions | Friends | List of all members
SystemEnvironment Class Reference

class used to safely manipulate the system environment More...

`#include <SystemEnvironment.h>`

## Static Public Member Functions
static DLLEXPORT class QoreString * | get (const char *name)
| returns the value of the environment variable as a new QoreString object, 0 if not present, caller owns the pointer returned More...
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, -1 for not found More...
static DLLEXPORT class QoreStringNode * | getAsStringNode (const char *name)
| returns the value of the environment variable as a new QoreStringNode object, 0 if not present, caller owns the reference count of the pointer returned More...
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 More...
static DLLEXPORT int | unset (const char *name)
| unsets the given environment variable More...
static DLLEXPORT bool | valueExists (const char *name)
| returns true if the environment variable exists and has a value, false if not More...

## Static Protected Member Functions
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, caller owns the reference count of the pointer returned More...
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, caller owns the pointer returned More...
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, -1 for not found More...
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 More...
static DLLLOCAL int | unset_intern (const char *name)
| unsets the given environment variable More...

## Friends
class | AtomicEnvironmentSetter

## Detailed Description

class used to safely manipulate the system environment

On some platforms (HP-UX for example), the system environment cannot be accessed safely from multiple threads without a lock. This class guarantees thread-safe access to the environment on all systems (as long as all accesses are made through this class). There is only one of the objects; the constructor and destructor are not exported in the public interface of the library and therefore can only be instantiated internally anyway. To make multiple updates atomically within the environment lock, use AtomicEnvironmentSetter

See Also
  AtomicEnvironmentSetter

## Member Function Documentation

static DLLEXPORT class QoreString* SystemEnvironment::get | ( | const char * | name | ) |
| static

returns the value of the environment variable as a new QoreString object, 0 if not present, caller owns the pointer returned

Parameters

  name | the name of the environment variable

Returns
  a QoreString pointer (or 0 if the variable does not exist), caller owns the pointer returned

static DLLEXPORT int SystemEnvironment::get | ( | const char * | name,
|  | class QoreString & | str
| ) |  |
| static

appends the value of the given environment variable to a QoreString, returns 0 for OK, -1 for not found

Parameters

  name | the name of the environment variable
  str | a reference to a QoreString object where the value will be concatenated if the environment variable exists

Returns
  0 for OK (environment variable found and value concatenated to string), or -1 for not found

static DLLLOCAL class QoreStringNode* SystemEnvironment::get_as_string_node_intern | ( | const char * | name | ) |
| staticprotected

returns the value of the environment variable as a new QoreStringNode object, 0 if not present, caller owns the reference count of the pointer returned

unlocked

Parameters

  name | the name of the environment variable

Returns
  a QoreStringNode pointer (or 0 if the variable does not exist), caller owns the reference count of the pointer returned

static DLLLOCAL class QoreString* SystemEnvironment::get_intern | ( | const char * | name | ) |
| staticprotected

returns the value of the environment variable as a new QoreString object, 0 if not present, caller owns the pointer returned

unlocked

Parameters

  name | the name of the environment variable

Returns
  a QoreString pointer (or 0 if the variable does not exist), caller owns the pointer returned

static DLLLOCAL int SystemEnvironment::get_intern | ( | const char * | name,
|  | class QoreString & | str
| ) |  |
| staticprotected

appends the value of the given environment variable to a QoreString, returns 0 for OK, -1 for not found

unlocked

Parameters

  name | the name of the environment variable
  str | a reference to a QoreString object where the value will be concatenated if the environment variable exists

Returns
  0 for OK (environment variable found and value concatenated to string), or -1 for not found

static DLLEXPORT class QoreStringNode* SystemEnvironment::getAsStringNode | ( | const char * | name | ) |
| static

returns the value of the environment variable as a new QoreStringNode object, 0 if not present, caller owns the reference count of the pointer returned

Parameters

  name | the name of the environment variable

Returns
  a QoreStringNode pointer (or 0 if the variable does not exist), caller owns the reference count of the pointer returned

static DLLEXPORT int SystemEnvironment::set | ( | const char * | name,
|  | const char * | value,
|  | bool | overwrite = `1`
| ) |  |
| static

sets the given environment variable to the value passed, respecting the overwrite flag

Parameters

  name | the name of the environment variable to set
  value | the value of the environment variable
  overwrite | the overwrite flag

static DLLLOCAL int SystemEnvironment::set_intern | ( | const char * | name,
|  | const char * | value,
|  | bool | overwrite = `1`
| ) |  |
| staticprotected

sets the given environment variable to the value passed, respecting the overwrite flag

unlocked

Parameters

  name | the name of the environment variable to set
  value | the value of the environment variable
  overwrite | the overwrite flag

static DLLEXPORT int SystemEnvironment::unset | ( | const char * | name | ) |
| static

unsets the given environment variable

Parameters

  name | the name of the environment variable to unset

Returns
  0 for OK, non-0 for error

static DLLLOCAL int SystemEnvironment::unset_intern | ( | const char * | name | ) |
| staticprotected

unsets the given environment variable

unlocked

Parameters

  name | the name of the environment variable to unset

Returns
  0 for OK, non-0 for error

static DLLEXPORT bool SystemEnvironment::valueExists | ( | const char * | name | ) |
| static

returns true if the environment variable exists and has a value, false if not

Parameters

  name | the name of the environment variable to check

Returns
  true if the environment variable exists and has a value, false if not

The documentation for this class was generated from the following file:

- include/qore/SystemEnvironment.h (6585)