Added property types: pointer, string, number, float
This commit is contained in:
@@ -39,6 +39,18 @@ extern "C" {
|
||||
*/
|
||||
typedef Uint32 SDL_PropertiesID;
|
||||
|
||||
/**
|
||||
* SDL property type
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
SDL_PROPERTY_TYPE_INVALID,
|
||||
SDL_PROPERTY_TYPE_POINTER,
|
||||
SDL_PROPERTY_TYPE_STRING,
|
||||
SDL_PROPERTY_TYPE_NUMBER,
|
||||
SDL_PROPERTY_TYPE_FLOAT,
|
||||
} SDL_PropertyType;
|
||||
|
||||
/**
|
||||
* Get the global SDL properties
|
||||
*
|
||||
@@ -105,24 +117,6 @@ extern DECLSPEC int SDLCALL SDL_LockProperties(SDL_PropertiesID props);
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_UnlockProperties(SDL_PropertiesID props);
|
||||
|
||||
/**
|
||||
* Set a property on a set of properties
|
||||
*
|
||||
* \param props the properties to modify
|
||||
* \param name the name of the property to modify
|
||||
* \param value the new value of the property, or NULL to delete the property
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetProperty
|
||||
* \sa SDL_SetPropertyWithCleanup
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SetProperty(SDL_PropertiesID props, const char *name, void *value);
|
||||
|
||||
/**
|
||||
* Set a property on a set of properties with a cleanup function that is
|
||||
* called when the property is deleted
|
||||
@@ -145,6 +139,88 @@ extern DECLSPEC int SDLCALL SDL_SetProperty(SDL_PropertiesID props, const char *
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SetPropertyWithCleanup(SDL_PropertiesID props, const char *name, void *value, void (SDLCALL *cleanup)(void *userdata, void *value), void *userdata);
|
||||
|
||||
/**
|
||||
* Set a property on a set of properties
|
||||
*
|
||||
* \param props the properties to modify
|
||||
* \param name the name of the property to modify
|
||||
* \param value the new value of the property, or NULL to delete the property
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetProperty
|
||||
* \sa SDL_SetPropertyWithCleanup
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SetProperty(SDL_PropertiesID props, const char *name, void *value);
|
||||
|
||||
/**
|
||||
* Set a string property on a set of properties
|
||||
*
|
||||
* \param props the properties to modify
|
||||
* \param name the name of the property to modify
|
||||
* \param value the new value of the property, or NULL to delete the property
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetStringProperty
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SetStringProperty(SDL_PropertiesID props, const char *name, const char *value);
|
||||
|
||||
/**
|
||||
* Set an integer property on a set of properties
|
||||
*
|
||||
* \param props the properties to modify
|
||||
* \param name the name of the property to modify
|
||||
* \param value the new value of the property
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetNumberProperty
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SetNumberProperty(SDL_PropertiesID props, const char *name, Sint64 value);
|
||||
|
||||
/**
|
||||
* Set a floating point property on a set of properties
|
||||
*
|
||||
* \param props the properties to modify
|
||||
* \param name the name of the property to modify
|
||||
* \param value the new value of the property
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetFloatProperty
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SetFloatProperty(SDL_PropertiesID props, const char *name, float value);
|
||||
|
||||
/**
|
||||
* Get the type of a property on a set of properties
|
||||
*
|
||||
* \param props the properties to query
|
||||
* \param name the name of the property to query
|
||||
* \returns the type of the property, or SDL_PROPERTY_TYPE_INVALID if it is not set.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern DECLSPEC SDL_PropertyType SDLCALL SDL_GetPropertyType(SDL_PropertiesID props, const char *name);
|
||||
|
||||
/**
|
||||
* Get a property on a set of properties
|
||||
*
|
||||
@@ -155,7 +231,8 @@ extern DECLSPEC int SDLCALL SDL_SetPropertyWithCleanup(SDL_PropertiesID props, c
|
||||
*
|
||||
* \param props the properties to query
|
||||
* \param name the name of the property to query
|
||||
* \returns the value of the property, or NULL if it is not set.
|
||||
* \param default_value the default value of the property
|
||||
* \returns the value of the property, or `default_value` if it is not set or not a pointer property.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread, although
|
||||
* the data returned is not protected and could potentially be
|
||||
@@ -165,9 +242,65 @@ extern DECLSPEC int SDLCALL SDL_SetPropertyWithCleanup(SDL_PropertiesID props, c
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetPropertyType
|
||||
* \sa SDL_SetProperty
|
||||
*/
|
||||
extern DECLSPEC void *SDLCALL SDL_GetProperty(SDL_PropertiesID props, const char *name);
|
||||
extern DECLSPEC void *SDLCALL SDL_GetProperty(SDL_PropertiesID props, const char *name, void *default_value);
|
||||
|
||||
/**
|
||||
* Get a string property on a set of properties
|
||||
*
|
||||
* \param props the properties to query
|
||||
* \param name the name of the property to query
|
||||
* \param default_value the default value of the property
|
||||
* \returns the value of the property, or `default_value` if it is not set or not a string property.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetPropertyType
|
||||
* \sa SDL_SetStringProperty
|
||||
*/
|
||||
extern DECLSPEC const char *SDLCALL SDL_GetStringProperty(SDL_PropertiesID props, const char *name, const char *default_value);
|
||||
|
||||
/**
|
||||
* Get a number property on a set of properties
|
||||
*
|
||||
* You can use SDL_GetPropertyType() to query whether the property exists and is a number property.
|
||||
*
|
||||
* \param props the properties to query
|
||||
* \param name the name of the property to query
|
||||
* \param default_value the default value of the property
|
||||
* \returns the value of the property, or `default_value` if it is not set or not a number property.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetPropertyType
|
||||
* \sa SDL_SetNumberProperty
|
||||
*/
|
||||
extern DECLSPEC Sint64 SDLCALL SDL_GetNumberProperty(SDL_PropertiesID props, const char *name, Sint64 default_value);
|
||||
|
||||
/**
|
||||
* Get a floating point property on a set of properties
|
||||
*
|
||||
* You can use SDL_GetPropertyType() to query whether the property exists and is a floating point property.
|
||||
*
|
||||
* \param props the properties to query
|
||||
* \param name the name of the property to query
|
||||
* \param default_value the default value of the property
|
||||
* \returns the value of the property, or `default_value` if it is not set or not a float property.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetPropertyType
|
||||
* \sa SDL_SetFloatProperty
|
||||
*/
|
||||
extern DECLSPEC float SDLCALL SDL_GetFloatProperty(SDL_PropertiesID props, const char *name, float default_value);
|
||||
|
||||
/**
|
||||
* Clear a property on a set of properties
|
||||
@@ -185,6 +318,24 @@ extern DECLSPEC void *SDLCALL SDL_GetProperty(SDL_PropertiesID props, const char
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_ClearProperty(SDL_PropertiesID props, const char *name);
|
||||
|
||||
typedef void (SDLCALL *SDL_EnumeratePropertiesCallback)(void *userdata, SDL_PropertiesID props, const char *name);
|
||||
/**
|
||||
* Enumerate the properties on a set of properties
|
||||
*
|
||||
* The callback function is called for each property on the set of properties. The properties are locked during enumeration.
|
||||
*
|
||||
* \param props the properties to query
|
||||
* \param callback the function to call for each property
|
||||
* \param userdata a pointer that is passed to `callback`
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_EnumerateProperties(SDL_PropertiesID props, SDL_EnumeratePropertiesCallback callback, void *userdata);
|
||||
|
||||
/**
|
||||
* Destroy a set of properties
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user