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"
182 SDL_PROPERTY_TYPE_INVALID;
185 SDL_PROPERTY_TYPE_POINTER;
188 SDL_PROPERTY_TYPE_STRING;
191 SDL_PROPERTY_TYPE_NUMBER;
196 SDL_PROPERTY_TYPE_BOOLEAN;
287 Wrapper::Wrap(std::move(cleanup)));
324 SDL_SetPointerPropertyWithCleanup(
get(), name, value, cleanup, userdata));
457 return SDL_GetPropertyType(
get(), name);
495 return SDL_GetPointerProperty(
get(), name, default_value);
529 return SDL_GetStringProperty(
get(), name, default_value);
558 return SDL_GetNumberProperty(
get(), name, default_value);
587 return SDL_GetFloatProperty(
get(), name, default_value);
616 return SDL_GetBooleanProperty(
get(), name, default_value);
639 template<std::output_iterator<const
char*> IT>
643 [&outputIter](
auto props,
const char name) { *outputIter++ = name; });
679 CheckError(SDL_EnumerateProperties(
get(), callback, userdata));
705 static void reset(SDL_PropertiesID resource)
707 SDL_DestroyProperties(resource);
886 [](
void* userdata, SDL_PropertiesID props,
const char* name) {
896 Enumerate([&](
auto,
const char*) { count++; });
900#pragma endregion impl
Base class for locks.
Definition SDL3pp_resource.h:408
RESOURCE release()
Returns reference and reset this.
Definition SDL3pp_resource.h:178
reference & get()
Get reference.
Definition SDL3pp_resource.h:120
Implement shared ownership for a resource.
Definition SDL3pp_resource.h:283
Implement unique ownership for a resource.
Definition SDL3pp_resource.h:226
constexpr ResourceUnique(std::nullptr_t=nullptr)
Default constructor.
Definition SDL3pp_resource.h:231
void reset()
Resets the value, destroying the resource if not nullptr.
Definition SDL3pp_resource.h:265
A dumb pointer to resource.
Definition SDL3pp_resource.h:197
constexpr ResourceUnsafe()=default
Default constructor.
Implement weak ownership for a resource.
Definition SDL3pp_resource.h:328
A SDL managed resource.
Definition SDL3pp_resource.h:29
constexpr Resource(T resource={})
Constructs from the underlying resource.
Definition SDL3pp_resource.h:37
constexpr SDL_PropertiesID get() const
Return contained resource;.
Definition SDL3pp_resource.h:76
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:195
SDL_PropertyType PropertyType
SDL property type.
Definition SDL3pp_properties.h:45
ResourceShared< Properties > PropertiesShared
Handle to a shared properties.
Definition SDL3pp_properties.h:166
PropertiesLock Lock() &
Lock a group of properties.
Definition SDL3pp_properties.h:874
SDL_EnumeratePropertiesCallback EnumeratePropertiesCallback
A callback used to enumerate all the properties in a group of properties.
Definition SDL3pp_properties.h:126
constexpr PropertyType PROPERTY_TYPE_NUMBER
NUMBER.
Definition SDL3pp_properties.h:190
constexpr PropertyType PROPERTY_TYPE_POINTER
POINTER.
Definition SDL3pp_properties.h:184
constexpr PropertyType PROPERTY_TYPE_INVALID
INVALID.
Definition SDL3pp_properties.h:181
constexpr PropertyType PROPERTY_TYPE_FLOAT
FLOAT.
Definition SDL3pp_properties.h:193
constexpr PropertyType PROPERTY_TYPE_STRING
STRING.
Definition SDL3pp_properties.h:187
std::function< void(void *)> CleanupPropertyCB
A callback used to free resources when a property is deleted.
Definition SDL3pp_properties.h:101
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:151
SDL_CleanupPropertyCallback CleanupPropertyCallback
A callback used to free resources when a property is deleted.
Definition SDL3pp_properties.h:74
PropertiesShared share()
Move this properties into a PropertiesShared.
Definition SDL3pp_properties.h:764
PropertiesRef GetGlobalProperties()
Get the global SDL properties.
Definition SDL3pp_properties.h:869
the main namespace where all SDL3pp public functions and types live
Definition SDL3pp_assert.h:7
Definition SDL3pp_callbackWrapper.h:66
Wrap the lock state for Properties.
Definition SDL3pp_properties.h:796
~PropertiesLock()
Destructor.
Definition SDL3pp_properties.h:842
PropertiesLock(PropertiesRef props)
Lock a group of properties.
Definition SDL3pp_properties.h:831
constexpr PropertiesLock(PropertiesLock &&other)
Move constructor.
Definition SDL3pp_properties.h:805
constexpr PropertiesLock()=default
Creates an empty lock.
void Unlock()
Unlock a group of properties.
Definition SDL3pp_properties.h:853
void reset()
Same as Unlock(), just for uniformity.
Definition SDL3pp_properties.h:858
SDL properties ID.
Definition SDL3pp_properties.h:209
float GetFloat(StringParam name, float default_value) const
Get a floating point property from a group of properties.
Definition SDL3pp_properties.h:585
Sint64 GetNumber(StringParam name, Sint64 default_value) const
Get a number property from a group of properties.
Definition SDL3pp_properties.h:556
void Enumerate(EnumeratePropertiesCallback callback, void *userdata) const
Enumerate the properties contained in a group of properties.
Definition SDL3pp_properties.h:677
void SetNumber(StringParam name, Sint64 value)
Set an integer property in a group of properties.
Definition SDL3pp_properties.h:387
PropertyType GetType(StringParam name) const
Get the type of a property.
Definition SDL3pp_properties.h:455
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:279
void Clear(StringParam name)
Clear a property from a group of properties.
Definition SDL3pp_properties.h:629
void SetBoolean(StringParam name, bool value)
Set a boolean property in a group of properties.
Definition SDL3pp_properties.h:423
void CopyPropertiesTo(PropertiesRef dst) const
Copy a group of properties.
Definition SDL3pp_properties.h:227
void Enumerate(IT outputIter) const
Enumerate the properties contained in a group of properties.
Definition SDL3pp_properties.h:640
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:318
void SetString(StringParam name, StringParam value)
Set a string property in a group of properties.
Definition SDL3pp_properties.h:369
Uint64 GetCount() const
Returns the number of properties this has.
Definition SDL3pp_properties.h:893
const char * GetString(StringParam name, StringParam default_value) const
Get a string property from a group of properties.
Definition SDL3pp_properties.h:527
static void reset(SDL_PropertiesID resource)
Destroy a group of properties.
Definition SDL3pp_properties.h:705
bool GetBoolean(StringParam name, bool default_value) const
Get a boolean property from a group of properties.
Definition SDL3pp_properties.h:614
void SetFloat(StringParam name, float value)
Set a floating point property in a group of properties.
Definition SDL3pp_properties.h:405
void * GetPointer(StringParam name, void *default_value) const
Get a pointer property from a group of properties.
Definition SDL3pp_properties.h:493
void SetPointer(StringParam name, void *value)
Set a pointer property in a group of properties.
Definition SDL3pp_properties.h:347
bool Has(StringParam name) const
Return whether a property exists in a group of properties.
Definition SDL3pp_properties.h:440
Unsafe Handle to properties.
Definition SDL3pp_properties.h:779
constexpr PropertiesUnsafe(Properties &&other)
Constructs PropertiesUnsafe from Properties.
Definition SDL3pp_properties.h:785
Handle to an owned properties.
Definition SDL3pp_properties.h:719
static Properties Create()
Create a group of properties.
Definition SDL3pp_properties.h:736
void Destroy()
Destroy a group of properties.
Definition SDL3pp_properties.h:755