Files
hdk-sdl/include/hdk/sdl/Properties.hpp
2026-05-11 10:28:21 +00:00

61 lines
3.3 KiB
C++

#pragma once
/// @file Properties.hpp
/// For complete documentation, see src/Properties.cpp
#include <SDL3/SDL_properties.h>
#include <hdk/grid/PrimitiveWrapper.hpp>
namespace hdk::sdl {
class Properties : public grid::PrimitiveWrapper<SDL_PropertiesID> {
public:
using grid::PrimitiveWrapper<SDL_PropertiesID>::PrimitiveWrapper;
static Properties Create() { return Properties(SDL_CreateProperties()); }
bool ClearProperty(const char* name) const { return SDL_ClearProperty(*this, name); }
bool CopyAllTo(SDL_PropertiesID destination) const { return SDL_CopyProperties(*this, destination); }
bool CopyAllFrom(SDL_PropertiesID source) { return SDL_CopyProperties(source, *this); }
void Destroy() {
SDL_DestroyProperties(*this);
*this = 0;
}
bool EnumerateProperties(SDL_EnumeratePropertiesCallback callback, void* callback_data) const {
return SDL_EnumerateProperties(*this, callback, callback_data);
}
bool GetBooleanProperty(const char* name, bool default_value) const {
return SDL_GetBooleanProperty(*this, name, default_value);
}
float GetFloatProperty(const char* name, float default_value) const {
return SDL_GetFloatProperty(*this, name, default_value);
}
static Properties GetGlobalProperties() { return Properties(SDL_GetGlobalProperties()); }
double GetNumberProperty(const char* name, double default_value) const {
return SDL_GetNumberProperty(*this, name, default_value);
}
void* GetPointerProperty(const char* name, void* default_value) const {
return SDL_GetPointerProperty(*this, name, default_value);
}
SDL_PropertyType GetPropertyType(const char* name) const { return SDL_GetPropertyType(*this, name); }
const char* GetStringProperty(const char* name, const char* default_value) const {
return SDL_GetStringProperty(*this, name, default_value);
}
bool HasProperty(const char* name) const { return SDL_HasProperty(*this, name); }
bool LockProperties() { return SDL_LockProperties(*this); }
bool SetBooleanProperty(const char* name, bool value) { return SDL_SetBooleanProperty(*this, name, value); }
// SDL_SetFloatProperty
bool SetFloatProperty(const char* name, float value) { return SDL_SetFloatProperty(*this, name, value); }
// SDL_SetNumberProperty
bool SetNumberProperty(const char* name, double value) { return SDL_SetNumberProperty(*this, name, value); }
// SDL_SetPointerProperty
bool SetPointerProperty(const char* name, void* value) { return SDL_SetPointerProperty(*this, name, value); }
// SDL_SetPointerPropertyWithCleanup
bool SetPointerPropertyWithCleanup(const char* name,
void* value,
SDL_CleanupPropertyCallback cleanup_callback,
void* userdata = nullptr) {
return SDL_SetPointerPropertyWithCleanup(*this, name, value, cleanup_callback, userdata);
}
// SDL_SetStringProperty
bool SetStringProperty(const char* name, const char* value) { return SDL_SetStringProperty(*this, name, value); }
// SDL_UnlockProperties
void UnlockProperties() { SDL_UnlockProperties(*this); }
};
}