SDL3pp
A slim C++ wrapper for SDL3
|
A property is a variable that can be created and retrieved by name at runtime. More...
Classes | |
struct | SDL::PropertiesParam |
Safely wrap Properties for non owning parameters. More... | |
class | SDL::Properties |
SDL properties ID. More... | |
struct | SDL::PropertiesRef |
Semi-safe reference for Properties. More... | |
Typedefs | |
using | SDL::PropertiesID = SDL_PropertiesID |
Alias to raw representation for Properties. | |
using | SDL::PropertyType = SDL_PropertyType |
SDL property type. More... | |
using | SDL::EnumeratePropertiesCallback = SDL_EnumeratePropertiesCallback |
A callback used to enumerate all the properties in a group of properties. More... | |
using | SDL::EnumeratePropertiesCB = std::function< void(PropertiesID props, const char *name)> |
A callback used to enumerate all the properties in a group of properties. More... | |
using | SDL::CleanupPropertyCallback = SDL_CleanupPropertyCallback |
A callback used to free resources when a property is deleted. More... | |
using | SDL::CleanupPropertyCB = std::function< void(void *)> |
A callback used to free resources when a property is deleted. More... | |
Functions | |
PropertiesRef | SDL::GetGlobalProperties () |
Get the global SDL properties. More... | |
Properties | SDL::CreateProperties () |
Create a group of properties. More... | |
void | SDL::CopyProperties (PropertiesParam src, PropertiesParam dst) |
Copy a group of properties. More... | |
void | SDL::LockProperties (PropertiesParam props) |
Lock a group of properties. More... | |
void | SDL::UnlockProperties (PropertiesParam props) |
Unlock a group of properties. More... | |
void | SDL::SetPointerPropertyWithCleanup (PropertiesParam props, 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. More... | |
void | SDL::SetPointerPropertyWithCleanup (PropertiesParam props, 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. More... | |
void | SDL::SetPointerProperty (PropertiesParam props, StringParam name, void *value) |
Set a pointer property in a group of properties. More... | |
void | SDL::SetStringProperty (PropertiesParam props, StringParam name, StringParam value) |
Set a string property in a group of properties. More... | |
void | SDL::SetNumberProperty (PropertiesParam props, StringParam name, Sint64 value) |
Set an integer property in a group of properties. More... | |
void | SDL::SetFloatProperty (PropertiesParam props, StringParam name, float value) |
Set a floating point property in a group of properties. More... | |
void | SDL::SetBooleanProperty (PropertiesParam props, StringParam name, bool value) |
Set a boolean property in a group of properties. More... | |
bool | SDL::HasProperty (PropertiesParam props, StringParam name) |
Return whether a property exists in a group of properties. More... | |
PropertyType | SDL::GetPropertyType (PropertiesParam props, StringParam name) |
Get the type of a property in a group of properties. More... | |
void * | SDL::GetPointerProperty (PropertiesParam props, StringParam name, void *default_value) |
Get a pointer property from a group of properties. More... | |
const char * | SDL::GetStringProperty (PropertiesParam props, StringParam name, StringParam default_value) |
Get a string property from a group of properties. More... | |
Sint64 | SDL::GetNumberProperty (PropertiesParam props, StringParam name, Sint64 default_value) |
Get a number property from a group of properties. More... | |
float | SDL::GetFloatProperty (PropertiesParam props, StringParam name, float default_value) |
Get a floating point property from a group of properties. More... | |
bool | SDL::GetBooleanProperty (PropertiesParam props, StringParam name, bool default_value) |
Get a boolean property from a group of properties. More... | |
void | SDL::ClearProperty (PropertiesParam props, StringParam name) |
Clear a property from a group of properties. More... | |
void | SDL::EnumerateProperties (PropertiesParam props, EnumeratePropertiesCallback callback, void *userdata) |
Enumerate the properties contained in a group of properties. More... | |
void | SDL::EnumerateProperties (PropertiesParam props, EnumeratePropertiesCB callback) |
Enumerate the properties contained in a group of properties. More... | |
Uint64 | SDL::CountProperties (PropertiesParam props) |
Returns the number of properties this has. More... | |
void | SDL::DestroyProperties (PropertiesID props) |
Destroy a group of properties. More... | |
static Properties | SDL::Properties::Create () |
Create a group of properties. More... | |
void | SDL::Properties::Copy (PropertiesParam dst) |
Copy a group of properties. More... | |
void | SDL::Properties::Lock () |
Lock a group of properties. More... | |
void | SDL::Properties::Unlock () |
Unlock a group of properties. More... | |
void | SDL::Properties::SetPointerPropertyWithCleanup (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. More... | |
void | SDL::Properties::SetPointerPropertyWithCleanup (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. More... | |
void | SDL::Properties::SetPointerProperty (StringParam name, void *value) |
Set a pointer property in a group of properties. More... | |
void | SDL::Properties::SetStringProperty (StringParam name, StringParam value) |
Set a string property in a group of properties. More... | |
void | SDL::Properties::SetNumberProperty (StringParam name, Sint64 value) |
Set an integer property in a group of properties. More... | |
void | SDL::Properties::SetFloatProperty (StringParam name, float value) |
Set a floating point property in a group of properties. More... | |
void | SDL::Properties::SetBooleanProperty (StringParam name, bool value) |
Set a boolean property in a group of properties. More... | |
bool | SDL::Properties::HasProperty (StringParam name) |
Return whether a property exists in a group of properties. More... | |
PropertyType | SDL::Properties::GetPropertyType (StringParam name) |
Get the type of a property in a group of properties. More... | |
void * | SDL::Properties::GetPointerProperty (StringParam name, void *default_value) |
Get a pointer property from a group of properties. More... | |
const char * | SDL::Properties::GetStringProperty (StringParam name, StringParam default_value) |
Get a string property from a group of properties. More... | |
Sint64 | SDL::Properties::GetNumberProperty (StringParam name, Sint64 default_value) |
Get a number property from a group of properties. More... | |
float | SDL::Properties::GetFloatProperty (StringParam name, float default_value) |
Get a floating point property from a group of properties. More... | |
bool | SDL::Properties::GetBooleanProperty (StringParam name, bool default_value) |
Get a boolean property from a group of properties. More... | |
void | SDL::Properties::ClearProperty (StringParam name) |
Clear a property from a group of properties. More... | |
void | SDL::Properties::Enumerate (EnumeratePropertiesCallback callback, void *userdata) |
Enumerate the properties contained in a group of properties. More... | |
void | SDL::Properties::Enumerate (EnumeratePropertiesCB callback) |
Enumerate the properties contained in a group of properties. More... | |
Uint64 | SDL::Properties::GetCount () |
Returns the number of properties this has. More... | |
void | SDL::Properties::Destroy () |
Destroy a group of properties. More... | |
Variables | |
constexpr PropertyType | SDL::PROPERTY_TYPE_INVALID |
INVALID. More... | |
constexpr PropertyType | SDL::PROPERTY_TYPE_POINTER |
POINTER. More... | |
constexpr PropertyType | SDL::PROPERTY_TYPE_STRING |
STRING. More... | |
constexpr PropertyType | SDL::PROPERTY_TYPE_NUMBER |
NUMBER. More... | |
constexpr PropertyType | SDL::PROPERTY_TYPE_FLOAT = SDL_PROPERTY_TYPE_FLOAT |
FLOAT. | |
constexpr PropertyType | SDL::PROPERTY_TYPE_BOOLEAN |
BOOLEAN. More... | |
All properties are part of a property group (Properties). A property group can be created with the Properties.Create function and destroyed with the Properties.Destroy function, but the Properties destructor probably will do what you want to, automatically.
Properties can be added to and retrieved from a property group through the following functions:
void*
pointer types.Properties can be removed from a group by using Properties.ClearProperty.
using SDL::CleanupPropertyCallback = typedef SDL_CleanupPropertyCallback |
This should release any resources associated with value
that are no longer needed.
This callback is set per-property. Different properties in the same group can have different cleanup callbacks.
This callback will be called during Properties.SetPointerPropertyWithCleanup if the function fails for any reason.
userdata | an app-defined pointer passed to the callback. |
value | the pointer assigned to the property to clean up. |
using SDL::CleanupPropertyCB = typedef std::function<void(void*)> |
This should release any resources associated with value
that are no longer needed.
This callback is set per-property. Different properties in the same group can have different cleanup callbacks.
This callback will be called during Properties.SetPointerPropertyWithCleanup if the function fails for any reason.
value | the pointer assigned to the property to clean up. |
using SDL::EnumeratePropertiesCallback = typedef SDL_EnumeratePropertiesCallback |
This callback is called from Properties.Enumerate(), and is called once per property in the set.
userdata | an app-defined pointer passed to the callback. |
props | the Properties that is being enumerated. |
name | the next property name in the enumeration. |
props
during this callback.using SDL::EnumeratePropertiesCB = typedef std::function<void(PropertiesID props, const char* name)> |
This callback is called from Properties.Enumerate(), and is called once per property in the set.
props | the Properties that is being enumerated. |
name | the next property name in the enumeration. |
props
during this callback.using SDL::PropertyType = typedef SDL_PropertyType |
|
inline |
|
inline |
|
inline |
Copy all the properties from one group of properties to another, with the exception of properties requiring cleanup (set using Properties.SetPointerPropertyWithCleanup()), which will not be copied. Any property that already exists on dst
will be overwritten.
dst | the destination properties. |
Error | on failure. |
|
inline |
Copy all the properties from one group of properties to another, with the exception of properties requiring cleanup (set using Properties.SetPointerPropertyWithCleanup()), which will not be copied. Any property that already exists on dst
will be overwritten.
src | the properties to copy. |
dst | the destination properties. |
Error | on failure. |
|
inline |
|
inlinestatic |
All properties are automatically destroyed when Quit() is called.
Error | on failure. |
|
inline |
All properties are automatically destroyed when Quit() is called.
Error | on failure. |
|
inline |
All properties are deleted and their cleanup functions will be called, if any.
|
inline |
All properties are deleted and their cleanup functions will be called, if any.
props | the properties to destroy. |
|
inline |
The callback function is called for each property in the group of properties. The properties are locked during enumeration.
callback | the function to call for each property. |
userdata | a pointer that is passed to callback . |
Error | on failure. |
|
inline |
The callback function is called for each property in the group of properties. The properties are locked during enumeration.
callback | the function to call for each property. |
Error | on failure. |
|
inline |
The callback function is called for each property in the group of properties. The properties are locked during enumeration.
props | the properties to query. |
callback | the function to call for each property. |
userdata | a pointer that is passed to callback . |
Error | on failure. |
|
inline |
The callback function is called for each property in the group of properties. The properties are locked during enumeration.
props | the properties to query. |
callback | the function to call for each property. |
Error | on failure. |
|
inline |
You can use Properties.GetPropertyType() to query whether the property exists and is a boolean property.
props | the properties to query. |
name | the name of the property to query. |
default_value | the default value of the property. |
default_value
if it is not set or not a boolean property.
|
inline |
You can use Properties.GetPropertyType() to query whether the property exists and is a boolean property.
name | the name of the property to query. |
default_value | the default value of the property. |
default_value
if it is not set or not a boolean property.
|
inline |
This uses EnumerateProperties() internally, so might not be so fast
|
inline |
You can use Properties.GetPropertyType() to query whether the property exists and is a floating point property.
props | the properties to query. |
name | the name of the property to query. |
default_value | the default value of the property. |
default_value
if it is not set or not a float property.
|
inline |
You can use Properties.GetPropertyType() to query whether the property exists and is a floating point property.
name | the name of the property to query. |
default_value | the default value of the property. |
default_value
if it is not set or not a float property.
|
inline |
|
inline |
You can use Properties.GetPropertyType() to query whether the property exists and is a number property.
props | the properties to query. |
name | the name of the property to query. |
default_value | the default value of the property. |
default_value
if it is not set or not a number property.
|
inline |
You can use Properties.GetPropertyType() to query whether the property exists and is a number property.
name | the name of the property to query. |
default_value | the default value of the property. |
default_value
if it is not set or not a number property.
|
inline |
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.
props | the properties to query. |
name | the name of the property to query. |
default_value | the default value of the property. |
default_value
if it is not set or not a pointer property.
|
inline |
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.
name | the name of the property to query. |
default_value | the default value of the property. |
default_value
if it is not set or not a pointer property.
|
inline |
props | the properties to query. |
name | the name of the property to query. |
|
inline |
name | the name of the property to query. |
|
inline |
props | the properties to query. |
name | the name of the property to query. |
default_value | the default value of the property. |
default_value
if it is not set or not a string property.
|
inline |
name | the name of the property to query. |
default_value | the default value of the property. |
default_value
if it is not set or not a string property.
|
inline |
props | the properties to query. |
name | the name of the property to query. |
|
inline |
name | the name of the property to query. |
|
inline |
Obtain a multi-threaded lock for these properties. Other threads will wait while trying to lock these properties until they are unlocked. Properties must be unlocked before they are destroyed.
The lock is automatically taken when setting individual properties, this function is only needed when you want to set several properties atomically or want to guarantee that properties being queried aren't freed in another thread.
Error | on failure. |
|
inline |
Obtain a multi-threaded lock for these properties. Other threads will wait while trying to lock these properties until they are unlocked. Properties must be unlocked before they are destroyed.
The lock is automatically taken when setting individual properties, this function is only needed when you want to set several properties atomically or want to guarantee that properties being queried aren't freed in another thread.
props | the properties to lock. |
Error | on failure. |
|
inline |
props | the properties to modify. |
name | the name of the property to modify. |
value | the new value of the property. |
Error | on failure. |
|
inline |
name | the name of the property to modify. |
value | the new value of the property. |
Error | on failure. |
|
inline |
props | the properties to modify. |
name | the name of the property to modify. |
value | the new value of the property. |
Error | on failure. |
|
inline |
name | the name of the property to modify. |
value | the new value of the property. |
Error | on failure. |
|
inline |
props | the properties to modify. |
name | the name of the property to modify. |
value | the new value of the property. |
Error | on failure. |
|
inline |
name | the name of the property to modify. |
value | the new value of the property. |
Error | on failure. |
|
inline |
|
inline |
|
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 Properties.SetNumberProperty, Properties.SetBooleanProperty, or Properties.SetStringProperty instead, as those functions will handle cleanup on your behalf. This function is only for more complex, custom data.
props | the properties to modify. |
name | the name of the property to modify. |
value | the new value of the property, or nullptr to delete the property. |
cleanup | the function to call when this property is deleted, or nullptr if no cleanup is necessary. |
userdata | a pointer that is passed to the cleanup function. |
Error | on failure. |
|
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 Properties.SetNumberProperty, Properties.SetBooleanProperty, or Properties.SetStringProperty instead, as those functions will handle cleanup on your behalf. This function is only for more complex, custom data.
props | the properties to modify. |
name | the name of the property to modify. |
value | the new value of the property, or nullptr to delete the property. |
cleanup | the function to call when this property is deleted, or nullptr if no cleanup is necessary. |
Error | on failure. |
|
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 Properties.SetNumberProperty, Properties.SetBooleanProperty, or Properties.SetStringProperty instead, as those functions will handle cleanup on your behalf. This function is only for more complex, custom data.
name | the name of the property to modify. |
value | the new value of the property, or nullptr to delete the property. |
cleanup | the function to call when this property is deleted, or nullptr if no cleanup is necessary. |
userdata | a pointer that is passed to the cleanup function. |
Error | on failure. |
|
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 Properties.SetNumberProperty, Properties.SetBooleanProperty, or Properties.SetStringProperty instead, as those functions will handle cleanup on your behalf. This function is only for more complex, custom data.
name | the name of the property to modify. |
value | the new value of the property, or nullptr to delete the property. |
cleanup | the function to call when this property is deleted, or nullptr if no cleanup is necessary. |
Error | on failure. |
|
inline |
This function makes a copy of the string; the caller does not have to preserve the data after this call completes.
props | the properties to modify. |
name | the name of the property to modify. |
value | the new value of the property, or nullptr to delete the property. |
Error | on failure. |
|
inline |
This function makes a copy of the string; the caller does not have to preserve the data after this call completes.
name | the name of the property to modify. |
value | the new value of the property, or nullptr to delete the property. |
Error | on failure. |
|
inline |
|
inline |
props | the properties to unlock. |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |