//! 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/nsregularexpressionoptions?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSRegularExpressionOptions(pub NSUInteger);
bitflags::bitflags! {
    impl NSRegularExpressionOptions: NSUInteger {
        #[doc(alias = "NSRegularExpressionCaseInsensitive")]
        const CaseInsensitive = 1<<0;
        #[doc(alias = "NSRegularExpressionAllowCommentsAndWhitespace")]
        const AllowCommentsAndWhitespace = 1<<1;
        #[doc(alias = "NSRegularExpressionIgnoreMetacharacters")]
        const IgnoreMetacharacters = 1<<2;
        #[doc(alias = "NSRegularExpressionDotMatchesLineSeparators")]
        const DotMatchesLineSeparators = 1<<3;
        #[doc(alias = "NSRegularExpressionAnchorsMatchLines")]
        const AnchorsMatchLines = 1<<4;
        #[doc(alias = "NSRegularExpressionUseUnixLineSeparators")]
        const UseUnixLineSeparators = 1<<5;
        #[doc(alias = "NSRegularExpressionUseUnicodeWordBoundaries")]
        const UseUnicodeWordBoundaries = 1<<6;
    }
}

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

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

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

unsafe impl Send for NSRegularExpression {}

unsafe impl Sync for NSRegularExpression {}

#[cfg(feature = "NSObject")]
extern_conformance!(
    unsafe impl NSCoding for NSRegularExpression {}
);

#[cfg(feature = "NSObject")]
extern_conformance!(
    unsafe impl NSCopying for NSRegularExpression {}
);

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

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

#[cfg(feature = "NSObject")]
extern_conformance!(
    unsafe impl NSSecureCoding for NSRegularExpression {}
);

impl NSRegularExpression {
    extern_methods!(
        #[cfg(all(feature = "NSError", feature = "NSString"))]
        #[unsafe(method(regularExpressionWithPattern:options:error:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn regularExpressionWithPattern_options_error(
            pattern: &NSString,
            options: NSRegularExpressionOptions,
        ) -> Result<Retained<NSRegularExpression>, Retained<NSError>>;

        #[cfg(all(feature = "NSError", feature = "NSString"))]
        #[unsafe(method(initWithPattern:options:error:_))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithPattern_options_error(
            this: Allocated<Self>,
            pattern: &NSString,
            options: NSRegularExpressionOptions,
        ) -> Result<Retained<Self>, Retained<NSError>>;

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

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

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

        #[cfg(feature = "NSString")]
        #[unsafe(method(escapedPatternForString:))]
        #[unsafe(method_family = none)]
        pub unsafe fn escapedPatternForString(string: &NSString) -> Retained<NSString>;
    );
}

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

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

/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmatchingoptions?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSMatchingOptions(pub NSUInteger);
bitflags::bitflags! {
    impl NSMatchingOptions: NSUInteger {
        #[doc(alias = "NSMatchingReportProgress")]
        const ReportProgress = 1<<0;
        #[doc(alias = "NSMatchingReportCompletion")]
        const ReportCompletion = 1<<1;
        #[doc(alias = "NSMatchingAnchored")]
        const Anchored = 1<<2;
        #[doc(alias = "NSMatchingWithTransparentBounds")]
        const WithTransparentBounds = 1<<3;
        #[doc(alias = "NSMatchingWithoutAnchoringBounds")]
        const WithoutAnchoringBounds = 1<<4;
    }
}

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

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

/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmatchingflags?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSMatchingFlags(pub NSUInteger);
bitflags::bitflags! {
    impl NSMatchingFlags: NSUInteger {
        #[doc(alias = "NSMatchingProgress")]
        const Progress = 1<<0;
        #[doc(alias = "NSMatchingCompleted")]
        const Completed = 1<<1;
        #[doc(alias = "NSMatchingHitEnd")]
        const HitEnd = 1<<2;
        #[doc(alias = "NSMatchingRequiredEnd")]
        const RequiredEnd = 1<<3;
        #[doc(alias = "NSMatchingInternalError")]
        const InternalError = 1<<4;
    }
}

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

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

/// NSMatching.
impl NSRegularExpression {
    extern_methods!(
        #[cfg(all(
            feature = "NSRange",
            feature = "NSString",
            feature = "NSTextCheckingResult",
            feature = "block2"
        ))]
        #[unsafe(method(enumerateMatchesInString:options:range:usingBlock:))]
        #[unsafe(method_family = none)]
        pub unsafe fn enumerateMatchesInString_options_range_usingBlock(
            &self,
            string: &NSString,
            options: NSMatchingOptions,
            range: NSRange,
            block: &block2::DynBlock<
                dyn Fn(*mut NSTextCheckingResult, NSMatchingFlags, NonNull<Bool>) + '_,
            >,
        );

        #[cfg(all(
            feature = "NSArray",
            feature = "NSRange",
            feature = "NSString",
            feature = "NSTextCheckingResult"
        ))]
        #[unsafe(method(matchesInString:options:range:))]
        #[unsafe(method_family = none)]
        pub unsafe fn matchesInString_options_range(
            &self,
            string: &NSString,
            options: NSMatchingOptions,
            range: NSRange,
        ) -> Retained<NSArray<NSTextCheckingResult>>;

        #[cfg(all(feature = "NSRange", feature = "NSString"))]
        #[unsafe(method(numberOfMatchesInString:options:range:))]
        #[unsafe(method_family = none)]
        pub unsafe fn numberOfMatchesInString_options_range(
            &self,
            string: &NSString,
            options: NSMatchingOptions,
            range: NSRange,
        ) -> NSUInteger;

        #[cfg(all(
            feature = "NSRange",
            feature = "NSString",
            feature = "NSTextCheckingResult"
        ))]
        #[unsafe(method(firstMatchInString:options:range:))]
        #[unsafe(method_family = none)]
        pub unsafe fn firstMatchInString_options_range(
            &self,
            string: &NSString,
            options: NSMatchingOptions,
            range: NSRange,
        ) -> Option<Retained<NSTextCheckingResult>>;

        #[cfg(all(feature = "NSRange", feature = "NSString"))]
        #[unsafe(method(rangeOfFirstMatchInString:options:range:))]
        #[unsafe(method_family = none)]
        pub unsafe fn rangeOfFirstMatchInString_options_range(
            &self,
            string: &NSString,
            options: NSMatchingOptions,
            range: NSRange,
        ) -> NSRange;
    );
}

/// NSReplacement.
impl NSRegularExpression {
    extern_methods!(
        #[cfg(all(feature = "NSRange", feature = "NSString"))]
        #[unsafe(method(stringByReplacingMatchesInString:options:range:withTemplate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn stringByReplacingMatchesInString_options_range_withTemplate(
            &self,
            string: &NSString,
            options: NSMatchingOptions,
            range: NSRange,
            templ: &NSString,
        ) -> Retained<NSString>;

        #[cfg(all(feature = "NSRange", feature = "NSString"))]
        #[unsafe(method(replaceMatchesInString:options:range:withTemplate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn replaceMatchesInString_options_range_withTemplate(
            &self,
            string: &NSMutableString,
            options: NSMatchingOptions,
            range: NSRange,
            templ: &NSString,
        ) -> NSUInteger;

        #[cfg(all(feature = "NSString", feature = "NSTextCheckingResult"))]
        #[unsafe(method(replacementStringForResult:inString:offset:template:))]
        #[unsafe(method_family = none)]
        pub unsafe fn replacementStringForResult_inString_offset_template(
            &self,
            result: &NSTextCheckingResult,
            string: &NSString,
            offset: NSInteger,
            templ: &NSString,
        ) -> Retained<NSString>;

        #[cfg(feature = "NSString")]
        #[unsafe(method(escapedTemplateForString:))]
        #[unsafe(method_family = none)]
        pub unsafe fn escapedTemplateForString(string: &NSString) -> Retained<NSString>;
    );
}

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

#[cfg(feature = "NSObject")]
extern_conformance!(
    unsafe impl NSCoding for NSDataDetector {}
);

#[cfg(feature = "NSObject")]
extern_conformance!(
    unsafe impl NSCopying for NSDataDetector {}
);

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

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

#[cfg(feature = "NSObject")]
extern_conformance!(
    unsafe impl NSSecureCoding for NSDataDetector {}
);

impl NSDataDetector {
    extern_methods!(
        #[cfg(all(feature = "NSError", feature = "NSTextCheckingResult"))]
        #[unsafe(method(dataDetectorWithTypes:error:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn dataDetectorWithTypes_error(
            checking_types: NSTextCheckingTypes,
        ) -> Result<Retained<NSDataDetector>, Retained<NSError>>;

        #[cfg(all(feature = "NSError", feature = "NSTextCheckingResult"))]
        #[unsafe(method(initWithTypes:error:_))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithTypes_error(
            this: Allocated<Self>,
            checking_types: NSTextCheckingTypes,
        ) -> Result<Retained<Self>, Retained<NSError>>;

        #[cfg(feature = "NSTextCheckingResult")]
        #[unsafe(method(checkingTypes))]
        #[unsafe(method_family = none)]
        pub unsafe fn checkingTypes(&self) -> NSTextCheckingTypes;
    );
}

/// Methods declared on superclass `NSRegularExpression`.
impl NSDataDetector {
    extern_methods!(
        #[cfg(all(feature = "NSError", feature = "NSString"))]
        #[unsafe(method(initWithPattern:options:error:_))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithPattern_options_error(
            this: Allocated<Self>,
            pattern: &NSString,
            options: NSRegularExpressionOptions,
        ) -> Result<Retained<Self>, Retained<NSError>>;
    );
}

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

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