|
SDL3pp
A slim C++ wrapper for SDL3
|
A property is a variable that can be created and retrieved by name at runtime. More...
Classes | |
| class | SDL::Properties |
| An ID that represents a properties set. More... | |
| struct | SDL::PropertiesRef |
| Reference for Properties. More... | |
| class | SDL::PropertiesLock |
| Lock a group of properties. More... | |
Typedefs | |
| using | SDL::PropertiesID = SDL_PropertiesID |
| Alias to raw representation for Properties. | |
| using | SDL::PropertyType = SDL_PropertyType |
| SDL property type. | |
| using | SDL::EnumeratePropertiesCallback |
| A callback used to enumerate all the properties in a group of properties. | |
| using | SDL::EnumeratePropertiesCB |
| A callback used to enumerate all the properties in a group of properties. | |
| using | SDL::CleanupPropertyCallback = void(SDLCALL*)(void* userdata, void* value) |
| A callback used to free resources when a property is deleted. | |
| using | SDL::CleanupPropertyCB = std::function<void(void* value)> |
| A callback used to free resources when a property is deleted. | |
Functions | |
| PropertiesRef | SDL::GetGlobalProperties () |
| Get the global SDL properties. | |
| Properties | SDL::CreateProperties () |
| Create a group of properties. | |
| void | SDL::CopyProperties (PropertiesRef src, PropertiesRef dst) |
| Copy a group of properties. | |
| void | SDL::LockProperties (PropertiesRef props) |
| Lock a group of properties. | |
| void | SDL::UnlockProperties (PropertiesRef props) |
| Unlock a group of properties. | |
| void | SDL::SetPointerPropertyWithCleanup (PropertiesRef 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. | |
| void | SDL::SetPointerPropertyWithCleanup (PropertiesRef 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. | |
| void | SDL::SetPointerProperty (PropertiesRef props, StringParam name, void *value) |
| Set a pointer property in a group of properties. | |
| void | SDL::SetStringProperty (PropertiesRef props, StringParam name, StringParam value) |
| Set a string property in a group of properties. | |
| void | SDL::SetNumberProperty (PropertiesRef props, StringParam name, Sint64 value) |
| Set an integer property in a group of properties. | |
| void | SDL::SetFloatProperty (PropertiesRef props, StringParam name, float value) |
| Set a floating point property in a group of properties. | |
| void | SDL::SetBooleanProperty (PropertiesRef props, StringParam name, bool value) |
| Set a boolean property in a group of properties. | |
| bool | SDL::HasProperty (PropertiesRef props, StringParam name) |
| Return whether a property exists in a group of properties. | |
| PropertyType | SDL::GetPropertyType (PropertiesRef props, StringParam name) |
| Get the type of a property in a group of properties. | |
| void * | SDL::GetPointerProperty (PropertiesRef props, StringParam name, void *default_value) |
| Get a pointer property from a group of properties. | |
| const char * | SDL::GetStringProperty (PropertiesRef props, StringParam name, StringParam default_value) |
| Get a string property from a group of properties. | |
| Sint64 | SDL::GetNumberProperty (PropertiesRef props, StringParam name, Sint64 default_value) |
| Get a number property from a group of properties. | |
| float | SDL::GetFloatProperty (PropertiesRef props, StringParam name, float default_value) |
| Get a floating point property from a group of properties. | |
| bool | SDL::GetBooleanProperty (PropertiesRef props, StringParam name, bool default_value) |
| Get a boolean property from a group of properties. | |
| void | SDL::ClearProperty (PropertiesRef props, StringParam name) |
| Clear a property from a group of properties. | |
| void | SDL::EnumerateProperties (PropertiesRef props, EnumeratePropertiesCallback callback, void *userdata) |
| Enumerate the properties contained in a group of properties. | |
| void | SDL::EnumerateProperties (PropertiesRef props, EnumeratePropertiesCB callback) |
| Enumerate the properties contained in a group of properties. | |
| Uint64 | SDL::CountProperties (PropertiesRef props) |
| Returns the number of properties this has. | |
| void | SDL::DestroyProperties (PropertiesID props) |
| Destroy a group of properties. | |
| static Properties | SDL::Properties::Create () |
| Create a group of properties. | |
| void | SDL::Properties::Copy (PropertiesRef dst) |
| Copy a group of properties. | |
| PropertiesLock | SDL::Properties::Lock () |
| Lock a group of properties. | |
| SDL::PropertiesLock::PropertiesLock (PropertiesRef resource) | |
| Lock a group of properties. | |
| void | SDL::Properties::Unlock (PropertiesLock &&lock) |
| Unlock a group of properties. | |
| void | SDL::PropertiesLock::reset () |
| Unlock a group of properties. | |
| 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. | |
| 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. | |
| void | SDL::Properties::SetPointerProperty (StringParam name, void *value) |
| Set a pointer property in a group of properties. | |
| void | SDL::Properties::SetStringProperty (StringParam name, StringParam value) |
| Set a string property in a group of properties. | |
| void | SDL::Properties::SetNumberProperty (StringParam name, Sint64 value) |
| Set an integer property in a group of properties. | |
| void | SDL::Properties::SetFloatProperty (StringParam name, float value) |
| Set a floating point property in a group of properties. | |
| void | SDL::Properties::SetBooleanProperty (StringParam name, bool value) |
| Set a boolean property in a group of properties. | |
| bool | SDL::Properties::HasProperty (StringParam name) |
| Return whether a property exists in a group of properties. | |
| PropertyType | SDL::Properties::GetPropertyType (StringParam name) |
| Get the type of a property in a group of properties. | |
| void * | SDL::Properties::GetPointerProperty (StringParam name, void *default_value) |
| Get a pointer property from a group of properties. | |
| const char * | SDL::Properties::GetStringProperty (StringParam name, StringParam default_value) |
| Get a string property from a group of properties. | |
| Sint64 | SDL::Properties::GetNumberProperty (StringParam name, Sint64 default_value) |
| Get a number property from a group of properties. | |
| float | SDL::Properties::GetFloatProperty (StringParam name, float default_value) |
| Get a floating point property from a group of properties. | |
| bool | SDL::Properties::GetBooleanProperty (StringParam name, bool default_value) |
| Get a boolean property from a group of properties. | |
| void | SDL::Properties::ClearProperty (StringParam name) |
| Clear a property from a group of properties. | |
| void | SDL::Properties::Enumerate (EnumeratePropertiesCallback callback, void *userdata) |
| Enumerate the properties contained in a group of properties. | |
| void | SDL::Properties::Enumerate (EnumeratePropertiesCB callback) |
| Enumerate the properties contained in a group of properties. | |
| Uint64 | SDL::Properties::GetCount () |
| Returns the number of properties this has. | |
| void | SDL::Properties::Destroy () |
| Destroy a group of properties. | |
Variables | |
| constexpr PropertyType | SDL::PROPERTY_TYPE_INVALID |
| INVALID. | |
| constexpr PropertyType | SDL::PROPERTY_TYPE_POINTER |
| POINTER. | |
| constexpr PropertyType | SDL::PROPERTY_TYPE_STRING |
| STRING. | |
| constexpr PropertyType | SDL::PROPERTY_TYPE_NUMBER |
| NUMBER. | |
| constexpr PropertyType | SDL::PROPERTY_TYPE_FLOAT = SDL_PROPERTY_TYPE_FLOAT |
| FLOAT. | |
| constexpr PropertyType | SDL::PROPERTY_TYPE_BOOLEAN |
| BOOLEAN. | |
| constexpr const char * | SDL::PROP_NAME_STRING = SDL_PROP_NAME_STRING |
| A generic property for naming things. | |
A property is a variable that can be created and retrieved by name at runtime.
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:
Properties can be removed from a group by using Properties.ClearProperty.
| using SDL::CleanupPropertyCallback = void(SDLCALL*)(void* userdata, void* value) |
A callback used to free resources when a property is deleted.
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 = std::function<void(void* value)> |
A callback used to free resources when a property is deleted.
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. |
A callback used to enumerate all the properties in a group of properties.
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. |
A callback used to enumerate all the properties in a group of properties.
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. |
| using SDL::PropertyType = SDL_PropertyType |
|
inline |
|
inline |
|
inline |
Copy a group of properties.
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 a group of properties.
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 |
Returns the number of properties this has.
This uses EnumerateProperties() internally, so might not be so fast
| props |
|
inlinestatic |
Create a group of properties.
All properties are automatically destroyed when Quit() is called.
| Error | on failure. |
|
inline |
Create a group of properties.
All properties are automatically destroyed when Quit() is called.
| Error | on failure. |
|
inline |
Destroy a group of properties.
All properties are deleted and their cleanup functions will be called, if any.
|
inline |
Destroy a group of properties.
All properties are deleted and their cleanup functions will be called, if any.
| props | the properties to destroy. |
|
inline |
Enumerate the properties contained in a group of properties.
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 |
Enumerate the properties contained in a group of properties.
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 |
Enumerate the properties contained in a group of properties.
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 |
Enumerate the properties contained in a group of properties.
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 |
Get a boolean property from a group of properties.
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. |
|
inline |
Get a boolean property from a group of properties.
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. |
|
inline |
Returns the number of properties this has.
This uses EnumerateProperties() internally, so might not be so fast
|
inline |
Get a floating point property from a group of properties.
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. |
|
inline |
Get a floating point property from a group of properties.
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. |
|
inline |
|
inline |
Get a number property from a group of properties.
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. |
|
inline |
Get a number property from a group of properties.
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. |
|
inline |
Get a pointer property from a group of properties.
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. |
|
inline |
Get a pointer property from a group of properties.
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. |
|
inline |
Get the type of a property in a group of properties.
| props | the properties to query. |
| name | the name of the property to query. |
|
inline |
Get the type of a property in a group of properties.
| name | the name of the property to query. |
|
inline |
Get a string property from a group of properties.
| props | the properties to query. |
| name | the name of the property to query. |
| default_value | the default value of the property. |
|
inline |
Get a string property from a group of properties.
| name | the name of the property to query. |
| default_value | the default value of the property. |
|
inline |
Return whether a property exists in a group of properties.
| props | the properties to query. |
| name | the name of the property to query. |
|
inline |
Return whether a property exists in a group of properties.
| name | the name of the property to query. |
|
inline |
Lock a group of properties.
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 |
Lock a group of properties.
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 |
Lock a group of properties.
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.
| resource | the properties to lock. |
|
inline |
Unlock a group of properties.
|
inline |
Set a boolean property in a group of properties.
| name | the name of the property to modify. |
| value | the new value of the property. |
| Error | on failure. |
|
inline |
Set a boolean property in a group of properties.
| props | the properties to modify. |
| name | the name of the property to modify. |
| value | the new value of the property. |
| Error | on failure. |
|
inline |
Set a floating point property in a group of properties.
| name | the name of the property to modify. |
| value | the new value of the property. |
| Error | on failure. |
|
inline |
Set a floating point property in a group of properties.
| props | the properties to modify. |
| name | the name of the property to modify. |
| value | the new value of the property. |
| Error | on failure. |
|
inline |
Set an integer property in a group of properties.
| name | the name of the property to modify. |
| value | the new value of the property. |
| Error | on failure. |
|
inline |
Set an integer property in a group of properties.
| props | the properties to modify. |
| name | the name of the property to modify. |
| value | the new value of the property. |
| Error | on failure. |
|
inline |
Set a pointer property in a group of properties.
| 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 |
Set a pointer property in a group of properties.
| 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 |
Set a pointer property in a group of properties with a cleanup function that is called when the property is deleted.
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 |
Set a pointer property in a group of properties with a cleanup function that is called when the property is deleted.
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 |
Set a pointer property in a group of properties with a cleanup function that is called when the property is deleted.
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 |
Set a pointer property in a group of properties with a cleanup function that is called when the property is deleted.
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 |
Set a string property in a group of properties.
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 |
Set a string property in a group of properties.
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 |
Unlock a group of properties.
|
inline |
Unlock a group of properties.
| props | the properties to unlock. |
|
constexpr |
A generic property for naming things.
This property is intended to be added to any Properties that needs a generic name associated with the property set. It is not guaranteed that any property set will include this key, but it is convenient to have a standard key that any piece of code could reasonably agree to use.
For example, the properties associated with an Texture might have a name string of "player sprites", or an AudioStream might have "background music", etc. This might also be useful for an IOStream to list the path to its asset.
There is no format for the value set with this key; it is expected to be human-readable and informational in nature, possibly for logging or debugging purposes.
SDL does not currently set this property on any objects it creates, but this may change in later versions; it is currently expected that apps and external libraries will take advantage of it, when appropriate.
|
constexpr |
BOOLEAN.
|
constexpr |
INVALID.
|
constexpr |
NUMBER.
|
constexpr |
POINTER.
|
constexpr |
STRING.