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