rust_macios/foundation/
ns_character_set.rs1use objc::{msg_send, sel, sel_impl};
2
3use crate::{object,
4 objective_c_runtime::{
5 macros::{interface_impl},
6 traits::{FromId, PNSObject},
7 },
8 utils::to_bool,
9};
10
11use super::{unichar, NSCoder, NSData, NSRange, NSString, UInt8};
12
13object! {
14 unsafe pub struct NSCharacterSet;
16}
17
18#[interface_impl(NSObject)]
19impl NSCharacterSet {
20 #[property]
25 pub fn alphanumeric_character_set() -> NSCharacterSet {
26 unsafe { NSCharacterSet::from_id(msg_send![Self::m_class(), alphanumericCharacterSet]) }
27 }
28
29 #[property]
31 pub fn capitalized_letter_character_set() -> NSCharacterSet {
32 unsafe {
33 NSCharacterSet::from_id(msg_send![Self::m_class(), capitalizedLetterCharacterSet])
34 }
35 }
36
37 #[property]
39 pub fn control_character_set() -> NSCharacterSet {
40 unsafe { NSCharacterSet::from_id(msg_send![Self::m_class(), controlCharacterSet]) }
41 }
42
43 #[property]
45 pub fn decimal_digit_character_set() -> NSCharacterSet {
46 unsafe { NSCharacterSet::from_id(msg_send![Self::m_class(), decimalDigitCharacterSet]) }
47 }
48
49 #[property]
51 pub fn decomposable_character_set() -> NSCharacterSet {
52 unsafe { NSCharacterSet::from_id(msg_send![Self::m_class(), decomposableCharacterSet]) }
53 }
54
55 #[property]
57 pub fn illegal_character_set() -> NSCharacterSet {
58 unsafe { NSCharacterSet::from_id(msg_send![Self::m_class(), illegalCharacterSet]) }
59 }
60
61 #[property]
63 pub fn letter_character_set() -> NSCharacterSet {
64 unsafe { NSCharacterSet::from_id(msg_send![Self::m_class(), letterCharacterSet]) }
65 }
66
67 #[property]
69 pub fn lowercase_letter_character_set() -> NSCharacterSet {
70 unsafe { NSCharacterSet::from_id(msg_send![Self::m_class(), lowercaseLetterCharacterSet]) }
71 }
72
73 #[property]
75 pub fn newline_character_set() -> NSCharacterSet {
76 unsafe { NSCharacterSet::from_id(msg_send![Self::m_class(), newlineCharacterSet]) }
77 }
78
79 #[property]
81 pub fn non_base_character_set() -> NSCharacterSet {
82 unsafe { NSCharacterSet::from_id(msg_send![Self::m_class(), nonBaseCharacterSet]) }
83 }
84
85 #[property]
87 pub fn punctuation_character_set() -> NSCharacterSet {
88 unsafe { NSCharacterSet::from_id(msg_send![Self::m_class(), punctuationCharacterSet]) }
89 }
90
91 #[property]
93 pub fn symbol_character_set() -> NSCharacterSet {
94 unsafe { NSCharacterSet::from_id(msg_send![Self::m_class(), symbolCharacterSet]) }
95 }
96
97 #[property]
99 pub fn uppercase_letter_character_set() -> NSCharacterSet {
100 unsafe { NSCharacterSet::from_id(msg_send![Self::m_class(), uppercaseLetterCharacterSet]) }
101 }
102
103 #[property]
105 pub fn whitespace_and_newline_character_set() -> NSCharacterSet {
106 unsafe {
107 NSCharacterSet::from_id(msg_send![Self::m_class(), whitespaceAndNewlineCharacterSet])
108 }
109 }
110
111 #[property]
113 pub fn whitespace_character_set() -> NSCharacterSet {
114 unsafe { NSCharacterSet::from_id(msg_send![Self::m_class(), whitespaceCharacterSet]) }
115 }
116
117 #[property]
122 pub fn url_fragment_allowed_character_set() -> NSCharacterSet {
123 unsafe {
124 NSCharacterSet::from_id(msg_send![Self::m_class(), URLFragmentAllowedCharacterSet])
125 }
126 }
127
128 #[property]
130 pub fn url_host_allowed_character_set() -> NSCharacterSet {
131 unsafe { NSCharacterSet::from_id(msg_send![Self::m_class(), URLHostAllowedCharacterSet]) }
132 }
133
134 #[property]
136 pub fn url_password_allowed_character_set() -> NSCharacterSet {
137 unsafe {
138 NSCharacterSet::from_id(msg_send![Self::m_class(), URLPasswordAllowedCharacterSet])
139 }
140 }
141
142 #[property]
144 pub fn url_path_allowed_character_set() -> NSCharacterSet {
145 unsafe { NSCharacterSet::from_id(msg_send![Self::m_class(), URLPathAllowedCharacterSet]) }
146 }
147
148 #[property]
150 pub fn url_query_allowed_character_set() -> NSCharacterSet {
151 unsafe { NSCharacterSet::from_id(msg_send![Self::m_class(), URLQueryAllowedCharacterSet]) }
152 }
153
154 #[property]
156 pub fn url_user_allowed_character_set() -> NSCharacterSet {
157 unsafe { NSCharacterSet::from_id(msg_send![Self::m_class(), URLUserAllowedCharacterSet]) }
158 }
159
160 #[method]
165 pub fn init_with_coder(mut self, coder: NSCoder) -> Self
166 where
167 Self: Sized + FromId,
168 {
169 unsafe { Self::from_id(msg_send![self.m_self(), initWithCoder: coder]) }
170 }
171
172 #[method]
174 pub fn character_set_with_characters_in_string(string: NSString) -> NSCharacterSet {
175 unsafe {
176 NSCharacterSet::from_id(msg_send![
177 Self::m_class(),
178 characterSetWithCharactersInString: string
179 ])
180 }
181 }
182
183 #[method]
185 pub fn character_set_with_range(range: NSRange) -> NSCharacterSet {
186 unsafe { NSCharacterSet::from_id(msg_send![Self::m_class(), characterSetWithRange: range]) }
187 }
188
189 #[method]
194 pub fn character_set_with_bitmap_representation(data: NSData) -> NSCharacterSet {
195 unsafe {
196 NSCharacterSet::from_id(msg_send![
197 Self::m_class(),
198 characterSetWithBitmapRepresentation: data
199 ])
200 }
201 }
202
203 #[method]
205 pub fn character_set_with_contents_of_file(path: NSString) -> NSCharacterSet {
206 unsafe {
207 NSCharacterSet::from_id(msg_send![
208 Self::m_class(),
209 characterSetWithContentsOfFile: path
210 ])
211 }
212 }
213
214 #[property]
216 pub fn bitmap_representation(&self) -> NSData {
217 unsafe { NSData::from_id(msg_send![self.m_self(), bitmapRepresentation]) }
218 }
219
220 #[property]
222 pub fn inverted_set(&self) -> NSCharacterSet {
223 unsafe { NSCharacterSet::from_id(msg_send![self.m_self(), invertedSet]) }
224 }
225
226 #[method]
231 pub fn character_is_member(&self, character: unichar) -> bool {
232 unsafe { to_bool(msg_send![self.m_self(), characterIsMember: character]) }
233 }
234
235 #[method]
237 pub fn has_member_in_plane(&self, plane: UInt8) -> bool {
238 unsafe { to_bool(msg_send![self.m_self(), hasMemberInPlane: plane]) }
239 }
240
241 #[method]
243 pub fn is_superset_of_set(&self, other: NSCharacterSet) -> bool {
244 unsafe { to_bool(msg_send![self.m_self(), isSupersetOfSet: other]) }
245 }
246
247 #[method]
249 pub fn long_character_is_member(&self, long_char: u32) -> bool {
250 unsafe { to_bool(msg_send![self.m_self(), longCharacterIsMember: long_char]) }
251 }
252}