objc2_core_foundation/generated/
CFNumberFormatter.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::cell::UnsafeCell;
4use core::ffi::*;
5use core::marker::{PhantomData, PhantomPinned};
6use core::ptr::NonNull;
7#[cfg(feature = "objc2")]
8use objc2::__framework_prelude::*;
9
10use crate::*;
11
12/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfnumberformatterkey?language=objc)
13// NS_TYPED_ENUM
14pub type CFNumberFormatterKey = CFString;
15
16/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfnumberformatter?language=objc)
17#[repr(C)]
18pub struct CFNumberFormatter {
19    inner: [u8; 0],
20    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
21}
22
23cf_type!(
24    unsafe impl CFNumberFormatter {}
25);
26#[cfg(feature = "objc2")]
27cf_objc2_type!(
28    unsafe impl RefEncode<"__CFNumberFormatter"> for CFNumberFormatter {}
29);
30
31unsafe impl ConcreteType for CFNumberFormatter {
32    #[doc(alias = "CFNumberFormatterGetTypeID")]
33    #[inline]
34    fn type_id() -> CFTypeID {
35        extern "C-unwind" {
36            fn CFNumberFormatterGetTypeID() -> CFTypeID;
37        }
38        unsafe { CFNumberFormatterGetTypeID() }
39    }
40}
41
42/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfnumberformatterstyle?language=objc)
43// NS_ENUM
44#[repr(transparent)]
45#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
46pub struct CFNumberFormatterStyle(pub CFIndex);
47impl CFNumberFormatterStyle {
48    #[doc(alias = "kCFNumberFormatterNoStyle")]
49    pub const NoStyle: Self = Self(0);
50    #[doc(alias = "kCFNumberFormatterDecimalStyle")]
51    pub const DecimalStyle: Self = Self(1);
52    #[doc(alias = "kCFNumberFormatterCurrencyStyle")]
53    pub const CurrencyStyle: Self = Self(2);
54    #[doc(alias = "kCFNumberFormatterPercentStyle")]
55    pub const PercentStyle: Self = Self(3);
56    #[doc(alias = "kCFNumberFormatterScientificStyle")]
57    pub const ScientificStyle: Self = Self(4);
58    #[doc(alias = "kCFNumberFormatterSpellOutStyle")]
59    pub const SpellOutStyle: Self = Self(5);
60    #[doc(alias = "kCFNumberFormatterOrdinalStyle")]
61    pub const OrdinalStyle: Self = Self(6);
62    #[doc(alias = "kCFNumberFormatterCurrencyISOCodeStyle")]
63    pub const CurrencyISOCodeStyle: Self = Self(8);
64    #[doc(alias = "kCFNumberFormatterCurrencyPluralStyle")]
65    pub const CurrencyPluralStyle: Self = Self(9);
66    #[doc(alias = "kCFNumberFormatterCurrencyAccountingStyle")]
67    pub const CurrencyAccountingStyle: Self = Self(10);
68}
69
70#[cfg(feature = "objc2")]
71unsafe impl Encode for CFNumberFormatterStyle {
72    const ENCODING: Encoding = CFIndex::ENCODING;
73}
74
75#[cfg(feature = "objc2")]
76unsafe impl RefEncode for CFNumberFormatterStyle {
77    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
78}
79
80impl CFNumberFormatter {
81    #[doc(alias = "CFNumberFormatterCreate")]
82    #[cfg(feature = "CFLocale")]
83    #[inline]
84    pub unsafe fn new(
85        allocator: Option<&CFAllocator>,
86        locale: Option<&CFLocale>,
87        style: CFNumberFormatterStyle,
88    ) -> Option<CFRetained<CFNumberFormatter>> {
89        extern "C-unwind" {
90            fn CFNumberFormatterCreate(
91                allocator: Option<&CFAllocator>,
92                locale: Option<&CFLocale>,
93                style: CFNumberFormatterStyle,
94            ) -> Option<NonNull<CFNumberFormatter>>;
95        }
96        let ret = unsafe { CFNumberFormatterCreate(allocator, locale, style) };
97        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
98    }
99
100    #[doc(alias = "CFNumberFormatterGetLocale")]
101    #[cfg(feature = "CFLocale")]
102    #[inline]
103    pub unsafe fn locale(self: &CFNumberFormatter) -> Option<CFRetained<CFLocale>> {
104        extern "C-unwind" {
105            fn CFNumberFormatterGetLocale(
106                formatter: &CFNumberFormatter,
107            ) -> Option<NonNull<CFLocale>>;
108        }
109        let ret = unsafe { CFNumberFormatterGetLocale(self) };
110        ret.map(|ret| unsafe { CFRetained::retain(ret) })
111    }
112
113    #[doc(alias = "CFNumberFormatterGetStyle")]
114    #[inline]
115    pub unsafe fn style(self: &CFNumberFormatter) -> CFNumberFormatterStyle {
116        extern "C-unwind" {
117            fn CFNumberFormatterGetStyle(formatter: &CFNumberFormatter) -> CFNumberFormatterStyle;
118        }
119        unsafe { CFNumberFormatterGetStyle(self) }
120    }
121
122    #[doc(alias = "CFNumberFormatterGetFormat")]
123    #[inline]
124    pub unsafe fn format(self: &CFNumberFormatter) -> Option<CFRetained<CFString>> {
125        extern "C-unwind" {
126            fn CFNumberFormatterGetFormat(
127                formatter: &CFNumberFormatter,
128            ) -> Option<NonNull<CFString>>;
129        }
130        let ret = unsafe { CFNumberFormatterGetFormat(self) };
131        ret.map(|ret| unsafe { CFRetained::retain(ret) })
132    }
133
134    #[doc(alias = "CFNumberFormatterSetFormat")]
135    #[inline]
136    pub unsafe fn set_format(self: &CFNumberFormatter, format_string: Option<&CFString>) {
137        extern "C-unwind" {
138            fn CFNumberFormatterSetFormat(
139                formatter: &CFNumberFormatter,
140                format_string: Option<&CFString>,
141            );
142        }
143        unsafe { CFNumberFormatterSetFormat(self, format_string) }
144    }
145
146    #[doc(alias = "CFNumberFormatterCreateStringWithNumber")]
147    #[cfg(feature = "CFNumber")]
148    #[inline]
149    pub unsafe fn new_string_with_number(
150        allocator: Option<&CFAllocator>,
151        formatter: Option<&CFNumberFormatter>,
152        number: Option<&CFNumber>,
153    ) -> Option<CFRetained<CFString>> {
154        extern "C-unwind" {
155            fn CFNumberFormatterCreateStringWithNumber(
156                allocator: Option<&CFAllocator>,
157                formatter: Option<&CFNumberFormatter>,
158                number: Option<&CFNumber>,
159            ) -> Option<NonNull<CFString>>;
160        }
161        let ret = unsafe { CFNumberFormatterCreateStringWithNumber(allocator, formatter, number) };
162        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
163    }
164
165    #[doc(alias = "CFNumberFormatterCreateStringWithValue")]
166    #[cfg(feature = "CFNumber")]
167    #[inline]
168    pub unsafe fn new_string_with_value(
169        allocator: Option<&CFAllocator>,
170        formatter: Option<&CFNumberFormatter>,
171        number_type: CFNumberType,
172        value_ptr: *const c_void,
173    ) -> Option<CFRetained<CFString>> {
174        extern "C-unwind" {
175            fn CFNumberFormatterCreateStringWithValue(
176                allocator: Option<&CFAllocator>,
177                formatter: Option<&CFNumberFormatter>,
178                number_type: CFNumberType,
179                value_ptr: *const c_void,
180            ) -> Option<NonNull<CFString>>;
181        }
182        let ret = unsafe {
183            CFNumberFormatterCreateStringWithValue(allocator, formatter, number_type, value_ptr)
184        };
185        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
186    }
187}
188
189/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfnumberformatteroptionflags?language=objc)
190// NS_OPTIONS
191#[repr(transparent)]
192#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
193pub struct CFNumberFormatterOptionFlags(pub CFOptionFlags);
194bitflags::bitflags! {
195    impl CFNumberFormatterOptionFlags: CFOptionFlags {
196        #[doc(alias = "kCFNumberFormatterParseIntegersOnly")]
197        const ParseIntegersOnly = 1;
198    }
199}
200
201#[cfg(feature = "objc2")]
202unsafe impl Encode for CFNumberFormatterOptionFlags {
203    const ENCODING: Encoding = CFOptionFlags::ENCODING;
204}
205
206#[cfg(feature = "objc2")]
207unsafe impl RefEncode for CFNumberFormatterOptionFlags {
208    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
209}
210
211impl CFNumberFormatter {
212    #[doc(alias = "CFNumberFormatterCreateNumberFromString")]
213    #[cfg(feature = "CFNumber")]
214    #[inline]
215    pub unsafe fn new_number_from_string(
216        allocator: Option<&CFAllocator>,
217        formatter: Option<&CFNumberFormatter>,
218        string: Option<&CFString>,
219        rangep: *mut CFRange,
220        options: CFOptionFlags,
221    ) -> Option<CFRetained<CFNumber>> {
222        extern "C-unwind" {
223            fn CFNumberFormatterCreateNumberFromString(
224                allocator: Option<&CFAllocator>,
225                formatter: Option<&CFNumberFormatter>,
226                string: Option<&CFString>,
227                rangep: *mut CFRange,
228                options: CFOptionFlags,
229            ) -> Option<NonNull<CFNumber>>;
230        }
231        let ret = unsafe {
232            CFNumberFormatterCreateNumberFromString(allocator, formatter, string, rangep, options)
233        };
234        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
235    }
236
237    #[doc(alias = "CFNumberFormatterGetValueFromString")]
238    #[cfg(feature = "CFNumber")]
239    #[inline]
240    pub unsafe fn value_from_string(
241        self: &CFNumberFormatter,
242        string: Option<&CFString>,
243        rangep: *mut CFRange,
244        number_type: CFNumberType,
245        value_ptr: *mut c_void,
246    ) -> bool {
247        extern "C-unwind" {
248            fn CFNumberFormatterGetValueFromString(
249                formatter: &CFNumberFormatter,
250                string: Option<&CFString>,
251                rangep: *mut CFRange,
252                number_type: CFNumberType,
253                value_ptr: *mut c_void,
254            ) -> Boolean;
255        }
256        let ret = unsafe {
257            CFNumberFormatterGetValueFromString(self, string, rangep, number_type, value_ptr)
258        };
259        ret != 0
260    }
261
262    #[doc(alias = "CFNumberFormatterSetProperty")]
263    #[inline]
264    pub unsafe fn set_property(
265        self: &CFNumberFormatter,
266        key: Option<&CFNumberFormatterKey>,
267        value: Option<&CFType>,
268    ) {
269        extern "C-unwind" {
270            fn CFNumberFormatterSetProperty(
271                formatter: &CFNumberFormatter,
272                key: Option<&CFNumberFormatterKey>,
273                value: Option<&CFType>,
274            );
275        }
276        unsafe { CFNumberFormatterSetProperty(self, key, value) }
277    }
278
279    #[doc(alias = "CFNumberFormatterCopyProperty")]
280    #[inline]
281    pub unsafe fn property(
282        self: &CFNumberFormatter,
283        key: Option<&CFNumberFormatterKey>,
284    ) -> Option<CFRetained<CFType>> {
285        extern "C-unwind" {
286            fn CFNumberFormatterCopyProperty(
287                formatter: &CFNumberFormatter,
288                key: Option<&CFNumberFormatterKey>,
289            ) -> Option<NonNull<CFType>>;
290        }
291        let ret = unsafe { CFNumberFormatterCopyProperty(self, key) };
292        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
293    }
294}
295
296extern "C" {
297    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformattercurrencycode?language=objc)
298    pub static kCFNumberFormatterCurrencyCode: Option<&'static CFNumberFormatterKey>;
299}
300
301extern "C" {
302    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatterdecimalseparator?language=objc)
303    pub static kCFNumberFormatterDecimalSeparator: Option<&'static CFNumberFormatterKey>;
304}
305
306extern "C" {
307    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformattercurrencydecimalseparator?language=objc)
308    pub static kCFNumberFormatterCurrencyDecimalSeparator: Option<&'static CFNumberFormatterKey>;
309}
310
311extern "C" {
312    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatteralwaysshowdecimalseparator?language=objc)
313    pub static kCFNumberFormatterAlwaysShowDecimalSeparator: Option<&'static CFNumberFormatterKey>;
314}
315
316extern "C" {
317    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformattergroupingseparator?language=objc)
318    pub static kCFNumberFormatterGroupingSeparator: Option<&'static CFNumberFormatterKey>;
319}
320
321extern "C" {
322    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatterusegroupingseparator?language=objc)
323    pub static kCFNumberFormatterUseGroupingSeparator: Option<&'static CFNumberFormatterKey>;
324}
325
326extern "C" {
327    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatterpercentsymbol?language=objc)
328    pub static kCFNumberFormatterPercentSymbol: Option<&'static CFNumberFormatterKey>;
329}
330
331extern "C" {
332    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatterzerosymbol?language=objc)
333    pub static kCFNumberFormatterZeroSymbol: Option<&'static CFNumberFormatterKey>;
334}
335
336extern "C" {
337    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatternansymbol?language=objc)
338    pub static kCFNumberFormatterNaNSymbol: Option<&'static CFNumberFormatterKey>;
339}
340
341extern "C" {
342    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatterinfinitysymbol?language=objc)
343    pub static kCFNumberFormatterInfinitySymbol: Option<&'static CFNumberFormatterKey>;
344}
345
346extern "C" {
347    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatterminussign?language=objc)
348    pub static kCFNumberFormatterMinusSign: Option<&'static CFNumberFormatterKey>;
349}
350
351extern "C" {
352    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatterplussign?language=objc)
353    pub static kCFNumberFormatterPlusSign: Option<&'static CFNumberFormatterKey>;
354}
355
356extern "C" {
357    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformattercurrencysymbol?language=objc)
358    pub static kCFNumberFormatterCurrencySymbol: Option<&'static CFNumberFormatterKey>;
359}
360
361extern "C" {
362    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatterexponentsymbol?language=objc)
363    pub static kCFNumberFormatterExponentSymbol: Option<&'static CFNumberFormatterKey>;
364}
365
366extern "C" {
367    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatterminintegerdigits?language=objc)
368    pub static kCFNumberFormatterMinIntegerDigits: Option<&'static CFNumberFormatterKey>;
369}
370
371extern "C" {
372    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformattermaxintegerdigits?language=objc)
373    pub static kCFNumberFormatterMaxIntegerDigits: Option<&'static CFNumberFormatterKey>;
374}
375
376extern "C" {
377    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatterminfractiondigits?language=objc)
378    pub static kCFNumberFormatterMinFractionDigits: Option<&'static CFNumberFormatterKey>;
379}
380
381extern "C" {
382    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformattermaxfractiondigits?language=objc)
383    pub static kCFNumberFormatterMaxFractionDigits: Option<&'static CFNumberFormatterKey>;
384}
385
386extern "C" {
387    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformattergroupingsize?language=objc)
388    pub static kCFNumberFormatterGroupingSize: Option<&'static CFNumberFormatterKey>;
389}
390
391extern "C" {
392    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformattersecondarygroupingsize?language=objc)
393    pub static kCFNumberFormatterSecondaryGroupingSize: Option<&'static CFNumberFormatterKey>;
394}
395
396extern "C" {
397    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatterroundingmode?language=objc)
398    pub static kCFNumberFormatterRoundingMode: Option<&'static CFNumberFormatterKey>;
399}
400
401extern "C" {
402    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatterroundingincrement?language=objc)
403    pub static kCFNumberFormatterRoundingIncrement: Option<&'static CFNumberFormatterKey>;
404}
405
406extern "C" {
407    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatterformatwidth?language=objc)
408    pub static kCFNumberFormatterFormatWidth: Option<&'static CFNumberFormatterKey>;
409}
410
411extern "C" {
412    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatterpaddingposition?language=objc)
413    pub static kCFNumberFormatterPaddingPosition: Option<&'static CFNumberFormatterKey>;
414}
415
416extern "C" {
417    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatterpaddingcharacter?language=objc)
418    pub static kCFNumberFormatterPaddingCharacter: Option<&'static CFNumberFormatterKey>;
419}
420
421extern "C" {
422    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatterdefaultformat?language=objc)
423    pub static kCFNumberFormatterDefaultFormat: Option<&'static CFNumberFormatterKey>;
424}
425
426extern "C" {
427    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformattermultiplier?language=objc)
428    pub static kCFNumberFormatterMultiplier: Option<&'static CFNumberFormatterKey>;
429}
430
431extern "C" {
432    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatterpositiveprefix?language=objc)
433    pub static kCFNumberFormatterPositivePrefix: Option<&'static CFNumberFormatterKey>;
434}
435
436extern "C" {
437    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatterpositivesuffix?language=objc)
438    pub static kCFNumberFormatterPositiveSuffix: Option<&'static CFNumberFormatterKey>;
439}
440
441extern "C" {
442    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatternegativeprefix?language=objc)
443    pub static kCFNumberFormatterNegativePrefix: Option<&'static CFNumberFormatterKey>;
444}
445
446extern "C" {
447    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatternegativesuffix?language=objc)
448    pub static kCFNumberFormatterNegativeSuffix: Option<&'static CFNumberFormatterKey>;
449}
450
451extern "C" {
452    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatterpermillsymbol?language=objc)
453    pub static kCFNumberFormatterPerMillSymbol: Option<&'static CFNumberFormatterKey>;
454}
455
456extern "C" {
457    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatterinternationalcurrencysymbol?language=objc)
458    pub static kCFNumberFormatterInternationalCurrencySymbol: Option<&'static CFNumberFormatterKey>;
459}
460
461extern "C" {
462    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformattercurrencygroupingseparator?language=objc)
463    pub static kCFNumberFormatterCurrencyGroupingSeparator: Option<&'static CFNumberFormatterKey>;
464}
465
466extern "C" {
467    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatterislenient?language=objc)
468    pub static kCFNumberFormatterIsLenient: Option<&'static CFNumberFormatterKey>;
469}
470
471extern "C" {
472    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatterusesignificantdigits?language=objc)
473    pub static kCFNumberFormatterUseSignificantDigits: Option<&'static CFNumberFormatterKey>;
474}
475
476extern "C" {
477    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformatterminsignificantdigits?language=objc)
478    pub static kCFNumberFormatterMinSignificantDigits: Option<&'static CFNumberFormatterKey>;
479}
480
481extern "C" {
482    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformattermaxsignificantdigits?language=objc)
483    pub static kCFNumberFormatterMaxSignificantDigits: Option<&'static CFNumberFormatterKey>;
484}
485
486extern "C" {
487    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfnumberformattermingroupingdigits?language=objc)
488    pub static kCFNumberFormatterMinGroupingDigits: Option<&'static CFNumberFormatterKey>;
489}
490
491/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfnumberformatterroundingmode?language=objc)
492// NS_ENUM
493#[repr(transparent)]
494#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
495pub struct CFNumberFormatterRoundingMode(pub CFIndex);
496impl CFNumberFormatterRoundingMode {
497    #[doc(alias = "kCFNumberFormatterRoundCeiling")]
498    pub const RoundCeiling: Self = Self(0);
499    #[doc(alias = "kCFNumberFormatterRoundFloor")]
500    pub const RoundFloor: Self = Self(1);
501    #[doc(alias = "kCFNumberFormatterRoundDown")]
502    pub const RoundDown: Self = Self(2);
503    #[doc(alias = "kCFNumberFormatterRoundUp")]
504    pub const RoundUp: Self = Self(3);
505    #[doc(alias = "kCFNumberFormatterRoundHalfEven")]
506    pub const RoundHalfEven: Self = Self(4);
507    #[doc(alias = "kCFNumberFormatterRoundHalfDown")]
508    pub const RoundHalfDown: Self = Self(5);
509    #[doc(alias = "kCFNumberFormatterRoundHalfUp")]
510    pub const RoundHalfUp: Self = Self(6);
511}
512
513#[cfg(feature = "objc2")]
514unsafe impl Encode for CFNumberFormatterRoundingMode {
515    const ENCODING: Encoding = CFIndex::ENCODING;
516}
517
518#[cfg(feature = "objc2")]
519unsafe impl RefEncode for CFNumberFormatterRoundingMode {
520    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
521}
522
523/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfnumberformatterpadposition?language=objc)
524// NS_ENUM
525#[repr(transparent)]
526#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
527pub struct CFNumberFormatterPadPosition(pub CFIndex);
528impl CFNumberFormatterPadPosition {
529    #[doc(alias = "kCFNumberFormatterPadBeforePrefix")]
530    pub const BeforePrefix: Self = Self(0);
531    #[doc(alias = "kCFNumberFormatterPadAfterPrefix")]
532    pub const AfterPrefix: Self = Self(1);
533    #[doc(alias = "kCFNumberFormatterPadBeforeSuffix")]
534    pub const BeforeSuffix: Self = Self(2);
535    #[doc(alias = "kCFNumberFormatterPadAfterSuffix")]
536    pub const AfterSuffix: Self = Self(3);
537}
538
539#[cfg(feature = "objc2")]
540unsafe impl Encode for CFNumberFormatterPadPosition {
541    const ENCODING: Encoding = CFIndex::ENCODING;
542}
543
544#[cfg(feature = "objc2")]
545unsafe impl RefEncode for CFNumberFormatterPadPosition {
546    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
547}
548
549impl CFNumberFormatter {
550    #[doc(alias = "CFNumberFormatterGetDecimalInfoForCurrencyCode")]
551    #[inline]
552    pub unsafe fn decimal_info_for_currency_code(
553        currency_code: Option<&CFString>,
554        default_fraction_digits: *mut i32,
555        rounding_increment: *mut c_double,
556    ) -> bool {
557        extern "C-unwind" {
558            fn CFNumberFormatterGetDecimalInfoForCurrencyCode(
559                currency_code: Option<&CFString>,
560                default_fraction_digits: *mut i32,
561                rounding_increment: *mut c_double,
562            ) -> Boolean;
563        }
564        let ret = unsafe {
565            CFNumberFormatterGetDecimalInfoForCurrencyCode(
566                currency_code,
567                default_fraction_digits,
568                rounding_increment,
569            )
570        };
571        ret != 0
572    }
573}
574
575#[cfg(feature = "CFLocale")]
576#[deprecated = "renamed to `CFNumberFormatter::new`"]
577#[inline]
578pub unsafe extern "C-unwind" fn CFNumberFormatterCreate(
579    allocator: Option<&CFAllocator>,
580    locale: Option<&CFLocale>,
581    style: CFNumberFormatterStyle,
582) -> Option<CFRetained<CFNumberFormatter>> {
583    extern "C-unwind" {
584        fn CFNumberFormatterCreate(
585            allocator: Option<&CFAllocator>,
586            locale: Option<&CFLocale>,
587            style: CFNumberFormatterStyle,
588        ) -> Option<NonNull<CFNumberFormatter>>;
589    }
590    let ret = unsafe { CFNumberFormatterCreate(allocator, locale, style) };
591    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
592}
593
594#[cfg(feature = "CFLocale")]
595#[deprecated = "renamed to `CFNumberFormatter::locale`"]
596#[inline]
597pub unsafe extern "C-unwind" fn CFNumberFormatterGetLocale(
598    formatter: &CFNumberFormatter,
599) -> Option<CFRetained<CFLocale>> {
600    extern "C-unwind" {
601        fn CFNumberFormatterGetLocale(formatter: &CFNumberFormatter) -> Option<NonNull<CFLocale>>;
602    }
603    let ret = unsafe { CFNumberFormatterGetLocale(formatter) };
604    ret.map(|ret| unsafe { CFRetained::retain(ret) })
605}
606
607extern "C-unwind" {
608    #[deprecated = "renamed to `CFNumberFormatter::style`"]
609    pub fn CFNumberFormatterGetStyle(formatter: &CFNumberFormatter) -> CFNumberFormatterStyle;
610}
611
612#[deprecated = "renamed to `CFNumberFormatter::format`"]
613#[inline]
614pub unsafe extern "C-unwind" fn CFNumberFormatterGetFormat(
615    formatter: &CFNumberFormatter,
616) -> Option<CFRetained<CFString>> {
617    extern "C-unwind" {
618        fn CFNumberFormatterGetFormat(formatter: &CFNumberFormatter) -> Option<NonNull<CFString>>;
619    }
620    let ret = unsafe { CFNumberFormatterGetFormat(formatter) };
621    ret.map(|ret| unsafe { CFRetained::retain(ret) })
622}
623
624extern "C-unwind" {
625    #[deprecated = "renamed to `CFNumberFormatter::set_format`"]
626    pub fn CFNumberFormatterSetFormat(
627        formatter: &CFNumberFormatter,
628        format_string: Option<&CFString>,
629    );
630}
631
632#[cfg(feature = "CFNumber")]
633#[deprecated = "renamed to `CFNumberFormatter::new_string_with_number`"]
634#[inline]
635pub unsafe extern "C-unwind" fn CFNumberFormatterCreateStringWithNumber(
636    allocator: Option<&CFAllocator>,
637    formatter: Option<&CFNumberFormatter>,
638    number: Option<&CFNumber>,
639) -> Option<CFRetained<CFString>> {
640    extern "C-unwind" {
641        fn CFNumberFormatterCreateStringWithNumber(
642            allocator: Option<&CFAllocator>,
643            formatter: Option<&CFNumberFormatter>,
644            number: Option<&CFNumber>,
645        ) -> Option<NonNull<CFString>>;
646    }
647    let ret = unsafe { CFNumberFormatterCreateStringWithNumber(allocator, formatter, number) };
648    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
649}
650
651#[cfg(feature = "CFNumber")]
652#[deprecated = "renamed to `CFNumberFormatter::new_string_with_value`"]
653#[inline]
654pub unsafe extern "C-unwind" fn CFNumberFormatterCreateStringWithValue(
655    allocator: Option<&CFAllocator>,
656    formatter: Option<&CFNumberFormatter>,
657    number_type: CFNumberType,
658    value_ptr: *const c_void,
659) -> Option<CFRetained<CFString>> {
660    extern "C-unwind" {
661        fn CFNumberFormatterCreateStringWithValue(
662            allocator: Option<&CFAllocator>,
663            formatter: Option<&CFNumberFormatter>,
664            number_type: CFNumberType,
665            value_ptr: *const c_void,
666        ) -> Option<NonNull<CFString>>;
667    }
668    let ret = unsafe {
669        CFNumberFormatterCreateStringWithValue(allocator, formatter, number_type, value_ptr)
670    };
671    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
672}
673
674#[cfg(feature = "CFNumber")]
675#[deprecated = "renamed to `CFNumberFormatter::new_number_from_string`"]
676#[inline]
677pub unsafe extern "C-unwind" fn CFNumberFormatterCreateNumberFromString(
678    allocator: Option<&CFAllocator>,
679    formatter: Option<&CFNumberFormatter>,
680    string: Option<&CFString>,
681    rangep: *mut CFRange,
682    options: CFOptionFlags,
683) -> Option<CFRetained<CFNumber>> {
684    extern "C-unwind" {
685        fn CFNumberFormatterCreateNumberFromString(
686            allocator: Option<&CFAllocator>,
687            formatter: Option<&CFNumberFormatter>,
688            string: Option<&CFString>,
689            rangep: *mut CFRange,
690            options: CFOptionFlags,
691        ) -> Option<NonNull<CFNumber>>;
692    }
693    let ret = unsafe {
694        CFNumberFormatterCreateNumberFromString(allocator, formatter, string, rangep, options)
695    };
696    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
697}
698
699#[cfg(feature = "CFNumber")]
700#[deprecated = "renamed to `CFNumberFormatter::value_from_string`"]
701#[inline]
702pub unsafe extern "C-unwind" fn CFNumberFormatterGetValueFromString(
703    formatter: &CFNumberFormatter,
704    string: Option<&CFString>,
705    rangep: *mut CFRange,
706    number_type: CFNumberType,
707    value_ptr: *mut c_void,
708) -> bool {
709    extern "C-unwind" {
710        fn CFNumberFormatterGetValueFromString(
711            formatter: &CFNumberFormatter,
712            string: Option<&CFString>,
713            rangep: *mut CFRange,
714            number_type: CFNumberType,
715            value_ptr: *mut c_void,
716        ) -> Boolean;
717    }
718    let ret = unsafe {
719        CFNumberFormatterGetValueFromString(formatter, string, rangep, number_type, value_ptr)
720    };
721    ret != 0
722}
723
724extern "C-unwind" {
725    #[deprecated = "renamed to `CFNumberFormatter::set_property`"]
726    pub fn CFNumberFormatterSetProperty(
727        formatter: &CFNumberFormatter,
728        key: Option<&CFNumberFormatterKey>,
729        value: Option<&CFType>,
730    );
731}
732
733#[deprecated = "renamed to `CFNumberFormatter::property`"]
734#[inline]
735pub unsafe extern "C-unwind" fn CFNumberFormatterCopyProperty(
736    formatter: &CFNumberFormatter,
737    key: Option<&CFNumberFormatterKey>,
738) -> Option<CFRetained<CFType>> {
739    extern "C-unwind" {
740        fn CFNumberFormatterCopyProperty(
741            formatter: &CFNumberFormatter,
742            key: Option<&CFNumberFormatterKey>,
743        ) -> Option<NonNull<CFType>>;
744    }
745    let ret = unsafe { CFNumberFormatterCopyProperty(formatter, key) };
746    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
747}
748
749#[deprecated = "renamed to `CFNumberFormatter::decimal_info_for_currency_code`"]
750#[inline]
751pub unsafe extern "C-unwind" fn CFNumberFormatterGetDecimalInfoForCurrencyCode(
752    currency_code: Option<&CFString>,
753    default_fraction_digits: *mut i32,
754    rounding_increment: *mut c_double,
755) -> bool {
756    extern "C-unwind" {
757        fn CFNumberFormatterGetDecimalInfoForCurrencyCode(
758            currency_code: Option<&CFString>,
759            default_fraction_digits: *mut i32,
760            rounding_increment: *mut c_double,
761        ) -> Boolean;
762    }
763    let ret = unsafe {
764        CFNumberFormatterGetDecimalInfoForCurrencyCode(
765            currency_code,
766            default_fraction_digits,
767            rounding_increment,
768        )
769    };
770    ret != 0
771}