objc2_core_foundation/generated/
CFNumberFormatter.rs1use 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#[cfg(feature = "CFBase")]
15pub type CFNumberFormatterKey = CFString;
16
17#[repr(C)]
19pub struct CFNumberFormatter {
20 inner: [u8; 0],
21 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
22}
23
24cf_type!(
25 #[encoding_name = "__CFNumberFormatter"]
26 unsafe impl CFNumberFormatter {}
27);
28
29#[cfg(feature = "CFBase")]
30unsafe impl ConcreteType for CFNumberFormatter {
31 #[doc(alias = "CFNumberFormatterGetTypeID")]
32 #[inline]
33 fn type_id() -> CFTypeID {
34 extern "C-unwind" {
35 fn CFNumberFormatterGetTypeID() -> CFTypeID;
36 }
37 unsafe { CFNumberFormatterGetTypeID() }
38 }
39}
40
41#[cfg(feature = "CFBase")]
44#[repr(transparent)]
45#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
46pub struct CFNumberFormatterStyle(pub CFIndex);
47#[cfg(feature = "CFBase")]
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(all(feature = "CFBase", feature = "objc2"))]
72unsafe impl Encode for CFNumberFormatterStyle {
73 const ENCODING: Encoding = CFIndex::ENCODING;
74}
75
76#[cfg(all(feature = "CFBase", feature = "objc2"))]
77unsafe impl RefEncode for CFNumberFormatterStyle {
78 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
79}
80
81#[cfg(all(feature = "CFBase", feature = "CFLocale"))]
82#[inline]
83pub unsafe extern "C-unwind" fn CFNumberFormatterCreate(
84 allocator: Option<&CFAllocator>,
85 locale: Option<&CFLocale>,
86 style: CFNumberFormatterStyle,
87) -> Option<CFRetained<CFNumberFormatter>> {
88 extern "C-unwind" {
89 fn CFNumberFormatterCreate(
90 allocator: Option<&CFAllocator>,
91 locale: Option<&CFLocale>,
92 style: CFNumberFormatterStyle,
93 ) -> Option<NonNull<CFNumberFormatter>>;
94 }
95 let ret = unsafe { CFNumberFormatterCreate(allocator, locale, style) };
96 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
97}
98
99#[cfg(feature = "CFLocale")]
100#[inline]
101pub unsafe extern "C-unwind" fn CFNumberFormatterGetLocale(
102 formatter: &CFNumberFormatter,
103) -> Option<CFRetained<CFLocale>> {
104 extern "C-unwind" {
105 fn CFNumberFormatterGetLocale(formatter: &CFNumberFormatter) -> Option<NonNull<CFLocale>>;
106 }
107 let ret = unsafe { CFNumberFormatterGetLocale(formatter) };
108 ret.map(|ret| unsafe { CFRetained::retain(ret) })
109}
110
111extern "C-unwind" {
112 #[cfg(feature = "CFBase")]
113 pub fn CFNumberFormatterGetStyle(formatter: &CFNumberFormatter) -> CFNumberFormatterStyle;
114}
115
116#[cfg(feature = "CFBase")]
117#[inline]
118pub unsafe extern "C-unwind" fn CFNumberFormatterGetFormat(
119 formatter: &CFNumberFormatter,
120) -> Option<CFRetained<CFString>> {
121 extern "C-unwind" {
122 fn CFNumberFormatterGetFormat(formatter: &CFNumberFormatter) -> Option<NonNull<CFString>>;
123 }
124 let ret = unsafe { CFNumberFormatterGetFormat(formatter) };
125 ret.map(|ret| unsafe { CFRetained::retain(ret) })
126}
127
128extern "C-unwind" {
129 #[cfg(feature = "CFBase")]
130 pub fn CFNumberFormatterSetFormat(
131 formatter: &CFNumberFormatter,
132 format_string: Option<&CFString>,
133 );
134}
135
136#[cfg(all(feature = "CFBase", feature = "CFNumber"))]
137#[inline]
138pub unsafe extern "C-unwind" fn CFNumberFormatterCreateStringWithNumber(
139 allocator: Option<&CFAllocator>,
140 formatter: Option<&CFNumberFormatter>,
141 number: Option<&CFNumber>,
142) -> Option<CFRetained<CFString>> {
143 extern "C-unwind" {
144 fn CFNumberFormatterCreateStringWithNumber(
145 allocator: Option<&CFAllocator>,
146 formatter: Option<&CFNumberFormatter>,
147 number: Option<&CFNumber>,
148 ) -> Option<NonNull<CFString>>;
149 }
150 let ret = unsafe { CFNumberFormatterCreateStringWithNumber(allocator, formatter, number) };
151 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
152}
153
154#[cfg(all(feature = "CFBase", feature = "CFNumber"))]
155#[inline]
156pub unsafe extern "C-unwind" fn CFNumberFormatterCreateStringWithValue(
157 allocator: Option<&CFAllocator>,
158 formatter: Option<&CFNumberFormatter>,
159 number_type: CFNumberType,
160 value_ptr: *const c_void,
161) -> Option<CFRetained<CFString>> {
162 extern "C-unwind" {
163 fn CFNumberFormatterCreateStringWithValue(
164 allocator: Option<&CFAllocator>,
165 formatter: Option<&CFNumberFormatter>,
166 number_type: CFNumberType,
167 value_ptr: *const c_void,
168 ) -> Option<NonNull<CFString>>;
169 }
170 let ret = unsafe {
171 CFNumberFormatterCreateStringWithValue(allocator, formatter, number_type, value_ptr)
172 };
173 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
174}
175
176#[cfg(feature = "CFBase")]
179#[repr(transparent)]
180#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
181pub struct CFNumberFormatterOptionFlags(pub CFOptionFlags);
182#[cfg(feature = "CFBase")]
183bitflags::bitflags! {
184 impl CFNumberFormatterOptionFlags: CFOptionFlags {
185 #[doc(alias = "kCFNumberFormatterParseIntegersOnly")]
186 const ParseIntegersOnly = 1;
187 }
188}
189
190#[cfg(all(feature = "CFBase", feature = "objc2"))]
191unsafe impl Encode for CFNumberFormatterOptionFlags {
192 const ENCODING: Encoding = CFOptionFlags::ENCODING;
193}
194
195#[cfg(all(feature = "CFBase", feature = "objc2"))]
196unsafe impl RefEncode for CFNumberFormatterOptionFlags {
197 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
198}
199
200#[cfg(all(feature = "CFBase", feature = "CFNumber"))]
201#[inline]
202pub unsafe extern "C-unwind" fn CFNumberFormatterCreateNumberFromString(
203 allocator: Option<&CFAllocator>,
204 formatter: Option<&CFNumberFormatter>,
205 string: Option<&CFString>,
206 rangep: *mut CFRange,
207 options: CFOptionFlags,
208) -> Option<CFRetained<CFNumber>> {
209 extern "C-unwind" {
210 fn CFNumberFormatterCreateNumberFromString(
211 allocator: Option<&CFAllocator>,
212 formatter: Option<&CFNumberFormatter>,
213 string: Option<&CFString>,
214 rangep: *mut CFRange,
215 options: CFOptionFlags,
216 ) -> Option<NonNull<CFNumber>>;
217 }
218 let ret = unsafe {
219 CFNumberFormatterCreateNumberFromString(allocator, formatter, string, rangep, options)
220 };
221 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
222}
223
224#[cfg(all(feature = "CFBase", feature = "CFNumber"))]
225#[inline]
226pub unsafe extern "C-unwind" fn CFNumberFormatterGetValueFromString(
227 formatter: &CFNumberFormatter,
228 string: Option<&CFString>,
229 rangep: *mut CFRange,
230 number_type: CFNumberType,
231 value_ptr: *mut c_void,
232) -> bool {
233 extern "C-unwind" {
234 fn CFNumberFormatterGetValueFromString(
235 formatter: &CFNumberFormatter,
236 string: Option<&CFString>,
237 rangep: *mut CFRange,
238 number_type: CFNumberType,
239 value_ptr: *mut c_void,
240 ) -> Boolean;
241 }
242 let ret = unsafe {
243 CFNumberFormatterGetValueFromString(formatter, string, rangep, number_type, value_ptr)
244 };
245 ret != 0
246}
247
248extern "C-unwind" {
249 #[cfg(feature = "CFBase")]
250 pub fn CFNumberFormatterSetProperty(
251 formatter: &CFNumberFormatter,
252 key: Option<&CFNumberFormatterKey>,
253 value: Option<&CFType>,
254 );
255}
256
257#[cfg(feature = "CFBase")]
258#[inline]
259pub unsafe extern "C-unwind" fn CFNumberFormatterCopyProperty(
260 formatter: &CFNumberFormatter,
261 key: Option<&CFNumberFormatterKey>,
262) -> Option<CFRetained<CFType>> {
263 extern "C-unwind" {
264 fn CFNumberFormatterCopyProperty(
265 formatter: &CFNumberFormatter,
266 key: Option<&CFNumberFormatterKey>,
267 ) -> Option<NonNull<CFType>>;
268 }
269 let ret = unsafe { CFNumberFormatterCopyProperty(formatter, key) };
270 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
271}
272
273extern "C" {
274 #[cfg(feature = "CFBase")]
276 pub static kCFNumberFormatterCurrencyCode: Option<&'static CFNumberFormatterKey>;
277}
278
279extern "C" {
280 #[cfg(feature = "CFBase")]
282 pub static kCFNumberFormatterDecimalSeparator: Option<&'static CFNumberFormatterKey>;
283}
284
285extern "C" {
286 #[cfg(feature = "CFBase")]
288 pub static kCFNumberFormatterCurrencyDecimalSeparator: Option<&'static CFNumberFormatterKey>;
289}
290
291extern "C" {
292 #[cfg(feature = "CFBase")]
294 pub static kCFNumberFormatterAlwaysShowDecimalSeparator: Option<&'static CFNumberFormatterKey>;
295}
296
297extern "C" {
298 #[cfg(feature = "CFBase")]
300 pub static kCFNumberFormatterGroupingSeparator: Option<&'static CFNumberFormatterKey>;
301}
302
303extern "C" {
304 #[cfg(feature = "CFBase")]
306 pub static kCFNumberFormatterUseGroupingSeparator: Option<&'static CFNumberFormatterKey>;
307}
308
309extern "C" {
310 #[cfg(feature = "CFBase")]
312 pub static kCFNumberFormatterPercentSymbol: Option<&'static CFNumberFormatterKey>;
313}
314
315extern "C" {
316 #[cfg(feature = "CFBase")]
318 pub static kCFNumberFormatterZeroSymbol: Option<&'static CFNumberFormatterKey>;
319}
320
321extern "C" {
322 #[cfg(feature = "CFBase")]
324 pub static kCFNumberFormatterNaNSymbol: Option<&'static CFNumberFormatterKey>;
325}
326
327extern "C" {
328 #[cfg(feature = "CFBase")]
330 pub static kCFNumberFormatterInfinitySymbol: Option<&'static CFNumberFormatterKey>;
331}
332
333extern "C" {
334 #[cfg(feature = "CFBase")]
336 pub static kCFNumberFormatterMinusSign: Option<&'static CFNumberFormatterKey>;
337}
338
339extern "C" {
340 #[cfg(feature = "CFBase")]
342 pub static kCFNumberFormatterPlusSign: Option<&'static CFNumberFormatterKey>;
343}
344
345extern "C" {
346 #[cfg(feature = "CFBase")]
348 pub static kCFNumberFormatterCurrencySymbol: Option<&'static CFNumberFormatterKey>;
349}
350
351extern "C" {
352 #[cfg(feature = "CFBase")]
354 pub static kCFNumberFormatterExponentSymbol: Option<&'static CFNumberFormatterKey>;
355}
356
357extern "C" {
358 #[cfg(feature = "CFBase")]
360 pub static kCFNumberFormatterMinIntegerDigits: Option<&'static CFNumberFormatterKey>;
361}
362
363extern "C" {
364 #[cfg(feature = "CFBase")]
366 pub static kCFNumberFormatterMaxIntegerDigits: Option<&'static CFNumberFormatterKey>;
367}
368
369extern "C" {
370 #[cfg(feature = "CFBase")]
372 pub static kCFNumberFormatterMinFractionDigits: Option<&'static CFNumberFormatterKey>;
373}
374
375extern "C" {
376 #[cfg(feature = "CFBase")]
378 pub static kCFNumberFormatterMaxFractionDigits: Option<&'static CFNumberFormatterKey>;
379}
380
381extern "C" {
382 #[cfg(feature = "CFBase")]
384 pub static kCFNumberFormatterGroupingSize: Option<&'static CFNumberFormatterKey>;
385}
386
387extern "C" {
388 #[cfg(feature = "CFBase")]
390 pub static kCFNumberFormatterSecondaryGroupingSize: Option<&'static CFNumberFormatterKey>;
391}
392
393extern "C" {
394 #[cfg(feature = "CFBase")]
396 pub static kCFNumberFormatterRoundingMode: Option<&'static CFNumberFormatterKey>;
397}
398
399extern "C" {
400 #[cfg(feature = "CFBase")]
402 pub static kCFNumberFormatterRoundingIncrement: Option<&'static CFNumberFormatterKey>;
403}
404
405extern "C" {
406 #[cfg(feature = "CFBase")]
408 pub static kCFNumberFormatterFormatWidth: Option<&'static CFNumberFormatterKey>;
409}
410
411extern "C" {
412 #[cfg(feature = "CFBase")]
414 pub static kCFNumberFormatterPaddingPosition: Option<&'static CFNumberFormatterKey>;
415}
416
417extern "C" {
418 #[cfg(feature = "CFBase")]
420 pub static kCFNumberFormatterPaddingCharacter: Option<&'static CFNumberFormatterKey>;
421}
422
423extern "C" {
424 #[cfg(feature = "CFBase")]
426 pub static kCFNumberFormatterDefaultFormat: Option<&'static CFNumberFormatterKey>;
427}
428
429extern "C" {
430 #[cfg(feature = "CFBase")]
432 pub static kCFNumberFormatterMultiplier: Option<&'static CFNumberFormatterKey>;
433}
434
435extern "C" {
436 #[cfg(feature = "CFBase")]
438 pub static kCFNumberFormatterPositivePrefix: Option<&'static CFNumberFormatterKey>;
439}
440
441extern "C" {
442 #[cfg(feature = "CFBase")]
444 pub static kCFNumberFormatterPositiveSuffix: Option<&'static CFNumberFormatterKey>;
445}
446
447extern "C" {
448 #[cfg(feature = "CFBase")]
450 pub static kCFNumberFormatterNegativePrefix: Option<&'static CFNumberFormatterKey>;
451}
452
453extern "C" {
454 #[cfg(feature = "CFBase")]
456 pub static kCFNumberFormatterNegativeSuffix: Option<&'static CFNumberFormatterKey>;
457}
458
459extern "C" {
460 #[cfg(feature = "CFBase")]
462 pub static kCFNumberFormatterPerMillSymbol: Option<&'static CFNumberFormatterKey>;
463}
464
465extern "C" {
466 #[cfg(feature = "CFBase")]
468 pub static kCFNumberFormatterInternationalCurrencySymbol: Option<&'static CFNumberFormatterKey>;
469}
470
471extern "C" {
472 #[cfg(feature = "CFBase")]
474 pub static kCFNumberFormatterCurrencyGroupingSeparator: Option<&'static CFNumberFormatterKey>;
475}
476
477extern "C" {
478 #[cfg(feature = "CFBase")]
480 pub static kCFNumberFormatterIsLenient: Option<&'static CFNumberFormatterKey>;
481}
482
483extern "C" {
484 #[cfg(feature = "CFBase")]
486 pub static kCFNumberFormatterUseSignificantDigits: Option<&'static CFNumberFormatterKey>;
487}
488
489extern "C" {
490 #[cfg(feature = "CFBase")]
492 pub static kCFNumberFormatterMinSignificantDigits: Option<&'static CFNumberFormatterKey>;
493}
494
495extern "C" {
496 #[cfg(feature = "CFBase")]
498 pub static kCFNumberFormatterMaxSignificantDigits: Option<&'static CFNumberFormatterKey>;
499}
500
501extern "C" {
502 #[cfg(feature = "CFBase")]
504 pub static kCFNumberFormatterMinGroupingDigits: Option<&'static CFNumberFormatterKey>;
505}
506
507#[cfg(feature = "CFBase")]
510#[repr(transparent)]
511#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
512pub struct CFNumberFormatterRoundingMode(pub CFIndex);
513#[cfg(feature = "CFBase")]
514impl CFNumberFormatterRoundingMode {
515 #[doc(alias = "kCFNumberFormatterRoundCeiling")]
516 pub const RoundCeiling: Self = Self(0);
517 #[doc(alias = "kCFNumberFormatterRoundFloor")]
518 pub const RoundFloor: Self = Self(1);
519 #[doc(alias = "kCFNumberFormatterRoundDown")]
520 pub const RoundDown: Self = Self(2);
521 #[doc(alias = "kCFNumberFormatterRoundUp")]
522 pub const RoundUp: Self = Self(3);
523 #[doc(alias = "kCFNumberFormatterRoundHalfEven")]
524 pub const RoundHalfEven: Self = Self(4);
525 #[doc(alias = "kCFNumberFormatterRoundHalfDown")]
526 pub const RoundHalfDown: Self = Self(5);
527 #[doc(alias = "kCFNumberFormatterRoundHalfUp")]
528 pub const RoundHalfUp: Self = Self(6);
529}
530
531#[cfg(all(feature = "CFBase", feature = "objc2"))]
532unsafe impl Encode for CFNumberFormatterRoundingMode {
533 const ENCODING: Encoding = CFIndex::ENCODING;
534}
535
536#[cfg(all(feature = "CFBase", feature = "objc2"))]
537unsafe impl RefEncode for CFNumberFormatterRoundingMode {
538 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
539}
540
541#[cfg(feature = "CFBase")]
544#[repr(transparent)]
545#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
546pub struct CFNumberFormatterPadPosition(pub CFIndex);
547#[cfg(feature = "CFBase")]
548impl CFNumberFormatterPadPosition {
549 #[doc(alias = "kCFNumberFormatterPadBeforePrefix")]
550 pub const BeforePrefix: Self = Self(0);
551 #[doc(alias = "kCFNumberFormatterPadAfterPrefix")]
552 pub const AfterPrefix: Self = Self(1);
553 #[doc(alias = "kCFNumberFormatterPadBeforeSuffix")]
554 pub const BeforeSuffix: Self = Self(2);
555 #[doc(alias = "kCFNumberFormatterPadAfterSuffix")]
556 pub const AfterSuffix: Self = Self(3);
557}
558
559#[cfg(all(feature = "CFBase", feature = "objc2"))]
560unsafe impl Encode for CFNumberFormatterPadPosition {
561 const ENCODING: Encoding = CFIndex::ENCODING;
562}
563
564#[cfg(all(feature = "CFBase", feature = "objc2"))]
565unsafe impl RefEncode for CFNumberFormatterPadPosition {
566 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
567}
568
569#[cfg(feature = "CFBase")]
570#[inline]
571pub unsafe extern "C-unwind" fn CFNumberFormatterGetDecimalInfoForCurrencyCode(
572 currency_code: Option<&CFString>,
573 default_fraction_digits: *mut i32,
574 rounding_increment: *mut c_double,
575) -> bool {
576 extern "C-unwind" {
577 fn CFNumberFormatterGetDecimalInfoForCurrencyCode(
578 currency_code: Option<&CFString>,
579 default_fraction_digits: *mut i32,
580 rounding_increment: *mut c_double,
581 ) -> Boolean;
582 }
583 let ret = unsafe {
584 CFNumberFormatterGetDecimalInfoForCurrencyCode(
585 currency_code,
586 default_fraction_digits,
587 rounding_increment,
588 )
589 };
590 ret != 0
591}