1#ifndef SDL3PP_PROPERTIES_H_
2#define SDL3PP_PROPERTIES_H_
4#include <SDL3/SDL_properties.h>
5#include "SDL3pp_error.h"
6#include "SDL3pp_stdinc.h"
150 SDL_PROPERTY_TYPE_INVALID;
153 SDL_PROPERTY_TYPE_POINTER;
156 SDL_PROPERTY_TYPE_STRING;
159 SDL_PROPERTY_TYPE_NUMBER;
164 SDL_PROPERTY_TYPE_BOOLEAN;
281 Wrapper::Wrap(std::move(cleanup)));
318 SDL_SetPointerPropertyWithCleanup(
get(), name, value, cleanup, userdata));
451 return SDL_GetPropertyType(
get(), name);
489 return SDL_GetPointerProperty(
get(), name, default_value);
523 return SDL_GetStringProperty(
get(), name, default_value);
552 return SDL_GetNumberProperty(
get(), name, default_value);
581 return SDL_GetFloatProperty(
get(), name, default_value);
610 return SDL_GetBooleanProperty(
get(), name, default_value);
633 template<std::output_iterator<const
char*> IT>
637 [&outputIter](
auto props,
const char name) { *outputIter++ = name; });
673 CheckError(SDL_EnumerateProperties(
get(), callback, userdata));
694 using PropertiesBase::PropertiesBase;
741 void reset(SDL_PropertiesID newResource = {})
743 SDL_DestroyProperties(
release(newResource));
762 constexpr explicit Properties(SDL_PropertiesID resource = {})
820 : properties(properties)
832 : properties(std::move(other.properties))
844 std::swap(properties, other.properties);
851 constexpr operator bool()
const {
return bool(properties); }
911 [](
void* userdata, SDL_PropertiesID props,
const char* name) {
921 Enumerate([&](
auto,
const char*) { count++; });
925#pragma endregion impl
Wrap the lock state for PropertiesBase.
Definition SDL3pp_properties.h:813
~PropertiesLock()
Definition SDL3pp_properties.h:839
constexpr PropertiesLock()=default
Default ctor.
void Unlock()
Unlock a group of properties.
Definition SDL3pp_properties.h:862
PropertiesLock(PropertiesLock &&other)
Move ctor.
Definition SDL3pp_properties.h:831
PropertiesLock & operator=(PropertiesLock other)
Assignment operator.
Definition SDL3pp_properties.h:842
A SDL managed resource.
Definition SDL3pp_resource.h:17
constexpr SDL_PropertiesID release(SDL_PropertiesID newResource={})
Return contained resource and empties or replace value.
Definition SDL3pp_resource.h:60
constexpr Resource(T resource={})
Constructs the underlying resource.
Definition SDL3pp_resource.h:22
constexpr SDL_PropertiesID get() const
Return contained resource;.
Definition SDL3pp_resource.h:57
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:206
constexpr PropertyType PROPERTY_TYPE_BOOLEAN
BOOLEAN.
Definition SDL3pp_properties.h:163
SDL_PropertyType PropertyType
SDL property type.
Definition SDL3pp_properties.h:45
SDL_EnumeratePropertiesCallback EnumeratePropertiesCallback
A callback used to enumerate all the properties in a group of properties.
Definition SDL3pp_properties.h:110
Properties CreateProperties()
Create a group of properties.
Definition SDL3pp_properties.h:900
constexpr PropertyType PROPERTY_TYPE_NUMBER
NUMBER.
Definition SDL3pp_properties.h:158
constexpr PropertyType PROPERTY_TYPE_POINTER
POINTER.
Definition SDL3pp_properties.h:152
PropertiesLock Lock() &
Lock a group of properties.
Definition SDL3pp_properties.h:880
constexpr PropertyType PROPERTY_TYPE_INVALID
INVALID.
Definition SDL3pp_properties.h:149
constexpr PropertyType PROPERTY_TYPE_FLOAT
FLOAT.
Definition SDL3pp_properties.h:161
constexpr PropertyType PROPERTY_TYPE_STRING
STRING.
Definition SDL3pp_properties.h:155
std::function< void(void *)> CleanupPropertyCB
A callback used to free resources when a property is deleted.
Definition SDL3pp_properties.h:85
std::function< void(PropertiesRef props, const char *name)> EnumeratePropertiesCB
A callback used to enumerate all the properties in a group of properties.
Definition SDL3pp_properties.h:136
SDL_CleanupPropertyCallback CleanupPropertyCallback
A callback used to free resources when a property is deleted.
Definition SDL3pp_properties.h:74
PropertiesRef GetGlobalProperties()
Get the global SDL properties.
Definition SDL3pp_properties.h:875
the main namespace where all SDL3pp public functions and types live
Definition SDL3pp_assert.h:7
Definition SDL3pp_callbackWrapper.h:66
Wrap properties id.
Definition SDL3pp_properties.h:203
Uint64 GetCount() const
Returns the number of properties this has.
Definition SDL3pp_properties.h:918
const char * GetString(StringParam name, StringParam default_value) const
Get a string property from a group of properties.
Definition SDL3pp_properties.h:521
void Clear(StringParam name)
Clear a property from a group of properties.
Definition SDL3pp_properties.h:623
void SetFloat(StringParam name, float value)
Set a floating point property in a group of properties.
Definition SDL3pp_properties.h:399
void SetPointer(StringParam name, void *value)
Set a pointer property in a group of properties.
Definition SDL3pp_properties.h:341
void CopyPropertiesTo(PropertiesBase &dst) const
Copy a group of properties.
Definition SDL3pp_properties.h:221
void SetBoolean(StringParam name, bool value)
Set a boolean property in a group of properties.
Definition SDL3pp_properties.h:417
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 prope...
Definition SDL3pp_properties.h:273
float GetFloat(StringParam name, float default_value) const
Get a floating point property from a group of properties.
Definition SDL3pp_properties.h:579
void SetString(StringParam name, StringParam value)
Set a string property in a group of properties.
Definition SDL3pp_properties.h:363
void SetNumber(StringParam name, Sint64 value)
Set an integer property in a group of properties.
Definition SDL3pp_properties.h:381
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 prope...
Definition SDL3pp_properties.h:312
void Enumerate(IT outputIter) const
Enumerate the properties contained in a group of properties.
Definition SDL3pp_properties.h:634
Sint64 GetNumber(StringParam name, Sint64 default_value) const
Get a number property from a group of properties.
Definition SDL3pp_properties.h:550
bool Has(StringParam name) const
Return whether a property exists in a group of properties.
Definition SDL3pp_properties.h:434
void * GetPointer(StringParam name, void *default_value) const
Get a pointer property from a group of properties.
Definition SDL3pp_properties.h:487
void Enumerate(EnumeratePropertiesCallback callback, void *userdata) const
Enumerate the properties contained in a group of properties.
Definition SDL3pp_properties.h:671
bool GetBoolean(StringParam name, bool default_value) const
Get a boolean property from a group of properties.
Definition SDL3pp_properties.h:608
PropertyType GetType(StringParam name) const
Get the type of a property.
Definition SDL3pp_properties.h:449
Handle to a non owned properties.
Definition SDL3pp_properties.h:693
void reset(SDL_PropertiesID newResource={})
Destroy a group of properties.
Definition SDL3pp_properties.h:741
PropertiesRef & operator=(PropertiesRef other)
Assignment operator.
Definition SDL3pp_properties.h:720
constexpr PropertiesRef(const PropertiesRef &other)
Copy constructor.
Definition SDL3pp_properties.h:699
constexpr ~PropertiesRef()=default
Default constructor.
constexpr PropertiesRef(PropertiesRef &&other)
Move constructor.
Definition SDL3pp_properties.h:707
Handle to an owned properties.
Definition SDL3pp_properties.h:756
Properties & operator=(Properties other)
Assignment operator.
Definition SDL3pp_properties.h:801
constexpr Properties(Properties &&other)=default
Move constructor.
~Properties()
Frees up resource when object goes out of scope.
Definition SDL3pp_properties.h:796
Properties()
Create a group of properties.
Definition SDL3pp_properties.h:788
constexpr Properties(SDL_PropertiesID resource={})
Constructs from the underlying resource.
Definition SDL3pp_properties.h:762