//! 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/nsvaluetransformername?language=objc)
// NS_TYPED_EXTENSIBLE_ENUM
#[cfg(feature = "NSString")]
pub type NSValueTransformerName = NSString;

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

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

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

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

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

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

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

extern_conformance!(
    unsafe impl NSObjectProtocol for NSValueTransformer {}
);

impl NSValueTransformer {
    extern_methods!(
        #[cfg(feature = "NSString")]
        #[unsafe(method(setValueTransformer:forName:))]
        #[unsafe(method_family = none)]
        pub fn setValueTransformer_forName(
            transformer: Option<&NSValueTransformer>,
            name: &NSValueTransformerName,
        );

        #[cfg(feature = "NSString")]
        #[unsafe(method(valueTransformerForName:))]
        #[unsafe(method_family = none)]
        pub fn valueTransformerForName(
            name: &NSValueTransformerName,
        ) -> Option<Retained<NSValueTransformer>>;

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[unsafe(method(valueTransformerNames))]
        #[unsafe(method_family = none)]
        pub fn valueTransformerNames() -> Retained<NSArray<NSValueTransformerName>>;

        #[unsafe(method(transformedValueClass))]
        #[unsafe(method_family = none)]
        pub fn transformedValueClass() -> &'static AnyClass;

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

        /// # Safety
        ///
        /// `value` should be of the correct type.
        #[unsafe(method(transformedValue:))]
        #[unsafe(method_family = none)]
        pub unsafe fn transformedValue(
            &self,
            value: Option<&AnyObject>,
        ) -> Option<Retained<AnyObject>>;

        /// # Safety
        ///
        /// `value` should be of the correct type.
        #[unsafe(method(reverseTransformedValue:))]
        #[unsafe(method_family = none)]
        pub unsafe fn reverseTransformedValue(
            &self,
            value: Option<&AnyObject>,
        ) -> Option<Retained<AnyObject>>;
    );
}

/// Methods declared on superclass `NSObject`.
impl NSValueTransformer {
    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>;
    );
}

impl DefaultRetained for NSValueTransformer {
    #[inline]
    fn default_retained() -> Retained<Self> {
        Self::new()
    }
}

extern_class!(
    /// A value transformer which transforms values to and from
    /// `NSData`by archiving and unarchiving using secure coding.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nssecureunarchivefromdatatransformer?language=objc)
    #[unsafe(super(NSValueTransformer, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct NSSecureUnarchiveFromDataTransformer;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for NSSecureUnarchiveFromDataTransformer {}
);

impl NSSecureUnarchiveFromDataTransformer {
    extern_methods!(
        #[cfg(feature = "NSArray")]
        /// The list of allowable classes which the top-level object in the archive must conform to on encoding and decoding.
        ///
        /// Returns the result of
        /// `+transformedValueClass`if not
        /// `Nil;`otherwise, currently returns
        /// `NSArray,``NSDictionary,``NSSet,``NSString,``NSNumber,``NSDate,``NSData,``NSURL,``NSUUID,`and
        /// `NSNull.`
        /// Can be overridden by subclasses to provide an expanded or different set of allowed transformation classes.
        #[unsafe(method(allowedTopLevelClasses))]
        #[unsafe(method_family = none)]
        pub fn allowedTopLevelClasses() -> Retained<NSArray<AnyClass>>;
    );
}

/// Methods declared on superclass `NSObject`.
impl NSSecureUnarchiveFromDataTransformer {
    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>;
    );
}

impl DefaultRetained for NSSecureUnarchiveFromDataTransformer {
    #[inline]
    fn default_retained() -> Retained<Self> {
        Self::new()
    }
}
