Loading...
Searching...
No Matches
Systems Extensions and Enhancements

Functions/classes for extending/enhancing standard OS functionality. More...

Files

file  dl.h
 Interface for opening code libraries.
 
file  getenv.h
 Functions for accessing environment variables.
 
file  setenv.h
 Functions for setting and unsetting environment variables.
 

Functions

TF_API void * TfDlopen (const std::string &filename, int flag, std::string *error=NULL, bool loadScriptBindings=true)
 Open a dynamic library and notify lib/tf that a new module has been loaded.
 
TF_API int TfDlclose (void *handle)
 Close a dynamic library.
 
TF_API std::string TfGetenv (const std::string &envName, const std::string &defaultValue="")
 Return an environment variable as a string.
 
TF_API int TfGetenvInt (const std::string &envName, int defaultValue)
 Return an environment variable as an integer.
 
TF_API bool TfGetenvBool (const std::string &, bool defaultValue)
 Return an environment variable as a boolean.
 
TF_API double TfGetenvDouble (const std::string &envName, double defaultValue)
 Return an environment variable as a double.
 
TF_API bool TfSetenv (const std::string &envName, const std::string &value)
 Set an environment variable.
 
TF_API bool TfUnsetenv (const std::string &envName)
 Unset an environment variable.
 

Detailed Description

Functions/classes for extending/enhancing standard OS functionality.

Function Documentation

◆ TfDlclose()

TF_API int TfDlclose ( void *  handle)

Close a dynamic library.

◆ TfDlopen()

TF_API void * TfDlopen ( const std::string &  filename,
int  flag,
std::string *  error = NULL,
bool  loadScriptBindings = true 
)

Open a dynamic library and notify lib/tf that a new module has been loaded.

This is a wrapper around ArchLibraryOpen() in the sense that this function calls ArchLibraryOpen(filename, flag) but it will additionally load script bindings if scripting is initialized and loading is requested.

If error is not NULL it will be set to a system reported error if opening the library failed, otherwise it will be cleared.

If you set TF_DLOPEN in the TF_DEBUG environment variable then debug output will be reported on each invocation of this function.

This returns an opaque handle to the opened library or NULL on failure.

◆ TfGetenv()

TF_API std::string TfGetenv ( const std::string &  envName,
const std::string &  defaultValue = "" 
)

Return an environment variable as a string.

Return the value of the environment variable envName as a string. If the variable is unset, or is the empty string, then defaultValue is returned.

◆ TfGetenvBool()

TF_API bool TfGetenvBool ( const std::string &  ,
bool  defaultValue 
)

Return an environment variable as a boolean.

Return the value of the environment variable envName as a boolean. If the variable is unset, or is the empty string, then defaultValue is returned. A value of true is returned if the environment variable is any of "true", "yes", "on" or "1"; the match is not case sensitive. All other values yield a return value of false.

◆ TfGetenvDouble()

TF_API double TfGetenvDouble ( const std::string &  envName,
double  defaultValue 
)

Return an environment variable as a double.

Return the value of the environment variable envName as a double. If the variable is unset, or is the empty string, then defaultValue is returned. Otherwise, the function uses TfStringToDouble() to convert the string to a double: the implication being that if the string is not a valid double, you get back whatever value TfStringToDouble() comes up with.

◆ TfGetenvInt()

TF_API int TfGetenvInt ( const std::string &  envName,
int  defaultValue 
)

Return an environment variable as an integer.

Return the value of the environment variable envName as an integer. If the variable is unset, or is the empty string, then defaultValue is returned. Otherwise, the function uses atoi() to convert the string to an integer: the implication being that if the string is not a valid integer, you get back whatever value atoi() comes up with.

◆ TfSetenv()

TF_API bool TfSetenv ( const std::string &  envName,
const std::string &  value 
)

Set an environment variable.

Sets an environment variable and ensures that it appears in the Python environment if Python is initialized. If Python has not yet been initialized, the variable envName is set to value in the environment using setenv. Otherwise, it is set both in the environment and in Python using TfPySetenv. The new value overwrites any existing value.

If the value cannot be set, false is returned and a warning is posted. Otherwise, the return value is true.

◆ TfUnsetenv()

TF_API bool TfUnsetenv ( const std::string &  envName)

Unset an environment variable.

Unsets an environment variable and ensures that it is also removed from the Python environment if Python is initialized. If Python has not yet been initialized, the variable envName is unset in the environment using unsetenv. Otherwise, it is unset both in the environment and in Python using TfPyUnsetenv.

If the value cannot be unset, false is returned and a warning is posted. Otherwise, the return value is true.