Qore Programming Language  1.12.0
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 Methods

DLLEXPORT class QoreStringget (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 QoreStringNodegetAsStringNode (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

◆ get() [1/2]

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
namethe name of the environment variable
Returns
a QoreString pointer (or 0 if the variable does not exist), caller owns the pointer returned

◆ get() [2/2]

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
namethe name of the environment variable
stra 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

◆ getAsStringNode()

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
namethe 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

◆ set()

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
namethe name of the environment variable to set
valuethe value of the environment variable
overwritethe overwrite flag

◆ unset()

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

unsets the given environment variable

Parameters
namethe name of the environment variable to unset
Returns
0 for OK, non-0 for error

◆ valueExists()

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

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

Parameters
namethe 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: