objc2_foundation/generated/
NSRegularExpression.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsregularexpressionoptions?language=objc)
10// NS_OPTIONS
11#[repr(transparent)]
12#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
13pub struct NSRegularExpressionOptions(pub NSUInteger);
14bitflags::bitflags! {
15    impl NSRegularExpressionOptions: NSUInteger {
16        #[doc(alias = "NSRegularExpressionCaseInsensitive")]
17        const CaseInsensitive = 1<<0;
18        #[doc(alias = "NSRegularExpressionAllowCommentsAndWhitespace")]
19        const AllowCommentsAndWhitespace = 1<<1;
20        #[doc(alias = "NSRegularExpressionIgnoreMetacharacters")]
21        const IgnoreMetacharacters = 1<<2;
22        #[doc(alias = "NSRegularExpressionDotMatchesLineSeparators")]
23        const DotMatchesLineSeparators = 1<<3;
24        #[doc(alias = "NSRegularExpressionAnchorsMatchLines")]
25        const AnchorsMatchLines = 1<<4;
26        #[doc(alias = "NSRegularExpressionUseUnixLineSeparators")]
27        const UseUnixLineSeparators = 1<<5;
28        #[doc(alias = "NSRegularExpressionUseUnicodeWordBoundaries")]
29        const UseUnicodeWordBoundaries = 1<<6;
30    }
31}
32
33unsafe impl Encode for NSRegularExpressionOptions {
34    const ENCODING: Encoding = NSUInteger::ENCODING;
35}
36
37unsafe impl RefEncode for NSRegularExpressionOptions {
38    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
39}
40
41extern_class!(
42    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsregularexpression?language=objc)
43    #[unsafe(super(NSObject))]
44    #[derive(Debug, PartialEq, Eq, Hash)]
45    pub struct NSRegularExpression;
46);
47
48unsafe impl Send for NSRegularExpression {}
49
50unsafe impl Sync for NSRegularExpression {}
51
52#[cfg(feature = "NSObject")]
53unsafe impl NSCoding for NSRegularExpression {}
54
55#[cfg(feature = "NSObject")]
56unsafe impl NSCopying for NSRegularExpression {}
57
58#[cfg(feature = "NSObject")]
59unsafe impl CopyingHelper for NSRegularExpression {
60    type Result = Self;
61}
62
63unsafe impl NSObjectProtocol for NSRegularExpression {}
64
65#[cfg(feature = "NSObject")]
66unsafe impl NSSecureCoding for NSRegularExpression {}
67
68impl NSRegularExpression {
69    extern_methods!(
70        #[cfg(all(feature = "NSError", feature = "NSString"))]
71        #[unsafe(method(regularExpressionWithPattern:options:error:_))]
72        #[unsafe(method_family = none)]
73        pub unsafe fn regularExpressionWithPattern_options_error(
74            pattern: &NSString,
75            options: NSRegularExpressionOptions,
76        ) -> Result<Retained<NSRegularExpression>, Retained<NSError>>;
77
78        #[cfg(all(feature = "NSError", feature = "NSString"))]
79        #[unsafe(method(initWithPattern:options:error:_))]
80        #[unsafe(method_family = init)]
81        pub unsafe fn initWithPattern_options_error(
82            this: Allocated<Self>,
83            pattern: &NSString,
84            options: NSRegularExpressionOptions,
85        ) -> Result<Retained<Self>, Retained<NSError>>;
86
87        #[cfg(feature = "NSString")]
88        #[unsafe(method(pattern))]
89        #[unsafe(method_family = none)]
90        pub unsafe fn pattern(&self) -> Retained<NSString>;
91
92        #[unsafe(method(options))]
93        #[unsafe(method_family = none)]
94        pub unsafe fn options(&self) -> NSRegularExpressionOptions;
95
96        #[unsafe(method(numberOfCaptureGroups))]
97        #[unsafe(method_family = none)]
98        pub unsafe fn numberOfCaptureGroups(&self) -> NSUInteger;
99
100        #[cfg(feature = "NSString")]
101        #[unsafe(method(escapedPatternForString:))]
102        #[unsafe(method_family = none)]
103        pub unsafe fn escapedPatternForString(string: &NSString) -> Retained<NSString>;
104    );
105}
106
107/// Methods declared on superclass `NSObject`.
108impl NSRegularExpression {
109    extern_methods!(
110        #[unsafe(method(init))]
111        #[unsafe(method_family = init)]
112        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
113
114        #[unsafe(method(new))]
115        #[unsafe(method_family = new)]
116        pub unsafe fn new() -> Retained<Self>;
117    );
118}
119
120/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmatchingoptions?language=objc)
121// NS_OPTIONS
122#[repr(transparent)]
123#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
124pub struct NSMatchingOptions(pub NSUInteger);
125bitflags::bitflags! {
126    impl NSMatchingOptions: NSUInteger {
127        #[doc(alias = "NSMatchingReportProgress")]
128        const ReportProgress = 1<<0;
129        #[doc(alias = "NSMatchingReportCompletion")]
130        const ReportCompletion = 1<<1;
131        #[doc(alias = "NSMatchingAnchored")]
132        const Anchored = 1<<2;
133        #[doc(alias = "NSMatchingWithTransparentBounds")]
134        const WithTransparentBounds = 1<<3;
135        #[doc(alias = "NSMatchingWithoutAnchoringBounds")]
136        const WithoutAnchoringBounds = 1<<4;
137    }
138}
139
140unsafe impl Encode for NSMatchingOptions {
141    const ENCODING: Encoding = NSUInteger::ENCODING;
142}
143
144unsafe impl RefEncode for NSMatchingOptions {
145    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
146}
147
148/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmatchingflags?language=objc)
149// NS_OPTIONS
150#[repr(transparent)]
151#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
152pub struct NSMatchingFlags(pub NSUInteger);
153bitflags::bitflags! {
154    impl NSMatchingFlags: NSUInteger {
155        #[doc(alias = "NSMatchingProgress")]
156        const Progress = 1<<0;
157        #[doc(alias = "NSMatchingCompleted")]
158        const Completed = 1<<1;
159        #[doc(alias = "NSMatchingHitEnd")]
160        const HitEnd = 1<<2;
161        #[doc(alias = "NSMatchingRequiredEnd")]
162        const RequiredEnd = 1<<3;
163        #[doc(alias = "NSMatchingInternalError")]
164        const InternalError = 1<<4;
165    }
166}
167
168unsafe impl Encode for NSMatchingFlags {
169    const ENCODING: Encoding = NSUInteger::ENCODING;
170}
171
172unsafe impl RefEncode for NSMatchingFlags {
173    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
174}
175
176/// NSMatching.
177impl NSRegularExpression {
178    extern_methods!(
179        #[cfg(all(
180            feature = "NSRange",
181            feature = "NSString",
182            feature = "NSTextCheckingResult",
183            feature = "block2"
184        ))]
185        #[unsafe(method(enumerateMatchesInString:options:range:usingBlock:))]
186        #[unsafe(method_family = none)]
187        pub unsafe fn enumerateMatchesInString_options_range_usingBlock(
188            &self,
189            string: &NSString,
190            options: NSMatchingOptions,
191            range: NSRange,
192            block: &block2::Block<
193                dyn Fn(*mut NSTextCheckingResult, NSMatchingFlags, NonNull<Bool>) + '_,
194            >,
195        );
196
197        #[cfg(all(
198            feature = "NSArray",
199            feature = "NSRange",
200            feature = "NSString",
201            feature = "NSTextCheckingResult"
202        ))]
203        #[unsafe(method(matchesInString:options:range:))]
204        #[unsafe(method_family = none)]
205        pub unsafe fn matchesInString_options_range(
206            &self,
207            string: &NSString,
208            options: NSMatchingOptions,
209            range: NSRange,
210        ) -> Retained<NSArray<NSTextCheckingResult>>;
211
212        #[cfg(all(feature = "NSRange", feature = "NSString"))]
213        #[unsafe(method(numberOfMatchesInString:options:range:))]
214        #[unsafe(method_family = none)]
215        pub unsafe fn numberOfMatchesInString_options_range(
216            &self,
217            string: &NSString,
218            options: NSMatchingOptions,
219            range: NSRange,
220        ) -> NSUInteger;
221
222        #[cfg(all(
223            feature = "NSRange",
224            feature = "NSString",
225            feature = "NSTextCheckingResult"
226        ))]
227        #[unsafe(method(firstMatchInString:options:range:))]
228        #[unsafe(method_family = none)]
229        pub unsafe fn firstMatchInString_options_range(
230            &self,
231            string: &NSString,
232            options: NSMatchingOptions,
233            range: NSRange,
234        ) -> Option<Retained<NSTextCheckingResult>>;
235
236        #[cfg(all(feature = "NSRange", feature = "NSString"))]
237        #[unsafe(method(rangeOfFirstMatchInString:options:range:))]
238        #[unsafe(method_family = none)]
239        pub unsafe fn rangeOfFirstMatchInString_options_range(
240            &self,
241            string: &NSString,
242            options: NSMatchingOptions,
243            range: NSRange,
244        ) -> NSRange;
245    );
246}
247
248/// NSReplacement.
249impl NSRegularExpression {
250    extern_methods!(
251        #[cfg(all(feature = "NSRange", feature = "NSString"))]
252        #[unsafe(method(stringByReplacingMatchesInString:options:range:withTemplate:))]
253        #[unsafe(method_family = none)]
254        pub unsafe fn stringByReplacingMatchesInString_options_range_withTemplate(
255            &self,
256            string: &NSString,
257            options: NSMatchingOptions,
258            range: NSRange,
259            templ: &NSString,
260        ) -> Retained<NSString>;
261
262        #[cfg(all(feature = "NSRange", feature = "NSString"))]
263        #[unsafe(method(replaceMatchesInString:options:range:withTemplate:))]
264        #[unsafe(method_family = none)]
265        pub unsafe fn replaceMatchesInString_options_range_withTemplate(
266            &self,
267            string: &NSMutableString,
268            options: NSMatchingOptions,
269            range: NSRange,
270            templ: &NSString,
271        ) -> NSUInteger;
272
273        #[cfg(all(feature = "NSString", feature = "NSTextCheckingResult"))]
274        #[unsafe(method(replacementStringForResult:inString:offset:template:))]
275        #[unsafe(method_family = none)]
276        pub unsafe fn replacementStringForResult_inString_offset_template(
277            &self,
278            result: &NSTextCheckingResult,
279            string: &NSString,
280            offset: NSInteger,
281            templ: &NSString,
282        ) -> Retained<NSString>;
283
284        #[cfg(feature = "NSString")]
285        #[unsafe(method(escapedTemplateForString:))]
286        #[unsafe(method_family = none)]
287        pub unsafe fn escapedTemplateForString(string: &NSString) -> Retained<NSString>;
288    );
289}
290
291extern_class!(
292    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsdatadetector?language=objc)
293    #[unsafe(super(NSRegularExpression, NSObject))]
294    #[derive(Debug, PartialEq, Eq, Hash)]
295    pub struct NSDataDetector;
296);
297
298#[cfg(feature = "NSObject")]
299unsafe impl NSCoding for NSDataDetector {}
300
301#[cfg(feature = "NSObject")]
302unsafe impl NSCopying for NSDataDetector {}
303
304#[cfg(feature = "NSObject")]
305unsafe impl CopyingHelper for NSDataDetector {
306    type Result = Self;
307}
308
309unsafe impl NSObjectProtocol for NSDataDetector {}
310
311#[cfg(feature = "NSObject")]
312unsafe impl NSSecureCoding for NSDataDetector {}
313
314impl NSDataDetector {
315    extern_methods!(
316        #[cfg(all(feature = "NSError", feature = "NSTextCheckingResult"))]
317        #[unsafe(method(dataDetectorWithTypes:error:_))]
318        #[unsafe(method_family = none)]
319        pub unsafe fn dataDetectorWithTypes_error(
320            checking_types: NSTextCheckingTypes,
321        ) -> Result<Retained<NSDataDetector>, Retained<NSError>>;
322
323        #[cfg(all(feature = "NSError", feature = "NSTextCheckingResult"))]
324        #[unsafe(method(initWithTypes:error:_))]
325        #[unsafe(method_family = init)]
326        pub unsafe fn initWithTypes_error(
327            this: Allocated<Self>,
328            checking_types: NSTextCheckingTypes,
329        ) -> Result<Retained<Self>, Retained<NSError>>;
330
331        #[cfg(feature = "NSTextCheckingResult")]
332        #[unsafe(method(checkingTypes))]
333        #[unsafe(method_family = none)]
334        pub unsafe fn checkingTypes(&self) -> NSTextCheckingTypes;
335    );
336}
337
338/// Methods declared on superclass `NSRegularExpression`.
339impl NSDataDetector {
340    extern_methods!(
341        #[cfg(all(feature = "NSError", feature = "NSString"))]
342        #[unsafe(method(initWithPattern:options:error:_))]
343        #[unsafe(method_family = init)]
344        pub unsafe fn initWithPattern_options_error(
345            this: Allocated<Self>,
346            pattern: &NSString,
347            options: NSRegularExpressionOptions,
348        ) -> Result<Retained<Self>, Retained<NSError>>;
349    );
350}
351
352/// Methods declared on superclass `NSObject`.
353impl NSDataDetector {
354    extern_methods!(
355        #[unsafe(method(init))]
356        #[unsafe(method_family = init)]
357        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
358
359        #[unsafe(method(new))]
360        #[unsafe(method_family = new)]
361        pub unsafe fn new() -> Retained<Self>;
362    );
363}