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