SDL3pp
A slim C++ wrapper for SDL3
|
Wrap properties id. More...
Public Member Functions | |
void | CopyPropertiesTo (PropertiesBase &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 the underlying resource. | |
constexpr | Resource (std::nullptr_t) |
Equivalent to default ctor. | |
constexpr | Resource (std::nullopt_t) |
Equivalent to default ctor. | |
Resource (const Resource &other)=delete | |
Resource (Resource &&other)=delete | |
![]() | |
constexpr | Resource (SDL_PropertiesID resource={}) |
Constructs the underlying resource. | |
constexpr | Resource (std::nullptr_t) |
Equivalent to default ctor. | |
constexpr | Resource (std::nullopt_t) |
Equivalent to default ctor. | |
Resource (const Resource &other)=delete | |
Resource (Resource &&other)=delete | |
Resource & | operator= (const Resource &other)=delete |
Resource & | operator= (Resource &&other)=delete |
constexpr | operator bool () const |
True if contains a valid resource. | |
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 SDL_PropertiesID | release (SDL_PropertiesID newResource={}) |
Return contained resource and empties or replace value. | |
constexpr const SDL_PropertiesID | operator-> () const |
Access to fields. | |
constexpr SDL_PropertiesID | operator-> () |
Access to fields. | |
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 constructor and destroyed with this goes out of scope.
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 SDL_ClearProperty.
To create a new properties group use CreateProperties() or Properties.Properties().
|
inline |
|
inline |
Copy all the properties from one group of properties to another, with the exception of properties requiring cleanup (set using PropertiesBase.SetPointerWithCleanup()), which will not be copied. Any property that already exists on dst
will be overwritten.
dst | the destination properties. |
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. |
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 |
outputIter | an output iterator to be assigned to each property name. |
Error | on failure. |
|
inline |
You can use PropertiesBase.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.
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 Enumerate() internally, so might not be so fast
|
inline |
You can use PropertiesBase.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.
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 PropertiesBase.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.
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 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.
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 |
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.
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. |
|
inline |
name | the name of the property to query. |
|
inline |
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 |
name | the name of the property to modify. |
value | the new value of the property. |
Error | on failure. |
|
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 PropertiesBase.SetNumber, PropertiesBase.SetBoolean, or PropertiesBase.SetString 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 SetNumber(), SetBoolean(), or SetString() 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 NULL to delete the property. |
cleanup | the function to call when this property is deleted. |
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. |