sdl3_sys/generated/
properties.rs

1//! A property is a variable that can be created and retrieved by name at
2//! runtime.
3//!
4//! All properties are part of a property group ([`SDL_PropertiesID`]). A property
5//! group can be created with the [`SDL_CreateProperties`] function and destroyed
6//! with the [`SDL_DestroyProperties`] function.
7//!
8//! Properties can be added to and retrieved from a property group through the
9//! following functions:
10//!
11//! - [`SDL_SetPointerProperty`] and [`SDL_GetPointerProperty`] operate on `void*`
12//!   pointer types.
13//! - [`SDL_SetStringProperty`] and [`SDL_GetStringProperty`] operate on string types.
14//! - [`SDL_SetNumberProperty`] and [`SDL_GetNumberProperty`] operate on signed 64-bit
15//!   integer types.
16//! - [`SDL_SetFloatProperty`] and [`SDL_GetFloatProperty`] operate on floating point
17//!   types.
18//! - [`SDL_SetBooleanProperty`] and [`SDL_GetBooleanProperty`] operate on boolean
19//!   types.
20//!
21//! Properties can be removed from a group by using [`SDL_ClearProperty`].
22
23use super::stdinc::*;
24
25use super::error::*;
26
27/// An ID that represents a properties set.
28///
29/// ## Availability
30/// This datatype is available since SDL 3.2.0.
31#[repr(transparent)]
32#[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
33#[cfg_attr(feature = "debug-impls", derive(Debug))]
34pub struct SDL_PropertiesID(pub Uint32);
35
36impl ::core::cmp::PartialEq<Uint32> for SDL_PropertiesID {
37    #[inline(always)]
38    fn eq(&self, other: &Uint32) -> bool {
39        &self.0 == other
40    }
41}
42
43impl ::core::cmp::PartialEq<SDL_PropertiesID> for Uint32 {
44    #[inline(always)]
45    fn eq(&self, other: &SDL_PropertiesID) -> bool {
46        self == &other.0
47    }
48}
49
50impl From<SDL_PropertiesID> for Uint32 {
51    #[inline(always)]
52    fn from(value: SDL_PropertiesID) -> Self {
53        value.0
54    }
55}
56
57#[cfg(feature = "metadata")]
58impl sdl3_sys::metadata::GroupMetadata for SDL_PropertiesID {
59    const GROUP_METADATA: &'static sdl3_sys::metadata::Group =
60        &crate::metadata::properties::METADATA_SDL_PropertiesID;
61}
62
63/// SDL property type
64///
65/// ## Availability
66/// This enum is available since SDL 3.2.0.
67///
68/// ## Known values (`sdl3-sys`)
69/// | Associated constant | Global constant | Description |
70/// | ------------------- | --------------- | ----------- |
71/// | [`INVALID`](SDL_PropertyType::INVALID) | [`SDL_PROPERTY_TYPE_INVALID`] | |
72/// | [`POINTER`](SDL_PropertyType::POINTER) | [`SDL_PROPERTY_TYPE_POINTER`] | |
73/// | [`STRING`](SDL_PropertyType::STRING) | [`SDL_PROPERTY_TYPE_STRING`] | |
74/// | [`NUMBER`](SDL_PropertyType::NUMBER) | [`SDL_PROPERTY_TYPE_NUMBER`] | |
75/// | [`FLOAT`](SDL_PropertyType::FLOAT) | [`SDL_PROPERTY_TYPE_FLOAT`] | |
76/// | [`BOOLEAN`](SDL_PropertyType::BOOLEAN) | [`SDL_PROPERTY_TYPE_BOOLEAN`] | |
77#[repr(transparent)]
78#[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
79pub struct SDL_PropertyType(pub ::core::ffi::c_int);
80
81impl ::core::cmp::PartialEq<::core::ffi::c_int> for SDL_PropertyType {
82    #[inline(always)]
83    fn eq(&self, other: &::core::ffi::c_int) -> bool {
84        &self.0 == other
85    }
86}
87
88impl ::core::cmp::PartialEq<SDL_PropertyType> for ::core::ffi::c_int {
89    #[inline(always)]
90    fn eq(&self, other: &SDL_PropertyType) -> bool {
91        self == &other.0
92    }
93}
94
95impl From<SDL_PropertyType> for ::core::ffi::c_int {
96    #[inline(always)]
97    fn from(value: SDL_PropertyType) -> Self {
98        value.0
99    }
100}
101
102#[cfg(feature = "debug-impls")]
103impl ::core::fmt::Debug for SDL_PropertyType {
104    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
105        #[allow(unreachable_patterns)]
106        f.write_str(match *self {
107            Self::INVALID => "SDL_PROPERTY_TYPE_INVALID",
108            Self::POINTER => "SDL_PROPERTY_TYPE_POINTER",
109            Self::STRING => "SDL_PROPERTY_TYPE_STRING",
110            Self::NUMBER => "SDL_PROPERTY_TYPE_NUMBER",
111            Self::FLOAT => "SDL_PROPERTY_TYPE_FLOAT",
112            Self::BOOLEAN => "SDL_PROPERTY_TYPE_BOOLEAN",
113
114            _ => return write!(f, "SDL_PropertyType({})", self.0),
115        })
116    }
117}
118
119impl SDL_PropertyType {
120    pub const INVALID: Self = Self((0 as ::core::ffi::c_int));
121    pub const POINTER: Self = Self((1 as ::core::ffi::c_int));
122    pub const STRING: Self = Self((2 as ::core::ffi::c_int));
123    pub const NUMBER: Self = Self((3 as ::core::ffi::c_int));
124    pub const FLOAT: Self = Self((4 as ::core::ffi::c_int));
125    pub const BOOLEAN: Self = Self((5 as ::core::ffi::c_int));
126}
127
128pub const SDL_PROPERTY_TYPE_INVALID: SDL_PropertyType = SDL_PropertyType::INVALID;
129pub const SDL_PROPERTY_TYPE_POINTER: SDL_PropertyType = SDL_PropertyType::POINTER;
130pub const SDL_PROPERTY_TYPE_STRING: SDL_PropertyType = SDL_PropertyType::STRING;
131pub const SDL_PROPERTY_TYPE_NUMBER: SDL_PropertyType = SDL_PropertyType::NUMBER;
132pub const SDL_PROPERTY_TYPE_FLOAT: SDL_PropertyType = SDL_PropertyType::FLOAT;
133pub const SDL_PROPERTY_TYPE_BOOLEAN: SDL_PropertyType = SDL_PropertyType::BOOLEAN;
134
135#[cfg(feature = "metadata")]
136impl sdl3_sys::metadata::GroupMetadata for SDL_PropertyType {
137    const GROUP_METADATA: &'static sdl3_sys::metadata::Group =
138        &crate::metadata::properties::METADATA_SDL_PropertyType;
139}
140
141/// A generic property for naming things.
142///
143/// This property is intended to be added to any [`SDL_PropertiesID`] that needs a
144/// generic name associated with the property set. It is not guaranteed that
145/// any property set will include this key, but it is convenient to have a
146/// standard key that any piece of code could reasonably agree to use.
147///
148/// For example, the properties associated with an [`SDL_Texture`] might have a
149/// name string of "player sprites", or an [`SDL_AudioStream`] might have
150/// "background music", etc. This might also be useful for an [`SDL_IOStream`] to
151/// list the path to its asset.
152///
153/// There is no format for the value set with this key; it is expected to be
154/// human-readable and informational in nature, possibly for logging or
155/// debugging purposes.
156///
157/// SDL does not currently set this property on any objects it creates, but
158/// this may change in later versions; it is currently expected that apps and
159/// external libraries will take advantage of it, when appropriate.
160///
161/// ## Availability
162/// This macro is available since SDL 3.4.0.
163pub const SDL_PROP_NAME_STRING: *const ::core::ffi::c_char = c"SDL.name".as_ptr();
164
165unsafe extern "C" {
166    /// Get the global SDL properties.
167    ///
168    /// ## Return value
169    /// Returns a valid property ID on success or 0 on failure; call
170    ///   [`SDL_GetError()`] for more information.
171    ///
172    /// ## Availability
173    /// This function is available since SDL 3.2.0.
174    pub fn SDL_GetGlobalProperties() -> SDL_PropertiesID;
175}
176
177unsafe extern "C" {
178    /// Create a group of properties.
179    ///
180    /// All properties are automatically destroyed when [`SDL_Quit()`] is called.
181    ///
182    /// ## Return value
183    /// Returns an ID for a new group of properties, or 0 on failure; call
184    ///   [`SDL_GetError()`] for more information.
185    ///
186    /// ## Thread safety
187    /// It is safe to call this function from any thread.
188    ///
189    /// ## Availability
190    /// This function is available since SDL 3.2.0.
191    ///
192    /// ## See also
193    /// - [`SDL_DestroyProperties`]
194    pub fn SDL_CreateProperties() -> SDL_PropertiesID;
195}
196
197unsafe extern "C" {
198    /// Copy a group of properties.
199    ///
200    /// Copy all the properties from one group of properties to another, with the
201    /// exception of properties requiring cleanup (set using
202    /// [`SDL_SetPointerPropertyWithCleanup()`]), which will not be copied. Any
203    /// property that already exists on `dst` will be overwritten.
204    ///
205    /// ## Parameters
206    /// - `src`: the properties to copy.
207    /// - `dst`: the destination properties.
208    ///
209    /// ## Return value
210    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
211    ///   information.
212    ///
213    /// ## Thread safety
214    /// It is safe to call this function from any thread. This
215    ///   function acquires simultaneous mutex locks on both the source
216    ///   and destination property sets.
217    ///
218    /// ## Availability
219    /// This function is available since SDL 3.2.0.
220    pub fn SDL_CopyProperties(
221        src: SDL_PropertiesID,
222        dst: SDL_PropertiesID,
223    ) -> ::core::primitive::bool;
224}
225
226unsafe extern "C" {
227    /// Lock a group of properties.
228    ///
229    /// Obtain a multi-threaded lock for these properties. Other threads will wait
230    /// while trying to lock these properties until they are unlocked. Properties
231    /// must be unlocked before they are destroyed.
232    ///
233    /// The lock is automatically taken when setting individual properties, this
234    /// function is only needed when you want to set several properties atomically
235    /// or want to guarantee that properties being queried aren't freed in another
236    /// thread.
237    ///
238    /// ## Parameters
239    /// - `props`: the properties to lock.
240    ///
241    /// ## Return value
242    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
243    ///   information.
244    ///
245    /// ## Thread safety
246    /// It is safe to call this function from any thread.
247    ///
248    /// ## Availability
249    /// This function is available since SDL 3.2.0.
250    ///
251    /// ## See also
252    /// - [`SDL_UnlockProperties`]
253    pub fn SDL_LockProperties(props: SDL_PropertiesID) -> ::core::primitive::bool;
254}
255
256unsafe extern "C" {
257    /// Unlock a group of properties.
258    ///
259    /// ## Parameters
260    /// - `props`: the properties to unlock.
261    ///
262    /// ## Thread safety
263    /// It is safe to call this function from any thread.
264    ///
265    /// ## Availability
266    /// This function is available since SDL 3.2.0.
267    ///
268    /// ## See also
269    /// - [`SDL_LockProperties`]
270    pub fn SDL_UnlockProperties(props: SDL_PropertiesID);
271}
272
273/// A callback used to free resources when a property is deleted.
274///
275/// This should release any resources associated with `value` that are no
276/// longer needed.
277///
278/// This callback is set per-property. Different properties in the same group
279/// can have different cleanup callbacks.
280///
281/// This callback will be called _during_ [`SDL_SetPointerPropertyWithCleanup`] if
282/// the function fails for any reason.
283///
284/// ## Parameters
285/// - `userdata`: an app-defined pointer passed to the callback.
286/// - `value`: the pointer assigned to the property to clean up.
287///
288/// ## Thread safety
289/// This callback may fire without any locks held; if this is a
290///   concern, the app should provide its own locking.
291///
292/// ## Availability
293/// This datatype is available since SDL 3.2.0.
294///
295/// ## See also
296/// - [`SDL_SetPointerPropertyWithCleanup`]
297pub type SDL_CleanupPropertyCallback = ::core::option::Option<
298    unsafe extern "C" fn(userdata: *mut ::core::ffi::c_void, value: *mut ::core::ffi::c_void),
299>;
300
301unsafe extern "C" {
302    /// Set a pointer property in a group of properties with a cleanup function
303    /// that is called when the property is deleted.
304    ///
305    /// The cleanup function is also called if setting the property fails for any
306    /// reason.
307    ///
308    /// For simply setting basic data types, like numbers, bools, or strings, use
309    /// [`SDL_SetNumberProperty`], [`SDL_SetBooleanProperty`], or [`SDL_SetStringProperty`]
310    /// instead, as those functions will handle cleanup on your behalf. This
311    /// function is only for more complex, custom data.
312    ///
313    /// ## Parameters
314    /// - `props`: the properties to modify.
315    /// - `name`: the name of the property to modify.
316    /// - `value`: the new value of the property, or NULL to delete the property.
317    /// - `cleanup`: the function to call when this property is deleted, or NULL
318    ///   if no cleanup is necessary.
319    /// - `userdata`: a pointer that is passed to the cleanup function.
320    ///
321    /// ## Return value
322    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
323    ///   information.
324    ///
325    /// ## Thread safety
326    /// It is safe to call this function from any thread.
327    ///
328    /// ## Availability
329    /// This function is available since SDL 3.2.0.
330    ///
331    /// ## See also
332    /// - [`SDL_GetPointerProperty`]
333    /// - [`SDL_SetPointerProperty`]
334    /// - [`SDL_CleanupPropertyCallback`]
335    pub fn SDL_SetPointerPropertyWithCleanup(
336        props: SDL_PropertiesID,
337        name: *const ::core::ffi::c_char,
338        value: *mut ::core::ffi::c_void,
339        cleanup: SDL_CleanupPropertyCallback,
340        userdata: *mut ::core::ffi::c_void,
341    ) -> ::core::primitive::bool;
342}
343
344unsafe extern "C" {
345    /// Set a pointer property in a group of properties.
346    ///
347    /// ## Parameters
348    /// - `props`: the properties to modify.
349    /// - `name`: the name of the property to modify.
350    /// - `value`: the new value of the property, or NULL to delete the property.
351    ///
352    /// ## Return value
353    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
354    ///   information.
355    ///
356    /// ## Thread safety
357    /// It is safe to call this function from any thread.
358    ///
359    /// ## Availability
360    /// This function is available since SDL 3.2.0.
361    ///
362    /// ## See also
363    /// - [`SDL_GetPointerProperty`]
364    /// - [`SDL_HasProperty`]
365    /// - [`SDL_SetBooleanProperty`]
366    /// - [`SDL_SetFloatProperty`]
367    /// - [`SDL_SetNumberProperty`]
368    /// - [`SDL_SetPointerPropertyWithCleanup`]
369    /// - [`SDL_SetStringProperty`]
370    pub fn SDL_SetPointerProperty(
371        props: SDL_PropertiesID,
372        name: *const ::core::ffi::c_char,
373        value: *mut ::core::ffi::c_void,
374    ) -> ::core::primitive::bool;
375}
376
377unsafe extern "C" {
378    /// Set a string property in a group of properties.
379    ///
380    /// This function makes a copy of the string; the caller does not have to
381    /// preserve the data after this call completes.
382    ///
383    /// ## Parameters
384    /// - `props`: the properties to modify.
385    /// - `name`: the name of the property to modify.
386    /// - `value`: the new value of the property, or NULL to delete the property.
387    ///
388    /// ## Return value
389    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
390    ///   information.
391    ///
392    /// ## Thread safety
393    /// It is safe to call this function from any thread.
394    ///
395    /// ## Availability
396    /// This function is available since SDL 3.2.0.
397    ///
398    /// ## See also
399    /// - [`SDL_GetStringProperty`]
400    pub fn SDL_SetStringProperty(
401        props: SDL_PropertiesID,
402        name: *const ::core::ffi::c_char,
403        value: *const ::core::ffi::c_char,
404    ) -> ::core::primitive::bool;
405}
406
407unsafe extern "C" {
408    /// Set an integer property in a group of properties.
409    ///
410    /// ## Parameters
411    /// - `props`: the properties to modify.
412    /// - `name`: the name of the property to modify.
413    /// - `value`: the new value of the property.
414    ///
415    /// ## Return value
416    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
417    ///   information.
418    ///
419    /// ## Thread safety
420    /// It is safe to call this function from any thread.
421    ///
422    /// ## Availability
423    /// This function is available since SDL 3.2.0.
424    ///
425    /// ## See also
426    /// - [`SDL_GetNumberProperty`]
427    pub fn SDL_SetNumberProperty(
428        props: SDL_PropertiesID,
429        name: *const ::core::ffi::c_char,
430        value: Sint64,
431    ) -> ::core::primitive::bool;
432}
433
434unsafe extern "C" {
435    /// Set a floating point property in a group of properties.
436    ///
437    /// ## Parameters
438    /// - `props`: the properties to modify.
439    /// - `name`: the name of the property to modify.
440    /// - `value`: the new value of the property.
441    ///
442    /// ## Return value
443    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
444    ///   information.
445    ///
446    /// ## Thread safety
447    /// It is safe to call this function from any thread.
448    ///
449    /// ## Availability
450    /// This function is available since SDL 3.2.0.
451    ///
452    /// ## See also
453    /// - [`SDL_GetFloatProperty`]
454    pub fn SDL_SetFloatProperty(
455        props: SDL_PropertiesID,
456        name: *const ::core::ffi::c_char,
457        value: ::core::ffi::c_float,
458    ) -> ::core::primitive::bool;
459}
460
461unsafe extern "C" {
462    /// Set a boolean property in a group of properties.
463    ///
464    /// ## Parameters
465    /// - `props`: the properties to modify.
466    /// - `name`: the name of the property to modify.
467    /// - `value`: the new value of the property.
468    ///
469    /// ## Return value
470    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
471    ///   information.
472    ///
473    /// ## Thread safety
474    /// It is safe to call this function from any thread.
475    ///
476    /// ## Availability
477    /// This function is available since SDL 3.2.0.
478    ///
479    /// ## See also
480    /// - [`SDL_GetBooleanProperty`]
481    pub fn SDL_SetBooleanProperty(
482        props: SDL_PropertiesID,
483        name: *const ::core::ffi::c_char,
484        value: ::core::primitive::bool,
485    ) -> ::core::primitive::bool;
486}
487
488unsafe extern "C" {
489    /// Return whether a property exists in a group of properties.
490    ///
491    /// ## Parameters
492    /// - `props`: the properties to query.
493    /// - `name`: the name of the property to query.
494    ///
495    /// ## Return value
496    /// Returns true if the property exists, or false if it doesn't.
497    ///
498    /// ## Thread safety
499    /// It is safe to call this function from any thread.
500    ///
501    /// ## Availability
502    /// This function is available since SDL 3.2.0.
503    ///
504    /// ## See also
505    /// - [`SDL_GetPropertyType`]
506    pub fn SDL_HasProperty(
507        props: SDL_PropertiesID,
508        name: *const ::core::ffi::c_char,
509    ) -> ::core::primitive::bool;
510}
511
512unsafe extern "C" {
513    /// Get the type of a property in a group of properties.
514    ///
515    /// ## Parameters
516    /// - `props`: the properties to query.
517    /// - `name`: the name of the property to query.
518    ///
519    /// ## Return value
520    /// Returns the type of the property, or [`SDL_PROPERTY_TYPE_INVALID`] if it is
521    ///   not set.
522    ///
523    /// ## Thread safety
524    /// It is safe to call this function from any thread.
525    ///
526    /// ## Availability
527    /// This function is available since SDL 3.2.0.
528    ///
529    /// ## See also
530    /// - [`SDL_HasProperty`]
531    pub fn SDL_GetPropertyType(
532        props: SDL_PropertiesID,
533        name: *const ::core::ffi::c_char,
534    ) -> SDL_PropertyType;
535}
536
537unsafe extern "C" {
538    /// Get a pointer property from a group of properties.
539    ///
540    /// By convention, the names of properties that SDL exposes on objects will
541    /// start with "SDL.", and properties that SDL uses internally will start with
542    /// "SDL.internal.". These should be considered read-only and should not be
543    /// modified by applications.
544    ///
545    /// ## Parameters
546    /// - `props`: the properties to query.
547    /// - `name`: the name of the property to query.
548    /// - `default_value`: the default value of the property.
549    ///
550    /// ## Return value
551    /// Returns the value of the property, or `default_value` if it is not set or
552    ///   not a pointer property.
553    ///
554    /// ## Thread safety
555    /// It is safe to call this function from any thread, although
556    ///   the data returned is not protected and could potentially be
557    ///   freed if you call [`SDL_SetPointerProperty()`] or
558    ///   [`SDL_ClearProperty()`] on these properties from another thread.
559    ///   If you need to avoid this, use [`SDL_LockProperties()`] and
560    ///   [`SDL_UnlockProperties()`].
561    ///
562    /// ## Availability
563    /// This function is available since SDL 3.2.0.
564    ///
565    /// ## See also
566    /// - [`SDL_GetBooleanProperty`]
567    /// - [`SDL_GetFloatProperty`]
568    /// - [`SDL_GetNumberProperty`]
569    /// - [`SDL_GetPropertyType`]
570    /// - [`SDL_GetStringProperty`]
571    /// - [`SDL_HasProperty`]
572    /// - [`SDL_SetPointerProperty`]
573    pub fn SDL_GetPointerProperty(
574        props: SDL_PropertiesID,
575        name: *const ::core::ffi::c_char,
576        default_value: *mut ::core::ffi::c_void,
577    ) -> *mut ::core::ffi::c_void;
578}
579
580unsafe extern "C" {
581    /// Get a string property from a group of properties.
582    ///
583    /// ## Parameters
584    /// - `props`: the properties to query.
585    /// - `name`: the name of the property to query.
586    /// - `default_value`: the default value of the property.
587    ///
588    /// ## Return value
589    /// Returns the value of the property, or `default_value` if it is not set or
590    ///   not a string property.
591    ///
592    /// ## Thread safety
593    /// It is safe to call this function from any thread, although
594    ///   the data returned is not protected and could potentially be
595    ///   freed if you call [`SDL_SetStringProperty()`] or
596    ///   [`SDL_ClearProperty()`] on these properties from another thread.
597    ///   If you need to avoid this, use [`SDL_LockProperties()`] and
598    ///   [`SDL_UnlockProperties()`].
599    ///
600    /// ## Availability
601    /// This function is available since SDL 3.2.0.
602    ///
603    /// ## See also
604    /// - [`SDL_GetPropertyType`]
605    /// - [`SDL_HasProperty`]
606    /// - [`SDL_SetStringProperty`]
607    pub fn SDL_GetStringProperty(
608        props: SDL_PropertiesID,
609        name: *const ::core::ffi::c_char,
610        default_value: *const ::core::ffi::c_char,
611    ) -> *const ::core::ffi::c_char;
612}
613
614unsafe extern "C" {
615    /// Get a number property from a group of properties.
616    ///
617    /// You can use [`SDL_GetPropertyType()`] to query whether the property exists and
618    /// is a number property.
619    ///
620    /// ## Parameters
621    /// - `props`: the properties to query.
622    /// - `name`: the name of the property to query.
623    /// - `default_value`: the default value of the property.
624    ///
625    /// ## Return value
626    /// Returns the value of the property, or `default_value` if it is not set or
627    ///   not a number property.
628    ///
629    /// ## Thread safety
630    /// It is safe to call this function from any thread.
631    ///
632    /// ## Availability
633    /// This function is available since SDL 3.2.0.
634    ///
635    /// ## See also
636    /// - [`SDL_GetPropertyType`]
637    /// - [`SDL_HasProperty`]
638    /// - [`SDL_SetNumberProperty`]
639    pub fn SDL_GetNumberProperty(
640        props: SDL_PropertiesID,
641        name: *const ::core::ffi::c_char,
642        default_value: Sint64,
643    ) -> Sint64;
644}
645
646unsafe extern "C" {
647    /// Get a floating point property from a group of properties.
648    ///
649    /// You can use [`SDL_GetPropertyType()`] to query whether the property exists and
650    /// is a floating point property.
651    ///
652    /// ## Parameters
653    /// - `props`: the properties to query.
654    /// - `name`: the name of the property to query.
655    /// - `default_value`: the default value of the property.
656    ///
657    /// ## Return value
658    /// Returns the value of the property, or `default_value` if it is not set or
659    ///   not a float property.
660    ///
661    /// ## Thread safety
662    /// It is safe to call this function from any thread.
663    ///
664    /// ## Availability
665    /// This function is available since SDL 3.2.0.
666    ///
667    /// ## See also
668    /// - [`SDL_GetPropertyType`]
669    /// - [`SDL_HasProperty`]
670    /// - [`SDL_SetFloatProperty`]
671    pub fn SDL_GetFloatProperty(
672        props: SDL_PropertiesID,
673        name: *const ::core::ffi::c_char,
674        default_value: ::core::ffi::c_float,
675    ) -> ::core::ffi::c_float;
676}
677
678unsafe extern "C" {
679    /// Get a boolean property from a group of properties.
680    ///
681    /// You can use [`SDL_GetPropertyType()`] to query whether the property exists and
682    /// is a boolean property.
683    ///
684    /// ## Parameters
685    /// - `props`: the properties to query.
686    /// - `name`: the name of the property to query.
687    /// - `default_value`: the default value of the property.
688    ///
689    /// ## Return value
690    /// Returns the value of the property, or `default_value` if it is not set or
691    ///   not a boolean property.
692    ///
693    /// ## Thread safety
694    /// It is safe to call this function from any thread.
695    ///
696    /// ## Availability
697    /// This function is available since SDL 3.2.0.
698    ///
699    /// ## See also
700    /// - [`SDL_GetPropertyType`]
701    /// - [`SDL_HasProperty`]
702    /// - [`SDL_SetBooleanProperty`]
703    pub fn SDL_GetBooleanProperty(
704        props: SDL_PropertiesID,
705        name: *const ::core::ffi::c_char,
706        default_value: ::core::primitive::bool,
707    ) -> ::core::primitive::bool;
708}
709
710unsafe extern "C" {
711    /// Clear a property from a group of properties.
712    ///
713    /// ## Parameters
714    /// - `props`: the properties to modify.
715    /// - `name`: the name of the property to clear.
716    ///
717    /// ## Return value
718    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
719    ///   information.
720    ///
721    /// ## Thread safety
722    /// It is safe to call this function from any thread.
723    ///
724    /// ## Availability
725    /// This function is available since SDL 3.2.0.
726    pub fn SDL_ClearProperty(
727        props: SDL_PropertiesID,
728        name: *const ::core::ffi::c_char,
729    ) -> ::core::primitive::bool;
730}
731
732/// A callback used to enumerate all the properties in a group of properties.
733///
734/// This callback is called from [`SDL_EnumerateProperties()`], and is called once
735/// per property in the set.
736///
737/// ## Parameters
738/// - `userdata`: an app-defined pointer passed to the callback.
739/// - `props`: the [`SDL_PropertiesID`] that is being enumerated.
740/// - `name`: the next property name in the enumeration.
741///
742/// ## Thread safety
743/// [`SDL_EnumerateProperties`] holds a lock on `props` during this
744///   callback.
745///
746/// ## Availability
747/// This datatype is available since SDL 3.2.0.
748///
749/// ## See also
750/// - [`SDL_EnumerateProperties`]
751pub type SDL_EnumeratePropertiesCallback = ::core::option::Option<
752    unsafe extern "C" fn(
753        userdata: *mut ::core::ffi::c_void,
754        props: SDL_PropertiesID,
755        name: *const ::core::ffi::c_char,
756    ),
757>;
758
759unsafe extern "C" {
760    /// Enumerate the properties contained in a group of properties.
761    ///
762    /// The callback function is called for each property in the group of
763    /// properties. The properties are locked during enumeration.
764    ///
765    /// ## Parameters
766    /// - `props`: the properties to query.
767    /// - `callback`: the function to call for each property.
768    /// - `userdata`: a pointer that is passed to `callback`.
769    ///
770    /// ## Return value
771    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
772    ///   information.
773    ///
774    /// ## Thread safety
775    /// It is safe to call this function from any thread.
776    ///
777    /// ## Availability
778    /// This function is available since SDL 3.2.0.
779    pub fn SDL_EnumerateProperties(
780        props: SDL_PropertiesID,
781        callback: SDL_EnumeratePropertiesCallback,
782        userdata: *mut ::core::ffi::c_void,
783    ) -> ::core::primitive::bool;
784}
785
786unsafe extern "C" {
787    /// Destroy a group of properties.
788    ///
789    /// All properties are deleted and their cleanup functions will be called, if
790    /// any.
791    ///
792    /// ## Parameters
793    /// - `props`: the properties to destroy.
794    ///
795    /// ## Thread safety
796    /// This function should not be called while these properties are
797    ///   locked or other threads might be setting or getting values
798    ///   from these properties.
799    ///
800    /// ## Availability
801    /// This function is available since SDL 3.2.0.
802    ///
803    /// ## See also
804    /// - [`SDL_CreateProperties`]
805    pub fn SDL_DestroyProperties(props: SDL_PropertiesID);
806}
807
808#[cfg(doc)]
809use crate::everything::*;