#[cfg(feature = "block2")]
use block2::*;
use objc2::__framework_prelude::*;
use crate::*;
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSRegularExpressionOptions(pub NSUInteger);
impl NSRegularExpressionOptions {
pub const NSRegularExpressionCaseInsensitive: Self = Self(1 << 0);
pub const NSRegularExpressionAllowCommentsAndWhitespace: Self = Self(1 << 1);
pub const NSRegularExpressionIgnoreMetacharacters: Self = Self(1 << 2);
pub const NSRegularExpressionDotMatchesLineSeparators: Self = Self(1 << 3);
pub const NSRegularExpressionAnchorsMatchLines: Self = Self(1 << 4);
pub const NSRegularExpressionUseUnixLineSeparators: Self = Self(1 << 5);
pub const NSRegularExpressionUseUnicodeWordBoundaries: Self = Self(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!(
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct NSRegularExpression;
unsafe impl ClassType for NSRegularExpression {
type Super = NSObject;
type Mutability = InteriorMutable;
}
);
unsafe impl Send for NSRegularExpression {}
unsafe impl Sync for NSRegularExpression {}
#[cfg(feature = "NSObject")]
unsafe impl NSCoding for NSRegularExpression {}
#[cfg(feature = "NSObject")]
unsafe impl NSCopying for NSRegularExpression {}
unsafe impl NSObjectProtocol for NSRegularExpression {}
#[cfg(feature = "NSObject")]
unsafe impl NSSecureCoding for NSRegularExpression {}
extern_methods!(
unsafe impl NSRegularExpression {
#[cfg(all(feature = "NSError", feature = "NSString"))]
#[method_id(@__retain_semantics Other regularExpressionWithPattern:options:error:_)]
pub unsafe fn regularExpressionWithPattern_options_error(
pattern: &NSString,
options: NSRegularExpressionOptions,
) -> Result<Id<NSRegularExpression>, Id<NSError>>;
#[cfg(all(feature = "NSError", feature = "NSString"))]
#[method_id(@__retain_semantics Init initWithPattern:options:error:_)]
pub unsafe fn initWithPattern_options_error(
this: Allocated<Self>,
pattern: &NSString,
options: NSRegularExpressionOptions,
) -> Result<Id<Self>, Id<NSError>>;
#[cfg(feature = "NSString")]
#[method_id(@__retain_semantics Other pattern)]
pub unsafe fn pattern(&self) -> Id<NSString>;
#[method(options)]
pub unsafe fn options(&self) -> NSRegularExpressionOptions;
#[method(numberOfCaptureGroups)]
pub unsafe fn numberOfCaptureGroups(&self) -> NSUInteger;
#[cfg(feature = "NSString")]
#[method_id(@__retain_semantics Other escapedPatternForString:)]
pub unsafe fn escapedPatternForString(string: &NSString) -> Id<NSString>;
}
);
extern_methods!(
unsafe impl NSRegularExpression {
#[method_id(@__retain_semantics Init init)]
pub unsafe fn init(this: Allocated<Self>) -> Id<Self>;
#[method_id(@__retain_semantics New new)]
pub unsafe fn new() -> Id<Self>;
}
);
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSMatchingOptions(pub NSUInteger);
impl NSMatchingOptions {
pub const NSMatchingReportProgress: Self = Self(1 << 0);
pub const NSMatchingReportCompletion: Self = Self(1 << 1);
pub const NSMatchingAnchored: Self = Self(1 << 2);
pub const NSMatchingWithTransparentBounds: Self = Self(1 << 3);
pub const NSMatchingWithoutAnchoringBounds: Self = Self(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);
}
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSMatchingFlags(pub NSUInteger);
impl NSMatchingFlags {
pub const NSMatchingProgress: Self = Self(1 << 0);
pub const NSMatchingCompleted: Self = Self(1 << 1);
pub const NSMatchingHitEnd: Self = Self(1 << 2);
pub const NSMatchingRequiredEnd: Self = Self(1 << 3);
pub const NSMatchingInternalError: Self = Self(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);
}
extern_methods!(
unsafe impl NSRegularExpression {
#[cfg(all(
feature = "NSRange",
feature = "NSString",
feature = "NSTextCheckingResult",
feature = "block2"
))]
#[method(enumerateMatchesInString:options:range:usingBlock:)]
pub unsafe fn enumerateMatchesInString_options_range_usingBlock(
&self,
string: &NSString,
options: NSMatchingOptions,
range: NSRange,
block: &Block<dyn Fn(*mut NSTextCheckingResult, NSMatchingFlags, NonNull<Bool>) + '_>,
);
#[cfg(all(
feature = "NSArray",
feature = "NSRange",
feature = "NSString",
feature = "NSTextCheckingResult"
))]
#[method_id(@__retain_semantics Other matchesInString:options:range:)]
pub unsafe fn matchesInString_options_range(
&self,
string: &NSString,
options: NSMatchingOptions,
range: NSRange,
) -> Id<NSArray<NSTextCheckingResult>>;
#[cfg(all(feature = "NSRange", feature = "NSString"))]
#[method(numberOfMatchesInString:options:range:)]
pub unsafe fn numberOfMatchesInString_options_range(
&self,
string: &NSString,
options: NSMatchingOptions,
range: NSRange,
) -> NSUInteger;
#[cfg(all(
feature = "NSRange",
feature = "NSString",
feature = "NSTextCheckingResult"
))]
#[method_id(@__retain_semantics Other firstMatchInString:options:range:)]
pub unsafe fn firstMatchInString_options_range(
&self,
string: &NSString,
options: NSMatchingOptions,
range: NSRange,
) -> Option<Id<NSTextCheckingResult>>;
#[cfg(all(feature = "NSRange", feature = "NSString"))]
#[method(rangeOfFirstMatchInString:options:range:)]
pub unsafe fn rangeOfFirstMatchInString_options_range(
&self,
string: &NSString,
options: NSMatchingOptions,
range: NSRange,
) -> NSRange;
}
);
extern_methods!(
unsafe impl NSRegularExpression {
#[cfg(all(feature = "NSRange", feature = "NSString"))]
#[method_id(@__retain_semantics Other stringByReplacingMatchesInString:options:range:withTemplate:)]
pub unsafe fn stringByReplacingMatchesInString_options_range_withTemplate(
&self,
string: &NSString,
options: NSMatchingOptions,
range: NSRange,
templ: &NSString,
) -> Id<NSString>;
#[cfg(all(feature = "NSRange", feature = "NSString"))]
#[method(replaceMatchesInString:options:range:withTemplate:)]
pub unsafe fn replaceMatchesInString_options_range_withTemplate(
&self,
string: &NSMutableString,
options: NSMatchingOptions,
range: NSRange,
templ: &NSString,
) -> NSUInteger;
#[cfg(all(feature = "NSString", feature = "NSTextCheckingResult"))]
#[method_id(@__retain_semantics Other replacementStringForResult:inString:offset:template:)]
pub unsafe fn replacementStringForResult_inString_offset_template(
&self,
result: &NSTextCheckingResult,
string: &NSString,
offset: NSInteger,
templ: &NSString,
) -> Id<NSString>;
#[cfg(feature = "NSString")]
#[method_id(@__retain_semantics Other escapedTemplateForString:)]
pub unsafe fn escapedTemplateForString(string: &NSString) -> Id<NSString>;
}
);
extern_class!(
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct NSDataDetector;
unsafe impl ClassType for NSDataDetector {
#[inherits(NSObject)]
type Super = NSRegularExpression;
type Mutability = InteriorMutable;
}
);
#[cfg(feature = "NSObject")]
unsafe impl NSCoding for NSDataDetector {}
#[cfg(feature = "NSObject")]
unsafe impl NSCopying for NSDataDetector {}
unsafe impl NSObjectProtocol for NSDataDetector {}
#[cfg(feature = "NSObject")]
unsafe impl NSSecureCoding for NSDataDetector {}
extern_methods!(
unsafe impl NSDataDetector {
#[cfg(all(feature = "NSError", feature = "NSTextCheckingResult"))]
#[method_id(@__retain_semantics Other dataDetectorWithTypes:error:_)]
pub unsafe fn dataDetectorWithTypes_error(
checking_types: NSTextCheckingTypes,
) -> Result<Id<NSDataDetector>, Id<NSError>>;
#[cfg(all(feature = "NSError", feature = "NSTextCheckingResult"))]
#[method_id(@__retain_semantics Init initWithTypes:error:_)]
pub unsafe fn initWithTypes_error(
this: Allocated<Self>,
checking_types: NSTextCheckingTypes,
) -> Result<Id<Self>, Id<NSError>>;
#[cfg(feature = "NSTextCheckingResult")]
#[method(checkingTypes)]
pub unsafe fn checkingTypes(&self) -> NSTextCheckingTypes;
}
);
extern_methods!(
unsafe impl NSDataDetector {
#[cfg(all(feature = "NSError", feature = "NSString"))]
#[method_id(@__retain_semantics Init initWithPattern:options:error:_)]
pub unsafe fn initWithPattern_options_error(
this: Allocated<Self>,
pattern: &NSString,
options: NSRegularExpressionOptions,
) -> Result<Id<Self>, Id<NSError>>;
}
);
extern_methods!(
unsafe impl NSDataDetector {
#[method_id(@__retain_semantics Init init)]
pub unsafe fn init(this: Allocated<Self>) -> Id<Self>;
#[method_id(@__retain_semantics New new)]
pub unsafe fn new() -> Id<Self>;
}
);