rust_macios/foundation/
ns_number_formatter.rs

1use objc::{msg_send, sel, sel_impl};
2
3use crate::{
4    object,
5    objective_c_runtime::{id, macros::interface_impl, traits::FromId},
6    utils::to_bool,
7};
8
9use super::{
10    INSFormatter, Int, NSAttributedString, NSDecimalNumberHandler, NSDictionary, NSError,
11    NSFormattingContext, NSLocale, NSNumber, NSNumberFormatterBehavior,
12    NSNumberFormatterPadPosition, NSNumberFormatterRoundingMode, NSNumberFormatterStyle, NSRange,
13    NSString, UInt,
14};
15
16object! {
17    /// A formatter that converts between numeric values and their textual
18    /// representations.
19    unsafe pub struct NSNumberFormatter;
20}
21
22impl INSFormatter for NSNumberFormatter {}
23
24#[interface_impl(NSFormatter)]
25impl NSNumberFormatter {
26    /* Configuring Formatter Behavior and Style
27     */
28
29    /// The formatter behavior of the receiver.
30    #[property]
31    pub fn formatter_behavior(&self) -> NSNumberFormatterBehavior {
32        unsafe { msg_send![self.m_self(), formatterBehavior] }
33    }
34
35    /// The formatter behavior of the receiver.
36    #[property]
37    pub fn set_formatter_behavior(&mut self, behavior: NSNumberFormatterBehavior) {
38        unsafe { msg_send![self.m_self(), setFormatterBehavior: behavior] }
39    }
40
41    /// Sets the default formatter behavior for new instances of
42    /// [`NSNumberFormatter`].
43    #[method]
44    pub fn set_default_formatter_behavior(behavior: NSNumberFormatterBehavior) {
45        unsafe { msg_send![Self::m_class(), setDefaultFormatterBehavior: behavior] }
46    }
47
48    /// Returns an [`NSNumberFormatterBehavior`] constant that indicates default
49    /// formatter behavior for new instances of NSNumberFormatter.
50    #[method]
51    pub fn default_formatter_behavior() -> NSNumberFormatterBehavior {
52        unsafe { msg_send![Self::m_class(), defaultFormatterBehavior] }
53    }
54
55    /// The number style used by the receiver.
56    #[property]
57    pub fn number_style(&self) -> NSNumberFormatterStyle {
58        unsafe { msg_send![self.m_self(), numberStyle] }
59    }
60
61    /// The number style used by the receiver.
62    #[property]
63    pub fn set_number_style(&mut self, style: NSNumberFormatterStyle) {
64        unsafe { msg_send![self.m_self(), setNumberStyle: style] }
65    }
66
67    /// Determines whether the receiver creates instances of [`super::NSDecimalNumber`]
68    /// when it converts strings to number objects.
69    #[property]
70    pub fn generates_decimal_numbers(&self) {
71        unsafe { msg_send![self.m_self(), generatesDecimalNumbers] }
72    }
73
74    /* Converting Between Numbers and Strings
75     */
76
77    /// Returns by reference a cell-content object after creating it from
78    /// a range of characters in a given string.
79    #[method]
80    pub fn get_object_value_for_string_range_error(
81        &self,
82        obj: id,
83        string: NSString,
84        rangep: NSRange,
85        error: NSError,
86    ) -> bool {
87        unsafe {
88            to_bool(
89                msg_send![self.m_self(), getObjectValue:obj forString:string range:rangep error: error],
90            )
91        }
92    }
93
94    /// Returns an [`NSNumber`] object created by parsing a given string.
95    #[method]
96    pub fn number_from_string(&self, string: NSString) -> NSNumber {
97        unsafe { NSNumber::from_id(msg_send![self.m_self(), numberFromString: string]) }
98    }
99
100    /// Returns a string containing the formatted value of the provided number
101    /// object.
102    #[method]
103    pub fn string_from_number(&self, number: NSNumber) -> NSString {
104        unsafe { NSString::from_id(msg_send![self.m_self(), stringFromNumber: number]) }
105    }
106
107    /// Returns a localized number string with the specified style.
108    #[method]
109    pub fn localized_string_from_number_number_style(
110        num: NSNumber,
111        nstyle: NSNumberFormatterStyle,
112    ) -> NSString {
113        unsafe {
114            NSString::from_id(
115                msg_send![Self::m_class(), localizedStringFromNumber: num numberStyle: nstyle],
116            )
117        }
118    }
119
120    /* Managing Localization of Numbers
121     */
122
123    /// Determines whether the dollar sign character ($), decimal separator
124    /// character (.), and thousand separator character (,) are converted to
125    /// appropriately localized characters as specified by the user’s
126    /// localization preference.
127    #[property]
128    pub fn localizes_format(&self) -> bool {
129        unsafe { to_bool(msg_send![self.m_self(), localizesFormat]) }
130    }
131
132    /// Sets whether the dollar sign character ($), decimal separator
133    /// character (.), and thousand separator character (,) are converted to
134    /// appropriately localized characters as specified by the user’s
135    /// localization preference.
136    #[property]
137    pub fn set_localizes_format(&mut self, localizes_format: bool) {
138        unsafe { msg_send![self.m_self(), setLocalizesFormat: localizes_format] }
139    }
140
141    /// The locale of the receiver.
142    #[property]
143    pub fn locale(&self) -> NSLocale {
144        unsafe { NSLocale::from_id(msg_send![self.m_self(), locale]) }
145    }
146
147    /// Sets the locale of the receiver.
148    #[property]
149    pub fn set_locale(&mut self, locale: NSLocale) {
150        unsafe { msg_send![self.m_self(), setLocale: locale] }
151    }
152
153    /* Configuring Rounding Behavior
154     */
155
156    /// The rounding behavior used by the receiver.
157    #[property]
158    pub fn rounding_behavior(&self) -> NSDecimalNumberHandler {
159        unsafe { NSDecimalNumberHandler::from_id(msg_send![self.m_self(), roundingBehavior]) }
160    }
161
162    /// Set the rounding behavior used by the receiver.
163    #[property]
164    pub fn set_rounding_behavior(&mut self, behavior: NSNumberFormatterBehavior) {
165        unsafe { msg_send![self.m_self(), setRoundingBehavior: behavior] }
166    }
167
168    /// The rounding increment used by the receiver.
169    #[property]
170    pub fn rounding_increment(&self) -> NSNumber {
171        unsafe { NSNumber::from_id(msg_send![self.m_self(), roundingIncrement]) }
172    }
173
174    /// The rounding increment used by the receiver.
175    #[property]
176    pub fn set_rounding_increment(&mut self, number: NSNumber) {
177        unsafe { msg_send![self.m_self(), setRoundingIncrement: number] }
178    }
179
180    /// The rounding mode used by the receiver.
181    #[property]
182    pub fn rounding_mode(&self) -> NSNumberFormatterRoundingMode {
183        unsafe { msg_send![self.m_self(), roundingMode] }
184    }
185
186    /// The rounding mode used by the receiver.
187    #[property]
188    pub fn set_rounding_mode(&mut self, mode: NSNumberFormatterRoundingMode) {
189        unsafe { msg_send![self.m_self(), setRoundingMode: mode] }
190    }
191
192    /* Configuring Integer and Fraction Digits
193     */
194
195    /// The minimum number of digits before the decimal separator.
196    #[property]
197    pub fn minimum_integer_digits(&self) -> UInt {
198        unsafe { msg_send![self.m_self(), minimumIntegerDigits] }
199    }
200
201    /// Sets the minimum number of digits before the decimal separator.
202    ///
203    /// # Example
204    ///
205    /// ```
206    /// use rust_macios::objective_c_runtime::traits::PNSObject;
207    /// use rust_macios::foundation::NSNumberFormatter;
208    ///
209    /// let mut number_formatter = NSNumberFormatter::m_new();
210    ///
211    /// number_formatter.set_minimum_integer_digits(0); // default
212    /// assert_eq!(number_formatter.string_from_number(123.into()), "123");
213    ///
214    /// number_formatter.set_minimum_integer_digits(5);
215    /// assert_eq!(number_formatter.string_from_number(123.into()), "00123");
216    /// ```
217    #[property]
218    pub fn set_minimum_integer_digits(&mut self, min: UInt) {
219        unsafe { msg_send![self.m_self(), setMinimumIntegerDigits: min] }
220    }
221
222    /// The maximum number of digits before the decimal separator.
223    #[property]
224    pub fn maximum_integer_digits(&self) -> UInt {
225        unsafe { msg_send![self.m_self(), maximumIntegerDigits] }
226    }
227
228    /// The maximum number of digits before the decimal separator.
229    ///
230    /// # Example
231    ///
232    /// ```
233    /// use rust_macios::objective_c_runtime::traits::PNSObject;
234    /// use rust_macios::foundation::NSNumberFormatter;
235    ///
236    /// let mut number_formatter = NSNumberFormatter::m_new();
237    ///
238    /// number_formatter.set_maximum_integer_digits(42); // default
239    /// assert_eq!(number_formatter.string_from_number(12345.into()), "12345");
240    ///
241    /// number_formatter.set_maximum_integer_digits(3);
242    /// assert_eq!(number_formatter.string_from_number(12345.into()), "345");
243    /// ```
244    #[property]
245    pub fn set_maximum_integer_digits(&mut self, max: UInt) {
246        unsafe { msg_send![self.m_self(), setMaximumIntegerDigits: max] }
247    }
248
249    /// The minimum number of digits after the decimal separator.
250    #[property]
251    pub fn minimum_fraction_digits(&self) -> UInt {
252        unsafe { msg_send![self.m_self(), minimumFractionDigits] }
253    }
254
255    /// Sets the minimum number of digits after the decimal separator.
256    ///
257    /// # Example
258    ///
259    /// ```
260    /// use rust_macios::objective_c_runtime::traits::PNSObject;
261    /// use rust_macios::foundation::NSNumberFormatter;
262    ///
263    /// let mut number_formatter = NSNumberFormatter::m_new();
264    ///
265    /// number_formatter.set_minimum_fraction_digits(0); // default
266    /// assert_eq!(number_formatter.string_from_number(123.456.into()), "123");
267    ///
268    /// number_formatter.set_minimum_fraction_digits(5);
269    /// assert_eq!(number_formatter.string_from_number(123.456.into()), "123.45600");
270    /// ```
271    #[property]
272    pub fn set_minimum_fraction_digits(&mut self, min: UInt) {
273        unsafe { msg_send![self.m_self(), setMinimumFractionDigits: min] }
274    }
275
276    /// The maximum number of digits after the decimal separator.
277    #[property]
278    pub fn maximum_fraction_digits(&self) -> UInt {
279        unsafe { msg_send![self.m_self(), maximumFractionDigits] }
280    }
281
282    /// Sets the maximum number of digits after the decimal separator.
283    ///
284    /// # Example
285    ///
286    /// ```
287    /// use rust_macios::objective_c_runtime::traits::PNSObject;
288    /// use rust_macios::foundation::NSNumberFormatter;
289    ///
290    /// let mut number_formatter = NSNumberFormatter::m_new();
291    ///
292    /// number_formatter.set_maximum_fraction_digits(0); // default
293    /// assert_eq!(number_formatter.string_from_number(123.456.into()), "123");
294    ///
295    /// number_formatter.set_maximum_fraction_digits(3);
296    /// assert_eq!(number_formatter.string_from_number(123.456789.into()), "123.457");
297    /// ```
298    #[property]
299    pub fn set_maximum_fraction_digits(&mut self, max: UInt) {
300        unsafe { msg_send![self.m_self(), setMaximumFractionDigits: max] }
301    }
302
303    /// A Boolean value indicating whether the formatter uses minimum and
304    /// maximum significant digits when formatting numbers.
305    #[property]
306    pub fn uses_significant_digits(&self) -> bool {
307        unsafe { to_bool(msg_send![self.m_self(), setUsesSignificantDigits]) }
308    }
309
310    /// A Boolean value indicating whether the formatter uses minimum and
311    /// maximum significant digits when formatting numbers.
312    ///
313    /// # Example
314    ///
315    /// ```
316    /// use rust_macios::objective_c_runtime::traits::PNSObject;
317    /// use rust_macios::foundation::NSNumberFormatter;
318    ///
319    /// let mut number_formatter = NSNumberFormatter::m_new();
320    ///
321    /// // Using significant digits
322    /// number_formatter.set_uses_significant_digits(true);
323    /// assert_eq!(number_formatter.string_from_number(12345678.into()), "12345700");
324    /// assert_eq!(number_formatter.string_from_number(1234.5678.into()), "1234.57");
325    /// assert_eq!(number_formatter.string_from_number(100.2345678.into()), "100.235");
326    /// assert_eq!(number_formatter.string_from_number(1.230000.into()), "1.23");
327    /// assert_eq!(number_formatter.string_from_number(0.00000123.into()), "0.00000123");
328    ///
329    /// // Using integer and fraction digits
330    /// number_formatter.set_uses_significant_digits(false);
331    /// assert_eq!(number_formatter.string_from_number(12345678.into()), "12345678");
332    /// assert_eq!(number_formatter.string_from_number(1234.5678.into()), "1235");
333    /// assert_eq!(number_formatter.string_from_number(100.2345678.into()), "100");
334    /// assert_eq!(number_formatter.string_from_number(1.230000.into()), "1");
335    /// assert_eq!(number_formatter.string_from_number(0.00000123.into()), "0");
336    /// ```
337    #[property]
338    pub fn set_uses_significant_digits(&mut self, uses: bool) {
339        unsafe { msg_send![self.m_self(), setUsesSignificantDigits: uses] }
340    }
341
342    /// The minimum number of significant digits for the number formatter.
343    #[property]
344    pub fn minimum_significant_digits(&self) -> UInt {
345        unsafe { msg_send![self.m_self(), minimumSignificantDigits] }
346    }
347
348    /// Sets the minimum number of significant digits for the number formatter.
349    #[property]
350    pub fn set_minimum_significant_digits(&self, min: UInt) {
351        unsafe { msg_send![self.m_self(), setMinimumSignificantDigits: min] }
352    }
353
354    /// The maximum number of significant digits for the number formatter.
355    #[property]
356    pub fn maximum_significant_digits(&self) -> UInt {
357        unsafe { msg_send![self.m_self(), maximumSignificantDigits] }
358    }
359
360    /// Sets the maximum number of significant digits for the number formatter.
361    #[property]
362    pub fn set_maximum_significant_digits(&self, max: UInt) {
363        unsafe { msg_send![self.m_self(), setMaximumSignificantDigits: max] }
364    }
365
366    /* Configuring Numeric Formats
367     */
368
369    /// The receiver’s format.
370    #[property]
371    pub fn format(&self) -> NSString {
372        unsafe { NSString::from_id(msg_send![self.m_self(), format]) }
373    }
374
375    /// Sets the receiver’s format.
376    #[property]
377    pub fn set_format(&mut self, format: NSString) {
378        unsafe { msg_send![self.m_self(), setFormat: format] }
379    }
380
381    /// The capitalization formatting context used when formatting a number.
382    #[property]
383    pub fn formatting_context(&self) -> NSFormattingContext {
384        unsafe { msg_send![self.m_self(), formattingContext] }
385    }
386
387    /// Sets the capitalization formatting context used when formatting a number.
388    #[property]
389    pub fn set_formatting_context(&mut self, context: NSFormattingContext) {
390        unsafe { msg_send![self.m_self(), setFormattingContext: context] }
391    }
392
393    /// The format width used by the receiver.
394    #[property]
395    pub fn format_width(&self) -> UInt {
396        unsafe { msg_send![self.m_self(), formatWidth] }
397    }
398
399    /// Sets the format width used by the receiver.
400    #[property]
401    pub fn set_format_width(&mut self, width: UInt) {
402        unsafe { msg_send![self.m_self(), setFormatWidth: width] }
403    }
404
405    /// The format the receiver uses to display negative values.
406    #[property]
407    pub fn negative_format(&self) -> NSString {
408        unsafe { NSString::from_id(msg_send![self.m_self(), negativeFormat]) }
409    }
410
411    /// Sets the format the receiver uses to display negative values.
412    #[property]
413    pub fn set_negative_format(&mut self) {
414        unsafe { msg_send![self.m_self(), setNegativeFormat] }
415    }
416
417    /// The format the receiver uses to display positive values.
418    #[property]
419    pub fn positive_format(&self) -> NSString {
420        unsafe { NSString::from_id(msg_send![self.m_self(), positiveFormat]) }
421    }
422
423    /// Sets the format the receiver uses to display positive values.
424    #[property]
425    pub fn set_positive_format(&mut self, format: NSString) {
426        unsafe { msg_send![self.m_self(), setPositiveFormat: format] }
427    }
428
429    /// The multiplier of the receiver.
430    #[property]
431    pub fn multiplier(&self) -> NSNumber {
432        unsafe { NSNumber::from_id(msg_send![self.m_self(), multiplier]) }
433    }
434
435    /// Sets the multiplier of the receiver.
436    #[property]
437    pub fn set_multiplier(&mut self, multiplier: NSNumber) {
438        unsafe { msg_send![self.m_self(), setMultiplier: multiplier] }
439    }
440
441    /* Configuring Numeric Symbols
442     */
443
444    /// The string used to represent a percent symbol.
445    #[property]
446    pub fn percent_symbol(&self) -> NSString {
447        unsafe { NSString::from_id(msg_send![self.m_self(), percentSymbol]) }
448    }
449
450    /// Sets the string used to represent a percent symbol.
451    #[property]
452    pub fn set_percent_symbol(&mut self, symbol: NSString) {
453        unsafe { msg_send![self.m_self(), setPercentSymbol: symbol] }
454    }
455
456    /// The string used to represent a per-mill (per-thousand) symbol.
457    #[property]
458    pub fn per_mill_symbol(&self) -> NSString {
459        unsafe { NSString::from_id(msg_send![self.m_self(), perMillSymbol]) }
460    }
461
462    /// The string used to represent a per-mill (per-thousand) symbol.
463    #[property]
464    pub fn set_per_mill_symbol(&mut self, symbol: NSString) {
465        unsafe { msg_send![self.m_self(), setPerMillSymbol: symbol] }
466    }
467
468    /// The string used to represent a minus sign.
469    #[property]
470    pub fn minus_sign(&self) -> NSString {
471        unsafe { NSString::from_id(msg_send![self.m_self(), minusSign]) }
472    }
473
474    /// Sets the string used to represent a minus sign.
475    #[property]
476    pub fn set_minus_sign(&mut self, sign: NSString) {
477        unsafe { msg_send![self.m_self(), setMinusSign: sign] }
478    }
479
480    /// The string used to represent a plus sign.
481    #[property]
482    pub fn plus_sign(&self) -> NSString {
483        unsafe { NSString::from_id(msg_send![self.m_self(), plusSign]) }
484    }
485
486    /// Sets the string used to represent a plus sign.
487    #[property]
488    pub fn set_plus_sign(&mut self, sign: NSString) {
489        unsafe { msg_send![self.m_self(), setPlusSign: sign] }
490    }
491
492    /// The string used to represent an exponent symbol.
493    #[property]
494    pub fn exponent_symbol(&self) -> NSString {
495        unsafe { NSString::from_id(msg_send![self.m_self(), exponentSymbol]) }
496    }
497
498    /// Sets the string used to represent an exponent symbol.
499    #[property]
500    pub fn set_exponent_symbol(&mut self, sign: NSString) {
501        unsafe { msg_send![self.m_self(), setExponentSymbol: sign] }
502    }
503
504    /// The string used to represent a zero symbol.
505    #[property]
506    pub fn zero_symbol(&self) -> NSString {
507        unsafe { NSString::from_id(msg_send![self.m_self(), zeroSymbol]) }
508    }
509
510    /// Sets the string used to represent a zero symbol.
511    #[property]
512    pub fn set_zero_symbol(&mut self, sign: NSString) {
513        unsafe { msg_send![self.m_self(), setZeroSymbol: sign] }
514    }
515
516    /// The string used to represent a nil symbol.
517    #[property]
518    pub fn nil_symbol(&self) -> NSString {
519        unsafe { NSString::from_id(msg_send![self.m_self(), nilSymbol]) }
520    }
521
522    /// Sets the string used to represent a nil symbol.
523    #[property]
524    pub fn set_nil_symbol(&mut self, sign: NSString) {
525        unsafe { msg_send![self.m_self(), setNilSymbol: sign] }
526    }
527
528    /// The string used to represent a NaN (“not a number”) value.
529    #[property]
530    pub fn not_a_number_symbol(&self) -> NSString {
531        unsafe { NSString::from_id(msg_send![self.m_self(), notANumberSymbol]) }
532    }
533
534    /// Sets the string used to represent a NaN (“not a number”) value.
535    #[property]
536    pub fn set_not_a_number_symbol(&mut self, symbol: NSString) {
537        unsafe { msg_send![self.m_self(), setNotANumberSymbol: symbol] }
538    }
539
540    /// The string used to represent a negative infinity symbol.
541    #[property]
542    pub fn negative_infinity_symbol(&self) -> NSString {
543        unsafe { NSString::from_id(msg_send![self.m_self(), negativeInfinitySymbol]) }
544    }
545
546    /// Sets the string used to represent a negative infinity symbol.
547    #[property]
548    pub fn set_negative_infinity_symbol(&self, symbol: NSString) {
549        unsafe { msg_send![self.m_self(), setNegativeInfinitySymbol: symbol] }
550    }
551
552    /// The string used to represent a positive infinity symbol.
553    #[property]
554    pub fn positive_infinity_symbol(&self) -> NSString {
555        unsafe { NSString::from_id(msg_send![self.m_self(), positiveInfinitySymbol]) }
556    }
557
558    /// Sets the string used to represent a positive infinity symbol.
559    #[property]
560    pub fn set_positive_infinity_symbol(&self, symbol: NSString) {
561        unsafe { msg_send![self.m_self(), setPositiveInfinitySymbol: symbol] }
562    }
563
564    /* Configuring the Format of Currency
565     */
566
567    /// The string used by the receiver as a local currency symbol.
568    #[property]
569    pub fn currency_symbol(&self) -> NSString {
570        unsafe { NSString::from_id(msg_send![self.m_self(), currencySymbol]) }
571    }
572
573    /// Sets the string used by the receiver as a local currency symbol.
574    #[property]
575    pub fn set_currency_symbol(&mut self, symbol: NSString) {
576        unsafe { msg_send![self.m_self(), setCurrencySymbol: symbol] }
577    }
578
579    /// The receiver’s currency code.
580    #[property]
581    pub fn currency_code(&self) -> NSString {
582        unsafe { NSString::from_id(msg_send![self.m_self(), currencyCode]) }
583    }
584
585    /// Sets the receiver’s currency code.
586    #[property]
587    pub fn set_currency_code(&mut self, code: NSString) {
588        unsafe { msg_send![self.m_self(), setCurrencyCode: code] }
589    }
590
591    /// The international currency symbol used by the receiver.
592    #[property]
593    pub fn international_currency_symbol(&self) -> NSString {
594        unsafe { NSString::from_id(msg_send![self.m_self(), internationalCurrencySymbol]) }
595    }
596
597    /// Sets the international currency symbol used by the receiver.
598    #[property]
599    pub fn set_international_currency_symbol(&mut self, symbol: NSString) {
600        unsafe { msg_send![self.m_self(), setInternationalCurrencySymbol: symbol] }
601    }
602
603    /// The currency grouping separator for the receiver.
604    #[property]
605    pub fn currency_grouping_separator(&self) -> NSString {
606        unsafe { NSString::from_id(msg_send![self.m_self(), currencyGroupingSepator]) }
607    }
608
609    /* Configuring Numeric Prefixes and Suffixes
610     */
611
612    /// The string the receiver uses as the prefix for positive values.
613    #[property]
614    pub fn positive_prefix(&self) -> NSString {
615        unsafe { NSString::from_id(msg_send![self.m_self(), positivePrefix]) }
616    }
617
618    /// Sets the string the receiver uses as the prefix for positive values.
619    #[property]
620    pub fn set_positive_prefix(&mut self, prefix: NSString) {
621        unsafe { msg_send![self.m_self(), setPositivePrefix: prefix] }
622    }
623
624    /// The string the receiver uses as the suffix for positive values.
625    #[property]
626    pub fn positive_suffix(&self) -> NSString {
627        unsafe { NSString::from_id(msg_send![self.m_self(), positiveSuffix]) }
628    }
629
630    /// Sets the string the receiver uses as the suffix for positive values.
631    #[property]
632    pub fn set_positive_suffix(&mut self, suffix: NSString) {
633        unsafe { msg_send![self.m_self(), setPositiveSuffix: suffix] }
634    }
635
636    /// The string the receiver uses as a prefix for negative values.
637    #[property]
638    pub fn negative_prefix(&self) -> NSString {
639        unsafe { NSString::from_id(msg_send![self.m_self(), negativePrefix]) }
640    }
641
642    /// Sets the string the receiver uses as a prefix for negative values.
643    #[property]
644    pub fn set_negative_prefix(&mut self, prefix: NSString) {
645        unsafe { msg_send![self.m_self(), setNegativePrefix: prefix] }
646    }
647
648    /// The string the receiver uses as a suffix for negative values.
649    #[property]
650    pub fn negative_suffix(&self) -> NSString {
651        unsafe { NSString::from_id(msg_send![self.m_self(), negativeSuffix]) }
652    }
653
654    /* Configuring the Display of Numeric Values
655     */
656
657    /// The text attributes to be used in displaying negative values.
658    #[property]
659    pub fn text_attributes_for_negative_values(&self) -> NSDictionary<NSString, id> {
660        unsafe { NSDictionary::from_id(msg_send![self.m_self(), negativeAttributes]) }
661    }
662
663    /// Sets the text attributes to be used in displaying negative values.
664    #[property]
665    pub fn set_text_attributes_for_negative_values(
666        &mut self,
667        attributes: NSDictionary<NSString, id>,
668    ) {
669        unsafe { msg_send![self.m_self(), setNegativeAttributes: attributes] }
670    }
671
672    /// The text attributes to be used in displaying positive values.
673    #[property]
674    pub fn text_attributes_for_positive_values(&self) -> NSDictionary<NSString, id> {
675        unsafe { NSDictionary::from_id(msg_send![self.m_self(), positiveAttributes]) }
676    }
677
678    /// Sets the text attributes to be used in displaying positive values.
679    #[property]
680    pub fn set_text_attributes_for_positive_values(
681        &mut self,
682        attributes: NSDictionary<NSString, id>,
683    ) {
684        unsafe { msg_send![self.m_self(), setPositiveAttributes: attributes] }
685    }
686
687    /// The attributed string that the receiver uses to display zero values.
688    #[property]
689    pub fn attributed_string_for_zero(&self) -> NSAttributedString {
690        unsafe { NSAttributedString::from_id(msg_send![self.m_self(), zeroAttributedString]) }
691    }
692
693    /// Sets the attributed string that the receiver uses to display zero values.
694    #[property]
695    pub fn set_attributed_string_for_zero(&mut self, string: NSAttributedString) {
696        unsafe { msg_send![self.m_self(), setZeroAttributedString: string] }
697    }
698
699    /// The text attributes used to display a zero value.
700    #[property]
701    pub fn text_attributes_for_zero(&self) -> NSDictionary<NSString, id> {
702        unsafe { NSDictionary::from_id(msg_send![self.m_self(), zeroAttributes]) }
703    }
704
705    /// Sets the text attributes used to display a zero value.
706    #[property]
707    pub fn set_text_attributes_for_zero(&mut self, attributes: NSDictionary<NSString, id>) {
708        unsafe { msg_send![self.m_self(), setZeroAttributes: attributes] }
709    }
710
711    /// The attributed string the receiver uses to display nil values.
712    #[property]
713    pub fn attributed_string_for_nil(&self) -> NSAttributedString {
714        unsafe { NSAttributedString::from_id(msg_send![self.m_self(), nilAttributedString]) }
715    }
716
717    /// Sets the attributed string the receiver uses to display nil values.
718    #[property]
719    pub fn set_attributed_string_for_nil(&mut self, string: NSAttributedString) {
720        unsafe { msg_send![self.m_self(), setNilAttributedString: string] }
721    }
722
723    /// The text attributes used to display the nil symbol.
724    #[property]
725    pub fn text_attributes_for_nil(&self) -> NSDictionary<NSString, id> {
726        unsafe { NSDictionary::from_id(msg_send![self.m_self(), nilAttributes]) }
727    }
728
729    /// Sets the text attributes used to display the nil symbol.
730    #[property]
731    pub fn set_text_attributes_for_nil(&mut self, attributes: NSDictionary<NSString, id>) {
732        unsafe { msg_send![self.m_self(), setNilAttributes: attributes] }
733    }
734
735    /// The attributed string the receiver uses to display “not a number” values.
736    #[property]
737    pub fn attributed_string_for_not_a_number(&self) -> NSAttributedString {
738        unsafe { NSAttributedString::from_id(msg_send![self.m_self(), notANumberAttributedString]) }
739    }
740
741    /// Sets the attributed string the receiver uses to display “not a number” values.
742    #[property]
743    pub fn set_attributed_string_for_not_a_number(&mut self, string: NSAttributedString) {
744        unsafe { msg_send![self.m_self(), setNotANumberAttributedString: string] }
745    }
746
747    /// The text attributes used to display the NaN (“not a number”) string.
748    #[property]
749    pub fn text_attributes_for_not_a_number(&self) -> NSDictionary<NSString, id> {
750        unsafe { NSDictionary::from_id(msg_send![self.m_self(), notANumberAttributes]) }
751    }
752
753    /// Sets the text attributes used to display the NaN (“not a number”) string.
754    #[property]
755    pub fn set_text_attributes_for_not_a_number(&mut self, attributes: NSDictionary<NSString, id>) {
756        unsafe { msg_send![self.m_self(), setNotANumberAttributes: attributes] }
757    }
758
759    /// The text attributes used to display the positive infinity symbol.
760    #[property]
761    pub fn text_attributes_for_positive_infinity(&self) -> NSDictionary<NSString, id> {
762        unsafe { NSDictionary::from_id(msg_send![self.m_self(), positiveInfinityAttributes]) }
763    }
764
765    /// Sets the text attributes used to display the positive infinity symbol.
766    #[property]
767    pub fn set_text_attributes_for_positive_infinity(
768        &mut self,
769        attributes: NSDictionary<NSString, id>,
770    ) {
771        unsafe { msg_send![self.m_self(), setPositiveInfinityAttributes: attributes] }
772    }
773
774    /// The text attributes used to display the negative infinity symbol.
775    #[property]
776    pub fn text_attributes_for_negative_infinity(&self) -> NSDictionary<NSString, id> {
777        unsafe { NSDictionary::from_id(msg_send![self.m_self(), negativeInfinityAttributes]) }
778    }
779
780    /// Sets the text attributes used to display the negative infinity symbol.
781    #[property]
782    pub fn set_text_attributes_for_negative_infinity(
783        &mut self,
784        attributes: NSDictionary<NSString, id>,
785    ) {
786        unsafe { msg_send![self.m_self(), setNegativeInfinityAttributes: attributes] }
787    }
788
789    /* Configuring Separators and Grouping Size
790     */
791
792    /// The string used by the receiver for a grouping separator.
793    #[property]
794    pub fn grouping_separator(&self) -> NSString {
795        unsafe { NSString::from_id(msg_send![self.m_self(), groupingSeparator]) }
796    }
797
798    /// Sets the string used by the receiver for a grouping separator.
799    #[property]
800    pub fn set_grouping_separator(&mut self, separator: NSString) {
801        unsafe { msg_send![self.m_self(), setGroupingSeparator: separator] }
802    }
803
804    /// Determines whether the receiver displays the group separator.
805    #[property]
806    pub fn uses_grouping_separator(&self) -> bool {
807        unsafe { to_bool(msg_send![self.m_self(), usesGroupingSeparator]) }
808    }
809
810    /// Sets whether the receiver displays the group separator.
811    #[property]
812    pub fn set_uses_grouping_separator(&mut self, flag: bool) {
813        unsafe { msg_send![self.m_self(), setUsesGroupingSeparator: flag] }
814    }
815
816    /// The character the receiver uses as a thousand separator.
817    #[property]
818    pub fn thousand_separator(&self) -> NSString {
819        unsafe { NSString::from_id(msg_send![self.m_self(), thousandSeparator]) }
820    }
821
822    /// Sets the character the receiver uses as a thousand separator.
823    #[property]
824    pub fn set_thousand_separator(&mut self, separator: NSString) {
825        unsafe { msg_send![self.m_self(), setThousandSeparator: separator] }
826    }
827
828    /// Determines whether the receiver uses thousand separators.
829    #[property]
830    pub fn uses_thousand_separators(&self) -> bool {
831        unsafe { to_bool(msg_send![self.m_self(), usesThousandSeparators]) }
832    }
833
834    /// Sets whether the receiver uses thousand separators.
835    #[property]
836    pub fn set_uses_thousand_separators(&mut self, flag: bool) {
837        unsafe { msg_send![self.m_self(), setUsesThousandSeparators: flag] }
838    }
839
840    /// The character the receiver uses as a decimal separator.
841    #[property]
842    pub fn decimal_separator(&self) -> NSString {
843        unsafe { NSString::from_id(msg_send![self.m_self(), decimalSeparator]) }
844    }
845
846    /// Determines whether the receiver always shows the decimal separator, even for integer numbers.
847    #[property]
848    pub fn always_show_decimal_separator(&self) -> bool {
849        unsafe { to_bool(msg_send![self.m_self(), alwaysShowDecimalSeparator]) }
850    }
851
852    /// Sets whether the receiver always shows the decimal separator, even for integer numbers.
853    #[property]
854    pub fn set_always_show_decimal_separator(&mut self, flag: bool) {
855        unsafe { msg_send![self.m_self(), setAlwaysShowDecimalSeparator: flag] }
856    }
857
858    /// The string used by the receiver as a currency decimal separator.
859    #[property]
860    pub fn currency_decimal_separator(&self) -> NSString {
861        unsafe { NSString::from_id(msg_send![self.m_self(), currencyDecimalSeparator]) }
862    }
863
864    /// Sets the string used by the receiver as a currency decimal separator.
865    #[property]
866    pub fn set_currency_decimal_separator(&mut self, separator: NSString) {
867        unsafe { msg_send![self.m_self(), setCurrencyDecimalSeparator: separator] }
868    }
869
870    /// The grouping size of the receiver.
871    #[property]
872    pub fn grouping_size(&self) -> Int {
873        unsafe { msg_send![self.m_self(), groupingSize] }
874    }
875
876    /// Sets the grouping size of the receiver.
877    #[property]
878    pub fn set_grouping_size(&mut self, size: Int) {
879        unsafe { msg_send![self.m_self(), setGroupingSize: size] }
880    }
881
882    /// The secondary grouping size of the receiver.
883    #[property]
884    pub fn secondary_grouping_size(&self) -> Int {
885        unsafe { msg_send![self.m_self(), secondaryGroupingSize] }
886    }
887
888    /// Sets the secondary grouping size of the receiver.
889    #[property]
890    pub fn set_secondary_grouping_size(&mut self, size: Int) {
891        unsafe { msg_send![self.m_self(), setSecondaryGroupingSize: size] }
892    }
893
894    /* Managing the Padding of Numbers
895     */
896
897    /// The string that the receiver uses to pad numbers in the formatted string representation.
898    #[property]
899    pub fn padding_character(&self) -> NSString {
900        unsafe { NSString::from_id(msg_send![self.m_self(), paddingCharacter]) }
901    }
902
903    /// Sets the string that the receiver uses to pad numbers in the formatted string representation.
904    #[property]
905    pub fn set_padding_character(&mut self, padding: NSString) {
906        unsafe { msg_send![self.m_self(), setPaddingCharacter: padding] }
907    }
908
909    /// The padding position used by the receiver.
910    #[property]
911    pub fn padding_position(&self) -> NSNumberFormatterPadPosition {
912        unsafe { msg_send![self.m_self(), paddingPosition] }
913    }
914
915    /// Sets the padding position used by the receiver.
916    #[property]
917    pub fn set_padding_position(&mut self, position: NSNumberFormatterPadPosition) {
918        unsafe { msg_send![self.m_self(), setPaddingPosition: position] }
919    }
920
921    /* Managing Input and Output Attributes
922     */
923
924    /// Determines whether the receiver allows as input floating-point values (that is, values that include the period character [.]).
925    #[property]
926    pub fn allows_floats(&self) -> bool {
927        unsafe { to_bool(msg_send![self.m_self(), allowsFloats]) }
928    }
929
930    /// Sets whether the receiver allows as input floating-point values (that is, values that include the period character [.]).
931    #[property]
932    pub fn set_allows_floats(&mut self, flag: bool) {
933        unsafe { msg_send![self.m_self(), setAllowsFloats: flag] }
934    }
935
936    /// The lowest number allowed as input by the receiver.
937    #[property]
938    pub fn minimum(&self) -> NSNumber {
939        unsafe { NSNumber::from_id(msg_send![self.m_self(), minimum]) }
940    }
941
942    /// Sets the lowest number allowed as input by the receiver.
943    #[property]
944    pub fn set_minimum(&mut self, number: NSNumber) {
945        unsafe { msg_send![self.m_self(), setMinimum: number] }
946    }
947
948    /// The highest number allowed as input by the receiver.
949    #[property]
950    pub fn maximum(&self) -> NSNumber {
951        unsafe { NSNumber::from_id(msg_send![self.m_self(), maximum]) }
952    }
953
954    /// Sets the highest number allowed as input by the receiver.
955    #[property]
956    pub fn set_maximum(&mut self, number: NSNumber) {
957        unsafe { msg_send![self.m_self(), setMaximum: number] }
958    }
959
960    /* Managing Leniency Behavior
961     */
962
963    /// Determines whether the receiver will use heuristics to guess at the number which is intended by a string.
964    #[property]
965    pub fn lenient(&self) -> bool {
966        unsafe { to_bool(msg_send![self.m_self(), isLenient]) }
967    }
968
969    /// Sets whether the receiver will use heuristics to guess at the number which is intended by a string.
970    #[property]
971    pub fn set_lenient(&mut self, flag: bool) {
972        unsafe { msg_send![self.m_self(), setLenient: flag] }
973    }
974
975    /* Managing the Validation of Partial Numeric Strings
976     */
977
978    /// Determines whether partial string validation is enabled for the receiver.
979    #[property]
980    pub fn partial_string_validation_enabled(&self) -> bool {
981        unsafe { to_bool(msg_send![self.m_self(), isPartialStringValidationEnabled]) }
982    }
983
984    /// Sets whether partial string validation is enabled for the receiver.
985    #[property]
986    pub fn set_partial_string_validation_enabled(&mut self, flag: bool) {
987        unsafe { msg_send![self.m_self(), setPartialStringValidationEnabled: flag] }
988    }
989}