//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmeasurementformatterunitoptions?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSMeasurementFormatterUnitOptions(pub NSUInteger);
bitflags::bitflags! {
    impl NSMeasurementFormatterUnitOptions: NSUInteger {
        #[doc(alias = "NSMeasurementFormatterUnitOptionsProvidedUnit")]
        const ProvidedUnit = 1<<0;
        #[doc(alias = "NSMeasurementFormatterUnitOptionsNaturalScale")]
        const NaturalScale = 1<<1;
        #[doc(alias = "NSMeasurementFormatterUnitOptionsTemperatureWithoutUnit")]
        const TemperatureWithoutUnit = 1<<2;
    }
}

unsafe impl Encode for NSMeasurementFormatterUnitOptions {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for NSMeasurementFormatterUnitOptions {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmeasurementformatter?language=objc)
    #[unsafe(super(NSFormatter, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "NSFormatter")]
    pub struct NSMeasurementFormatter;
);

#[cfg(all(feature = "NSFormatter", feature = "NSObject"))]
extern_conformance!(
    unsafe impl NSCoding for NSMeasurementFormatter {}
);

#[cfg(all(feature = "NSFormatter", feature = "NSObject"))]
extern_conformance!(
    unsafe impl NSCopying for NSMeasurementFormatter {}
);

#[cfg(all(feature = "NSFormatter", feature = "NSObject"))]
unsafe impl CopyingHelper for NSMeasurementFormatter {
    type Result = Self;
}

#[cfg(feature = "NSFormatter")]
extern_conformance!(
    unsafe impl NSObjectProtocol for NSMeasurementFormatter {}
);

#[cfg(all(feature = "NSFormatter", feature = "NSObject"))]
extern_conformance!(
    unsafe impl NSSecureCoding for NSMeasurementFormatter {}
);

#[cfg(feature = "NSFormatter")]
impl NSMeasurementFormatter {
    extern_methods!(
        #[unsafe(method(unitOptions))]
        #[unsafe(method_family = none)]
        pub fn unitOptions(&self) -> NSMeasurementFormatterUnitOptions;

        /// Setter for [`unitOptions`][Self::unitOptions].
        #[unsafe(method(setUnitOptions:))]
        #[unsafe(method_family = none)]
        pub fn setUnitOptions(&self, unit_options: NSMeasurementFormatterUnitOptions);

        #[unsafe(method(unitStyle))]
        #[unsafe(method_family = none)]
        pub fn unitStyle(&self) -> NSFormattingUnitStyle;

        /// Setter for [`unitStyle`][Self::unitStyle].
        #[unsafe(method(setUnitStyle:))]
        #[unsafe(method_family = none)]
        pub fn setUnitStyle(&self, unit_style: NSFormattingUnitStyle);

        #[cfg(feature = "NSLocale")]
        #[unsafe(method(locale))]
        #[unsafe(method_family = none)]
        pub fn locale(&self) -> Retained<NSLocale>;

        #[cfg(feature = "NSLocale")]
        /// Setter for [`locale`][Self::locale].
        ///
        /// This is [copied][crate::NSCopying::copy] when set.
        #[unsafe(method(setLocale:))]
        #[unsafe(method_family = none)]
        pub fn setLocale(&self, locale: Option<&NSLocale>);

        #[cfg(feature = "NSNumberFormatter")]
        #[unsafe(method(numberFormatter))]
        #[unsafe(method_family = none)]
        pub fn numberFormatter(&self) -> Retained<NSNumberFormatter>;

        #[cfg(feature = "NSNumberFormatter")]
        /// Setter for [`numberFormatter`][Self::numberFormatter].
        ///
        /// This is [copied][crate::NSCopying::copy] when set.
        #[unsafe(method(setNumberFormatter:))]
        #[unsafe(method_family = none)]
        pub fn setNumberFormatter(&self, number_formatter: Option<&NSNumberFormatter>);

        #[cfg(all(feature = "NSMeasurement", feature = "NSString", feature = "NSUnit"))]
        /// # Safety
        ///
        /// `measurement` generic should be bound by `AsRef<NSUnit>`.
        #[unsafe(method(stringFromMeasurement:))]
        #[unsafe(method_family = none)]
        pub unsafe fn stringFromMeasurement(
            &self,
            measurement: &NSMeasurement,
        ) -> Retained<NSString>;

        #[cfg(all(feature = "NSString", feature = "NSUnit"))]
        #[unsafe(method(stringFromUnit:))]
        #[unsafe(method_family = none)]
        pub fn stringFromUnit(&self, unit: &NSUnit) -> Retained<NSString>;
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "NSFormatter")]
impl NSMeasurementFormatter {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub fn new() -> Retained<Self>;
    );
}

#[cfg(feature = "NSFormatter")]
impl DefaultRetained for NSMeasurementFormatter {
    #[inline]
    fn default_retained() -> Retained<Self> {
        Self::new()
    }
}
