//! 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/nspersonnamecomponentsformatterstyle?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSPersonNameComponentsFormatterStyle(pub NSInteger);
impl NSPersonNameComponentsFormatterStyle {
    #[doc(alias = "NSPersonNameComponentsFormatterStyleDefault")]
    pub const Default: Self = Self(0);
    #[doc(alias = "NSPersonNameComponentsFormatterStyleShort")]
    pub const Short: Self = Self(1);
    #[doc(alias = "NSPersonNameComponentsFormatterStyleMedium")]
    pub const Medium: Self = Self(2);
    #[doc(alias = "NSPersonNameComponentsFormatterStyleLong")]
    pub const Long: Self = Self(3);
    #[doc(alias = "NSPersonNameComponentsFormatterStyleAbbreviated")]
    pub const Abbreviated: Self = Self(4);
}

unsafe impl Encode for NSPersonNameComponentsFormatterStyle {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

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

/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nspersonnamecomponentsformatteroptions?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSPersonNameComponentsFormatterOptions(pub NSUInteger);
bitflags::bitflags! {
    impl NSPersonNameComponentsFormatterOptions: NSUInteger {
        #[doc(alias = "NSPersonNameComponentsFormatterPhonetic")]
        const Phonetic = 1<<1;
    }
}

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

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

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

#[cfg(feature = "NSFormatter")]
unsafe impl Send for NSPersonNameComponentsFormatter {}

#[cfg(feature = "NSFormatter")]
unsafe impl Sync for NSPersonNameComponentsFormatter {}

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

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

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

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

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

        /// Setter for [`style`][Self::style].
        #[unsafe(method(setStyle:))]
        #[unsafe(method_family = none)]
        pub fn setStyle(&self, style: NSPersonNameComponentsFormatterStyle);

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

        /// Setter for [`isPhonetic`][Self::isPhonetic].
        #[unsafe(method(setPhonetic:))]
        #[unsafe(method_family = none)]
        pub fn setPhonetic(&self, phonetic: bool);

        #[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(all(feature = "NSPersonNameComponents", feature = "NSString"))]
        #[unsafe(method(localizedStringFromPersonNameComponents:style:options:))]
        #[unsafe(method_family = none)]
        pub fn localizedStringFromPersonNameComponents_style_options(
            components: &NSPersonNameComponents,
            name_format_style: NSPersonNameComponentsFormatterStyle,
            name_options: NSPersonNameComponentsFormatterOptions,
        ) -> Retained<NSString>;

        #[cfg(all(feature = "NSPersonNameComponents", feature = "NSString"))]
        #[unsafe(method(stringFromPersonNameComponents:))]
        #[unsafe(method_family = none)]
        pub fn stringFromPersonNameComponents(
            &self,
            components: &NSPersonNameComponents,
        ) -> Retained<NSString>;

        #[cfg(all(feature = "NSAttributedString", feature = "NSPersonNameComponents"))]
        #[unsafe(method(annotatedStringFromPersonNameComponents:))]
        #[unsafe(method_family = none)]
        pub fn annotatedStringFromPersonNameComponents(
            &self,
            components: &NSPersonNameComponents,
        ) -> Retained<NSAttributedString>;

        #[cfg(all(feature = "NSPersonNameComponents", feature = "NSString"))]
        #[unsafe(method(personNameComponentsFromString:))]
        #[unsafe(method_family = none)]
        pub fn personNameComponentsFromString(
            &self,
            string: &NSString,
        ) -> Option<Retained<NSPersonNameComponents>>;

        #[cfg(feature = "NSString")]
        /// # Safety
        ///
        /// `obj` should be of the correct type.
        #[unsafe(method(getObjectValue:forString:errorDescription:))]
        #[unsafe(method_family = none)]
        pub unsafe fn getObjectValue_forString_errorDescription(
            &self,
            obj: Option<&mut Option<Retained<AnyObject>>>,
            string: &NSString,
            error: Option<&mut Option<Retained<NSString>>>,
        ) -> bool;
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "NSFormatter")]
impl NSPersonNameComponentsFormatter {
    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 NSPersonNameComponentsFormatter {
    #[inline]
    fn default_retained() -> Retained<Self> {
        Self::new()
    }
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nspersonnamecomponentkey?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSPersonNameComponentKey: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nspersonnamecomponentgivenname?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSPersonNameComponentGivenName: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nspersonnamecomponentfamilyname?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSPersonNameComponentFamilyName: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nspersonnamecomponentmiddlename?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSPersonNameComponentMiddleName: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nspersonnamecomponentprefix?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSPersonNameComponentPrefix: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nspersonnamecomponentsuffix?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSPersonNameComponentSuffix: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nspersonnamecomponentnickname?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSPersonNameComponentNickname: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nspersonnamecomponentdelimiter?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSPersonNameComponentDelimiter: &'static NSString;
}
