Skip to main content

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