All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
AtomicEnvironmentSetter Class Reference

class allowing for multiple updates to the system environment within a single lock in a thread-safe way, can be used on the stack More...

`#include <SystemEnvironment.h>`

## Public Member Functions

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...
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...
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...
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...
DLLEXPORT int | unset (const char *name)
| unsets the given environment variable More...
DLLEXPORT bool | valueExists (const char *name)
| returns true if the environment variable exists and has a value, false if not More...

## Detailed Description

class allowing for multiple updates to the system environment within a single lock in a thread-safe way, can be used on the stack

some systems (HP-UX, for examplex) require a lock to access the environment in a multi-threaded environment. This class allows for multiple updates to be done within the scope of the lock

See Also
  SystemEnvironment

## Member Function Documentation

DLLEXPORT class QoreString* AtomicEnvironmentSetter::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

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

DLLEXPORT int AtomicEnvironmentSetter::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

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

DLLEXPORT class QoreStringNode* AtomicEnvironmentSetter::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

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

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

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

DLLEXPORT int AtomicEnvironmentSetter::unset | ( | const char * | name | ) |

unsets the given environment variable

Parameters

  name | the name of the environment variable to unset

Returns
  0 for OK, non-0 for error

DLLEXPORT bool AtomicEnvironmentSetter::valueExists | ( | const char * | name | ) |

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 (79e5dd4f976dab9d74ec8272aec97c21df86c597)