SDL3pp
A slim C++ wrapper for SDL3
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
SDL::EnvironmentRef Struct Reference

A thread-safe set of environment variables. More...

Inheritance diagram for SDL::EnvironmentRef:
Inheritance graph
[legend]

Public Member Functions

const char * GetVariable (StringParam name)
 Get the value of a variable in the environment.
 
OwnArray< char * > GetVariables ()
 Get all variables in the environment.
 
Uint64 GetVariableCount ()
 Get the Variables count.
 
void SetVariable (StringParam name, StringParam value, bool overwrite)
 Set the value of a variable in the environment.
 
void UnsetVariable (StringParam name)
 Clear a variable from the environment.
 
constexpr Resource (T resource={})
 Constructs from the underlying resource.
 
constexpr Resource (const ResourceHandle< Resource< T > > auto &resource)
 Constructs from pointer like.
 
constexpr Resource (std::nullptr_t)
 Equivalent to default ctor.
 
constexpr Resource (std::nullopt_t)
 Equivalent to default ctor.
 
- Public Member Functions inherited from SDL::Resource< SDL_Environment * >
constexpr Resource (SDL_Environment * resource={})
 Constructs from the underlying resource.
 
constexpr Resource (const ResourceHandle< Resource< SDL_Environment * > > auto &resource)
 Constructs from pointer like.
 
constexpr Resource (std::nullptr_t)
 Equivalent to default ctor.
 
constexpr Resource (std::nullopt_t)
 Equivalent to default ctor.
 
constexpr operator bool () const
 True if contains a valid resource.
 
constexpr operator value_type () const
 Converts back to underlying type.
 
constexpr bool operator== (const Resource &other) const=default
 Comparison.
 
constexpr bool operator== (std::nullopt_t) const
 Comparison.
 
constexpr bool operator== (std::nullptr_t) const
 Comparison.
 
constexpr SDL_Environment * get () const
 Return contained resource;.
 
constexpr const SDL_Environment * operator-> () const
 Access to fields.
 
constexpr SDL_Environment * operator-> ()
 Access to fields.
 

Static Public Member Functions

static void reset (SDL_Environment *resource)
 Destroy a set of environment variables.
 

Additional Inherited Members

- Public Types inherited from SDL::Resource< SDL_Environment * >
using value_type = SDL_Environment *
 The raw resource type.
 

Detailed Description

Since
This struct is available since SDL 3.2.0.
Category:
Resource
See also
Environment
GetEnvironment
Environment.Create
EnvironmentRef.GetVariable
EnvironmentRef.GetVariables
EnvironmentRef.SetVariable
EnvironmentRef.UnsetVariable
Environment.Destroy

Member Function Documentation

◆ GetVariable()

const char * SDL::EnvironmentRef::GetVariable ( StringParam  name)
inline
Parameters
namethe name of the variable to get.
Returns
a pointer to the value of the variable or nullptr if it can't be found.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.
See also
GetEnvironment
Environment.Environment
EnvironmentRef.GetVariables
EnvironmentRef.SetVariable
EnvironmentRef.UnsetVariable

◆ GetVariableCount()

Uint64 SDL::EnvironmentRef::GetVariableCount ( )
inline
Returns
the number of existing environment variables

This might be slow.

◆ GetVariables()

OwnArray< char * > SDL::EnvironmentRef::GetVariables ( )
inline
Returns
a nullptr terminated array of pointers to environment variables in the form "variable=value" on success. This is wrapped to be auto-deleted, use FreeWrapper.release() if you want to manage manually.
Exceptions
Erroron failure
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.
See also
GetEnvironment
Environment.Environment
EnvironmentRef.GetVariables
EnvironmentRef.SetVariable
EnvironmentRef.UnsetVariable

◆ reset()

static void SDL::EnvironmentRef::reset ( SDL_Environment *  resource)
inlinestatic
Parameters
resourcethe environment to destroy.
Thread safety:
It is safe to call this function from any thread, as long as the environment is no longer in use.
Since
This function is available since SDL 3.2.0.
See also
Environment.Create

◆ SetVariable()

void SDL::EnvironmentRef::SetVariable ( StringParam  name,
StringParam  value,
bool  overwrite 
)
inline
Parameters
namethe name of the variable to set.
valuethe value of the variable to set.
overwritetrue to overwrite the variable if it exists, false to return success without setting the variable if it already exists.
Exceptions
Erroron failure.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.
See also
GetEnvironment
Environment.Environment
EnvironmentRef.GetVariable
EnvironmentRef.GetVariables
EnvironmentRef.UnsetVariable

◆ UnsetVariable()

void SDL::EnvironmentRef::UnsetVariable ( StringParam  name)
inline
Parameters
namethe name of the variable to unset.
Exceptions
Erroron failure.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.
See also
GetEnvironment
Environment.Environment
EnvironmentRef.GetVariable
EnvironmentRef.GetVariables
EnvironmentRef.SetVariable
EnvironmentRef.UnsetVariable

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