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