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

SDL properties ID. More...

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

Public Member Functions

void CopyPropertiesTo (PropertiesRef dst) const
 Copy a group of properties.
 
PropertiesLock Lock () &
 Lock a group of properties.
 
void SetPointerWithCleanup (StringParam name, void *value, CleanupPropertyCB cleanup)
 Set a pointer property in a group of properties with a cleanup function that is called when the property is deleted.
 
void SetPointerWithCleanup (StringParam name, void *value, CleanupPropertyCallback cleanup, void *userdata)
 Set a pointer property in a group of properties with a cleanup function that is called when the property is deleted.
 
void SetPointer (StringParam name, void *value)
 Set a pointer property in a group of properties.
 
void SetString (StringParam name, StringParam value)
 Set a string property in a group of properties.
 
void SetNumber (StringParam name, Sint64 value)
 Set an integer property in a group of properties.
 
void SetFloat (StringParam name, float value)
 Set a floating point property in a group of properties.
 
void SetBoolean (StringParam name, bool value)
 Set a boolean property in a group of properties.
 
bool Has (StringParam name) const
 Return whether a property exists in a group of properties.
 
PropertyType GetType (StringParam name) const
 Get the type of a property.
 
void * GetPointer (StringParam name, void *default_value) const
 Get a pointer property from a group of properties.
 
const char * GetString (StringParam name, StringParam default_value) const
 Get a string property from a group of properties.
 
Sint64 GetNumber (StringParam name, Sint64 default_value) const
 Get a number property from a group of properties.
 
float GetFloat (StringParam name, float default_value) const
 Get a floating point property from a group of properties.
 
bool GetBoolean (StringParam name, bool default_value) const
 Get a boolean property from a group of properties.
 
void Clear (StringParam name)
 Clear a property from a group of properties.
 
template<std::output_iterator< const char * > IT>
void Enumerate (IT outputIter) const
 Enumerate the properties contained in a group of properties.
 
void Enumerate (EnumeratePropertiesCB callback) const
 Enumerate the properties contained in a group of properties.
 
void Enumerate (EnumeratePropertiesCallback callback, void *userdata) const
 Enumerate the properties contained in a group of properties.
 
Uint64 GetCount () const
 Returns the number of properties this has.
 
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_PropertiesID >
constexpr Resource (SDL_PropertiesID resource={})
 Constructs from the underlying resource.
 
constexpr Resource (const ResourceHandle< Resource< SDL_PropertiesID > > 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_PropertiesID get () const
 Return contained resource;.
 
constexpr const SDL_PropertiesID operator-> () const
 Access to fields.
 
constexpr SDL_PropertiesID operator-> ()
 Access to fields.
 

Static Public Member Functions

static void reset (SDL_PropertiesID resource)
 Destroy a group of properties.
 

Additional Inherited Members

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

Detailed Description

Since
This datatype is available since SDL 3.2.0.
Category:
Resource
See also
Properties.Create
Properties

Member Function Documentation

◆ Clear()

void SDL::PropertiesRef::Clear ( StringParam  name)
inline
Parameters
namethe name of the property to clear.
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.

◆ CopyPropertiesTo()

void SDL::PropertiesRef::CopyPropertiesTo ( PropertiesRef  dst) const
inline

Copy all the properties from one group of properties to another, with the exception of properties requiring cleanup (set using PropertiesRef.SetPointerWithCleanup()), which will not be copied. Any property that already exists on dst will be overwritten.

Parameters
dstthe destination properties.
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.

◆ Enumerate() [1/3]

void SDL::PropertiesRef::Enumerate ( EnumeratePropertiesCallback  callback,
void *  userdata 
) const
inline

The callback function is called for each property in the group of properties. The properties are locked during enumeration.

Parameters
callbackthe function to call for each property.
userdataa pointer that is passed to callback.
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.

◆ Enumerate() [2/3]

void SDL::PropertiesRef::Enumerate ( EnumeratePropertiesCB  callback) const
inline

The callback function is called for each property in the group of properties. The properties are locked during enumeration.

Parameters
callbackthe function to call for each property.
Exceptions
Erroron failure.
Thread safety:
It is safe to call this function from any thread.
Category:
Immediate callback
See also
immediate-callback

◆ Enumerate() [3/3]

template<std::output_iterator< const char * > IT>
void SDL::PropertiesRef::Enumerate ( IT  outputIter) const
inline
Parameters
outputIteran output iterator to be assigned to each property name.
Exceptions
Erroron failure.
Thread safety:
It is safe to call this function from any thread.

◆ GetBoolean()

bool SDL::PropertiesRef::GetBoolean ( StringParam  name,
bool  default_value 
) const
inline

You can use PropertiesRef.GetType() to query whether the property exists and is a boolean property.

By convention, the names of properties that SDL exposes on objects will start with "SDL.", and properties that SDL uses internally will start with "SDL.internal.". These should be considered read-only and should not be modified by applications.

Parameters
namethe name of the property to query.
default_valuethe default value of the property.
Returns
the value of the property, or default_value if it is not set or not a boolean property.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.
See also
PropertiesRef.GetType
PropertiesRef.Has
PropertiesRef.SetBoolean

◆ GetCount()

Uint64 SDL::PropertiesRef::GetCount ( ) const
inline

This uses Enumerate() internally, so might not be so fast

◆ GetFloat()

float SDL::PropertiesRef::GetFloat ( StringParam  name,
float  default_value 
) const
inline

You can use PropertiesRef.GetType() to query whether the property exists and is a floating point property.

By convention, the names of properties that SDL exposes on objects will start with "SDL.", and properties that SDL uses internally will start with "SDL.internal.". These should be considered read-only and should not be modified by applications.

Parameters
namethe name of the property to query.
default_valuethe default value of the property.
Returns
the value of the property, or default_value if it is not set or not a float property.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.
See also
PropertiesRef.GetType
PropertiesRef.Has
PropertiesRef.SetFloat

◆ GetNumber()

Sint64 SDL::PropertiesRef::GetNumber ( StringParam  name,
Sint64  default_value 
) const
inline

You can use PropertiesRef.GetType() to query whether the property exists and is a number property.

By convention, the names of properties that SDL exposes on objects will start with "SDL.", and properties that SDL uses internally will start with "SDL.internal.". These should be considered read-only and should not be modified by applications.

Parameters
namethe name of the property to query.
default_valuethe default value of the property.
Returns
the value of the property, or default_value if it is not set or not a number property.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.
See also
PropertiesRef.GetType
PropertiesRef.Has
PropertiesRef.SetNumber

◆ GetPointer()

void * SDL::PropertiesRef::GetPointer ( StringParam  name,
void *  default_value 
) const
inline

You can use SDL_GetPropertyType() to query whether the property exists and is a pointer property.

By convention, the names of properties that SDL exposes on objects will start with "SDL.", and properties that SDL uses internally will start with "SDL.internal.". These should be considered read-only and should not be modified by applications.

Parameters
namethe name of the property to query.
default_valuethe default value of the property.
Returns
the value of the property, or default_value if it is not set or not a pointer property.
Thread safety:
It is safe to call this function from any thread, although the data returned is not protected and could potentially be freed if you call PropertiesRef.SetPointer() or PropertiesRef.Clear() on these properties from another thread. If you need to avoid this, use PropertiesRef.Lock() and PropertiesLock.Unlock().
Since
This function is available since SDL 3.2.0.
See also
PropertiesRef.GetBoolean
PropertiesRef.GetFloat
PropertiesRef.GetNumber
PropertiesRef.GetType
PropertiesRef.GetString
PropertiesRef.Has
PropertiesRef.SetPointer

◆ GetString()

const char * SDL::PropertiesRef::GetString ( StringParam  name,
StringParam  default_value 
) const
inline

You can use SDL_GetPropertyType() to query whether the property exists and is a string property.

By convention, the names of properties that SDL exposes on objects will start with "SDL.", and properties that SDL uses internally will start with "SDL.internal.". These should be considered read-only and should not be modified by applications.

Parameters
namethe name of the property to query.
default_valuethe default value of the property.
Returns
the value of the property, or default_value if it is not set or not a string property.
Thread safety:
It is safe to call this function from any thread, although the data returned is not protected and could potentially be freed if you call PropertiesRef.SetString() or PropertiesRef.Clear() on these properties from another thread. If you need to avoid this, use PropertiesRef.Lock() and PropertiesLock.Unlock().
Since
This function is available since SDL 3.2.0.
See also
PropertiesRef.GetType
PropertiesRef.Has
PropertiesRef.SetString

◆ GetType()

PropertyType SDL::PropertiesRef::GetType ( StringParam  name) const
inline
Parameters
namethe name of the property to query.
Returns
the type of the property, or PROPERTY_TYPE_INVALID if it is not set.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.
See also
PropertiesRef.Has

◆ Has()

bool SDL::PropertiesRef::Has ( StringParam  name) const
inline
Parameters
namethe name of the property to query.
Returns
true if the property exists, or false if it doesn't.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.
See also
PropertiesRef.GetType

◆ reset()

static void SDL::PropertiesRef::reset ( SDL_PropertiesID  resource)
inlinestatic

All properties are deleted and their cleanup functions will be called, if any.

Parameters
resourcethe properties to destroy.
Thread safety:
This function should not be called while these properties are locked or other threads might be setting or getting values from these properties.
Since
This function is available since SDL 3.2.0.
See also
Properties.Create

◆ SetBoolean()

void SDL::PropertiesRef::SetBoolean ( StringParam  name,
bool  value 
)
inline
Parameters
namethe name of the property to modify.
valuethe new value of the property.
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
PropertiesRef.GetBoolean

◆ SetFloat()

void SDL::PropertiesRef::SetFloat ( StringParam  name,
float  value 
)
inline
Parameters
namethe name of the property to modify.
valuethe new value of the property.
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
PropertiesRef.GetFloat

◆ SetNumber()

void SDL::PropertiesRef::SetNumber ( StringParam  name,
Sint64  value 
)
inline
Parameters
namethe name of the property to modify.
valuethe new value of the property.
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
PropertiesRef.GetNumber

◆ SetPointer()

void SDL::PropertiesRef::SetPointer ( StringParam  name,
void *  value 
)
inline
Parameters
namethe name of the property to modify.
valuethe new value of the property, or nullptr to delete the property.
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
PropertiesRef.GetPointer
PropertiesRef.Has
PropertiesRef.SetBoolean
PropertiesRef.SetFloat
PropertiesRef.SetNumber
PropertiesRef.SetPointerWithCleanup
PropertiesRef.SetString

◆ SetPointerWithCleanup() [1/2]

void SDL::PropertiesRef::SetPointerWithCleanup ( StringParam  name,
void *  value,
CleanupPropertyCallback  cleanup,
void *  userdata 
)
inline

The cleanup function is also called if setting the property fails for any reason.

For simply setting basic data types, like numbers, bools, or strings, use PropertiesRef.SetNumber, PropertiesRef.SetBoolean, or PropertiesRef.SetString instead, as those functions will handle cleanup on your behalf. This function is only for more complex, custom data.

Parameters
namethe name of the property to modify.
valuethe new value of the property, or nullptr to delete the property.
cleanupthe function to call when this property is deleted, or nullptr if no cleanup is necessary.
userdataa pointer that is passed to the cleanup function.
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
PropertiesRef.GetPointer
PropertiesRef.SetPointer
CleanupPropertyCallback

◆ SetPointerWithCleanup() [2/2]

void SDL::PropertiesRef::SetPointerWithCleanup ( StringParam  name,
void *  value,
CleanupPropertyCB  cleanup 
)
inline

The cleanup function is also called if setting the property fails for any reason.

For simply setting basic data types, like numbers, bools, or strings, use SetNumber(), SetBoolean(), or SetString() instead, as those functions will handle cleanup on your behalf. This function is only for more complex, custom data.

Parameters
namethe name of the property to modify.
valuethe new value of the property, or NULL to delete the property.
cleanupthe function to call when this property is deleted.
Exceptions
Erroron failure.
Thread safety:
It is safe to call this function from any thread.
See also
result-callback
Category:
Result callback

◆ SetString()

void SDL::PropertiesRef::SetString ( StringParam  name,
StringParam  value 
)
inline

This function makes a copy of the string; the caller does not have to preserve the data after this call completes.

Parameters
namethe name of the property to modify.
valuethe new value of the property, or nullptr to delete the property.
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
PropertiesRef.GetString

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