1#ifndef SDL3PP_PROPERTIES_H_ 
    2#define SDL3PP_PROPERTIES_H_ 
    4#include <SDL3/SDL_properties.h> 
    5#include "SDL3pp_callbackWrapper.h" 
    6#include "SDL3pp_error.h" 
    7#include "SDL3pp_strings.h" 
   68  constexpr explicit operator bool()
 const { 
return !!
value; }
 
   85  SDL_PROPERTY_TYPE_INVALID; 
 
   88  SDL_PROPERTY_TYPE_POINTER; 
 
   91  SDL_PROPERTY_TYPE_STRING; 
 
   94  SDL_PROPERTY_TYPE_NUMBER; 
 
   99  SDL_PROPERTY_TYPE_BOOLEAN; 
 
  137  std::function<void(
PropertiesID props, 
const char* name)>;
 
  214    : m_resource(resource)
 
  253    std::swap(m_resource, other.m_resource);
 
  272  constexpr bool operator==(std::nullptr_t _)
 const { 
return !m_resource; }
 
  275  constexpr explicit operator bool()
 const { 
return !!m_resource; }
 
  734  return {
CheckError(SDL_GetGlobalProperties())};
 
  825  SDL_UnlockProperties(props);
 
  866    SDL_SetPointerPropertyWithCleanup(props, name, value, cleanup, userdata));
 
  903  SDL_SetPointerPropertyWithCleanup(props,
 
  907                                    Wrapper::Wrap(std::move(cleanup)));
 
  917    m_resource, std::move(name), value, cleanup, userdata);
 
  925    m_resource, std::move(name), value, cleanup);
 
  953  CheckError(SDL_SetPointerProperty(props, name, value));
 
  983  CheckError(SDL_SetStringProperty(props, name, value));
 
 1009  CheckError(SDL_SetNumberProperty(props, name, value));
 
 1035  CheckError(SDL_SetFloatProperty(props, name, value));
 
 1061  CheckError(SDL_SetBooleanProperty(props, name, value));
 
 1084  return SDL_HasProperty(props, name);
 
 1108  return SDL_GetPropertyType(props, name);
 
 1149                                void* default_value)
 
 1151  return SDL_GetPointerProperty(props, name, default_value);
 
 1155                                            void* default_value)
 
 1186  return SDL_GetStringProperty(props, name, default_value);
 
 1193    m_resource, std::move(name), std::move(default_value));
 
 1220  return SDL_GetNumberProperty(props, name, default_value);
 
 1251                              float default_value)
 
 1253  return SDL_GetFloatProperty(props, name, default_value);
 
 1285  return SDL_GetBooleanProperty(props, name, default_value);
 
 1333  CheckError(SDL_EnumerateProperties(props, callback, userdata));
 
 1355    [](
void* userdata, 
PropertiesID props, 
const char* name) {
 
 1411  SDL_DestroyProperties(props);
 
SDL properties ID.
Definition: SDL3pp_properties.h:199
constexpr Properties(const Properties &other)=delete
Copy constructor.
constexpr PropertiesID get() const
Retrieves underlying PropertiesID.
Definition: SDL3pp_properties.h:258
Properties & operator=(Properties other)
Assignment operator.
Definition: SDL3pp_properties.h:251
constexpr auto operator<=>(const Properties &other) const =default
Comparison.
constexpr Properties(const PropertiesID resource)
Constructs from PropertiesParam.
Definition: SDL3pp_properties.h:213
constexpr Properties(Properties &&other)
Move constructor.
Definition: SDL3pp_properties.h:222
~Properties()
Destructor.
Definition: SDL3pp_properties.h:248
constexpr bool operator==(std::nullptr_t _) const
Comparison.
Definition: SDL3pp_properties.h:272
constexpr PropertiesID release()
Retrieves underlying PropertiesID and clear this.
Definition: SDL3pp_properties.h:261
constexpr Properties()=default
Default ctor.
Helpers to use C++ strings parameters.
Definition: SDL3pp_strings.h:43
constexpr void CheckError(bool result)
Check and throw if returned value from SDL is an error.
Definition: SDL3pp_error.h:198
constexpr PropertyType PROPERTY_TYPE_BOOLEAN
BOOLEAN.
Definition: SDL3pp_properties.h:98
void UnlockProperties(PropertiesParam props)
Unlock a group of properties.
Definition: SDL3pp_properties.h:823
static Properties Create()
Create a group of properties.
Definition: SDL3pp_properties.h:756
Sint64 GetNumberProperty(StringParam name, Sint64 default_value)
Get a number property from a group of properties.
Definition: SDL3pp_properties.h:1223
Sint64 GetNumberProperty(PropertiesParam props, StringParam name, Sint64 default_value)
Get a number property from a group of properties.
Definition: SDL3pp_properties.h:1216
void SetBooleanProperty(PropertiesParam props, StringParam name, bool value)
Set a boolean property in a group of properties.
Definition: SDL3pp_properties.h:1057
void LockProperties(PropertiesParam props)
Lock a group of properties.
Definition: SDL3pp_properties.h:805
SDL_PropertyType PropertyType
SDL property type.
Definition: SDL3pp_properties.h:82
void SetFloatProperty(StringParam name, float value)
Set a floating point property in a group of properties.
Definition: SDL3pp_properties.h:1038
void Lock()
Lock a group of properties.
Definition: SDL3pp_properties.h:810
void 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 prope...
Definition: SDL3pp_properties.h:910
float GetFloatProperty(StringParam name, float default_value)
Get a floating point property from a group of properties.
Definition: SDL3pp_properties.h:1256
void SetNumberProperty(StringParam name, Sint64 value)
Set an integer property in a group of properties.
Definition: SDL3pp_properties.h:1012
void Unlock()
Unlock a group of properties.
Definition: SDL3pp_properties.h:828
Uint64 CountProperties(PropertiesParam props)
Returns the number of properties this has.
Definition: SDL3pp_properties.h:1381
const char * GetStringProperty(StringParam name, StringParam default_value)
Get a string property from a group of properties.
Definition: SDL3pp_properties.h:1189
bool HasProperty(PropertiesParam props, StringParam name)
Return whether a property exists in a group of properties.
Definition: SDL3pp_properties.h:1082
float GetFloatProperty(PropertiesParam props, StringParam name, float default_value)
Get a floating point property from a group of properties.
Definition: SDL3pp_properties.h:1249
void ClearProperty(PropertiesParam props, StringParam name)
Clear a property from a group of properties.
Definition: SDL3pp_properties.h:1304
bool GetBooleanProperty(StringParam name, bool default_value)
Get a boolean property from a group of properties.
Definition: SDL3pp_properties.h:1288
void SetStringProperty(StringParam name, StringParam value)
Set a string property in a group of properties.
Definition: SDL3pp_properties.h:986
std::function< void(PropertiesID props, const char *name)> EnumeratePropertiesCB
A callback used to enumerate all the properties in a group of properties.
Definition: SDL3pp_properties.h:137
void Copy(PropertiesParam dst)
Copy a group of properties.
Definition: SDL3pp_properties.h:779
SDL_EnumeratePropertiesCallback EnumeratePropertiesCallback
A callback used to enumerate all the properties in a group of properties.
Definition: SDL3pp_properties.h:118
Uint64 GetCount()
Returns the number of properties this has.
Definition: SDL3pp_properties.h:1388
void * GetPointerProperty(PropertiesParam props, StringParam name, void *default_value)
Get a pointer property from a group of properties.
Definition: SDL3pp_properties.h:1147
PropertyType GetPropertyType(PropertiesParam props, StringParam name)
Get the type of a property in a group of properties.
Definition: SDL3pp_properties.h:1106
bool HasProperty(StringParam name)
Return whether a property exists in a group of properties.
Definition: SDL3pp_properties.h:1087
void * GetPointerProperty(StringParam name, void *default_value)
Get a pointer property from a group of properties.
Definition: SDL3pp_properties.h:1154
void 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 prope...
Definition: SDL3pp_properties.h:859
void SetBooleanProperty(StringParam name, bool value)
Set a boolean property in a group of properties.
Definition: SDL3pp_properties.h:1064
void CopyProperties(PropertiesParam src, PropertiesParam dst)
Copy a group of properties.
Definition: SDL3pp_properties.h:774
Properties CreateProperties()
Create a group of properties.
Definition: SDL3pp_properties.h:751
constexpr PropertyType PROPERTY_TYPE_NUMBER
NUMBER.
Definition: SDL3pp_properties.h:93
constexpr PropertyType PROPERTY_TYPE_POINTER
POINTER.
Definition: SDL3pp_properties.h:87
void SetPointerProperty(PropertiesParam props, StringParam name, void *value)
Set a pointer property in a group of properties.
Definition: SDL3pp_properties.h:949
const char * GetStringProperty(PropertiesParam props, StringParam name, StringParam default_value)
Get a string property from a group of properties.
Definition: SDL3pp_properties.h:1182
constexpr PropertyType PROPERTY_TYPE_INVALID
INVALID.
Definition: SDL3pp_properties.h:84
constexpr PropertyType PROPERTY_TYPE_FLOAT
FLOAT.
Definition: SDL3pp_properties.h:96
void Enumerate(EnumeratePropertiesCallback callback, void *userdata)
Enumerate the properties contained in a group of properties.
Definition: SDL3pp_properties.h:1362
void SetNumberProperty(PropertiesParam props, StringParam name, Sint64 value)
Set an integer property in a group of properties.
Definition: SDL3pp_properties.h:1005
constexpr PropertyType PROPERTY_TYPE_STRING
STRING.
Definition: SDL3pp_properties.h:90
PropertyType GetPropertyType(StringParam name)
Get the type of a property in a group of properties.
Definition: SDL3pp_properties.h:1111
void SetFloatProperty(PropertiesParam props, StringParam name, float value)
Set a floating point property in a group of properties.
Definition: SDL3pp_properties.h:1031
std::function< void(void *)> CleanupPropertyCB
A callback used to free resources when a property is deleted.
Definition: SDL3pp_properties.h:187
void SetPointerProperty(StringParam name, void *value)
Set a pointer property in a group of properties.
Definition: SDL3pp_properties.h:956
void Destroy()
Destroy a group of properties.
Definition: SDL3pp_properties.h:1414
void SetStringProperty(PropertiesParam props, StringParam name, StringParam value)
Set a string property in a group of properties.
Definition: SDL3pp_properties.h:979
SDL_CleanupPropertyCallback CleanupPropertyCallback
A callback used to free resources when a property is deleted.
Definition: SDL3pp_properties.h:162
SDL_PropertiesID PropertiesID
Alias to raw representation for Properties.
Definition: SDL3pp_properties.h:45
bool GetBooleanProperty(PropertiesParam props, StringParam name, bool default_value)
Get a boolean property from a group of properties.
Definition: SDL3pp_properties.h:1281
void ClearProperty(StringParam name)
Clear a property from a group of properties.
Definition: SDL3pp_properties.h:1309
void EnumerateProperties(PropertiesParam props, EnumeratePropertiesCallback callback, void *userdata)
Enumerate the properties contained in a group of properties.
Definition: SDL3pp_properties.h:1329
void DestroyProperties(PropertiesID props)
Destroy a group of properties.
Definition: SDL3pp_properties.h:1409
PropertiesRef GetGlobalProperties()
Get the global SDL properties.
Definition: SDL3pp_properties.h:732
::Uint64 Uint64
An unsigned 64-bit integer type.
Definition: SDL3pp_stdinc.h:340
::Sint64 Sint64
A signed 64-bit integer type.
Definition: SDL3pp_stdinc.h:325
Main include header for the SDL3pp library.
Definition: SDL3pp_callbackWrapper.h:66
Safely wrap Properties for non owning parameters.
Definition: SDL3pp_properties.h:52
constexpr PropertiesParam(std::nullptr_t _=nullptr)
Constructs null/invalid.
Definition: SDL3pp_properties.h:62
constexpr auto operator<=>(const PropertiesParam &other) const =default
Comparison.
constexpr PropertiesParam(PropertiesID value)
Constructs from PropertiesID.
Definition: SDL3pp_properties.h:56
PropertiesID value
parameter's PropertiesID
Definition: SDL3pp_properties.h:53
Semi-safe reference for Properties.
Definition: SDL3pp_properties.h:701
PropertiesRef(PropertiesParam resource)
Constructs from PropertiesParam.
Definition: SDL3pp_properties.h:709
PropertiesRef(const PropertiesRef &other)
Copy constructor.
Definition: SDL3pp_properties.h:715
~PropertiesRef()
Destructor.
Definition: SDL3pp_properties.h:721