1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9pub type unichar = c_ushort;
11
12#[repr(transparent)]
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
16pub struct NSStringCompareOptions(pub NSUInteger);
17bitflags::bitflags! {
18 impl NSStringCompareOptions: NSUInteger {
19 #[doc(alias = "NSCaseInsensitiveSearch")]
20 const CaseInsensitiveSearch = 1;
21 #[doc(alias = "NSLiteralSearch")]
22 const LiteralSearch = 2;
23 #[doc(alias = "NSBackwardsSearch")]
24 const BackwardsSearch = 4;
25 #[doc(alias = "NSAnchoredSearch")]
26 const AnchoredSearch = 8;
27 #[doc(alias = "NSNumericSearch")]
28 const NumericSearch = 64;
29 #[doc(alias = "NSDiacriticInsensitiveSearch")]
30 const DiacriticInsensitiveSearch = 128;
31 #[doc(alias = "NSWidthInsensitiveSearch")]
32 const WidthInsensitiveSearch = 256;
33 #[doc(alias = "NSForcedOrderingSearch")]
34 const ForcedOrderingSearch = 512;
35 #[doc(alias = "NSRegularExpressionSearch")]
36 const RegularExpressionSearch = 1024;
37 }
38}
39
40unsafe impl Encode for NSStringCompareOptions {
41 const ENCODING: Encoding = NSUInteger::ENCODING;
42}
43
44unsafe impl RefEncode for NSStringCompareOptions {
45 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
46}
47
48pub type NSStringEncoding = NSUInteger;
50
51pub const NSASCIIStringEncoding: NSStringEncoding = 1;
53pub const NSNEXTSTEPStringEncoding: NSStringEncoding = 2;
55pub const NSJapaneseEUCStringEncoding: NSStringEncoding = 3;
57pub const NSUTF8StringEncoding: NSStringEncoding = 4;
59pub const NSISOLatin1StringEncoding: NSStringEncoding = 5;
61pub const NSSymbolStringEncoding: NSStringEncoding = 6;
63pub const NSNonLossyASCIIStringEncoding: NSStringEncoding = 7;
65pub const NSShiftJISStringEncoding: NSStringEncoding = 8;
67pub const NSISOLatin2StringEncoding: NSStringEncoding = 9;
69pub const NSUnicodeStringEncoding: NSStringEncoding = 10;
71pub const NSWindowsCP1251StringEncoding: NSStringEncoding = 11;
73pub const NSWindowsCP1252StringEncoding: NSStringEncoding = 12;
75pub const NSWindowsCP1253StringEncoding: NSStringEncoding = 13;
77pub const NSWindowsCP1254StringEncoding: NSStringEncoding = 14;
79pub const NSWindowsCP1250StringEncoding: NSStringEncoding = 15;
81pub const NSISO2022JPStringEncoding: NSStringEncoding = 21;
83pub const NSMacOSRomanStringEncoding: NSStringEncoding = 30;
85pub const NSUTF16StringEncoding: NSStringEncoding = NSUnicodeStringEncoding;
87pub const NSUTF16BigEndianStringEncoding: NSStringEncoding = 0x90000100;
89pub const NSUTF16LittleEndianStringEncoding: NSStringEncoding = 0x94000100;
91pub const NSUTF32StringEncoding: NSStringEncoding = 0x8c000100;
93pub const NSUTF32BigEndianStringEncoding: NSStringEncoding = 0x98000100;
95pub const NSUTF32LittleEndianStringEncoding: NSStringEncoding = 0x9c000100;
97
98#[repr(transparent)]
101#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
102pub struct NSStringEncodingConversionOptions(pub NSUInteger);
103bitflags::bitflags! {
104 impl NSStringEncodingConversionOptions: NSUInteger {
105 #[doc(alias = "NSStringEncodingConversionAllowLossy")]
106 const AllowLossy = 1;
107 #[doc(alias = "NSStringEncodingConversionExternalRepresentation")]
108 const ExternalRepresentation = 2;
109 }
110}
111
112unsafe impl Encode for NSStringEncodingConversionOptions {
113 const ENCODING: Encoding = NSUInteger::ENCODING;
114}
115
116unsafe impl RefEncode for NSStringEncodingConversionOptions {
117 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
118}
119
120extern_class!(
121 #[unsafe(super(NSObject))]
123 #[derive(PartialEq, Eq, Hash)]
124 pub struct NSString;
125);
126
127#[cfg(feature = "NSObject")]
128unsafe impl NSCoding for NSString {}
129
130#[cfg(feature = "NSObject")]
131unsafe impl NSCopying for NSString {}
132
133#[cfg(feature = "NSObject")]
134unsafe impl CopyingHelper for NSString {
135 type Result = Self;
136}
137
138#[cfg(feature = "NSObject")]
139unsafe impl NSMutableCopying for NSString {}
140
141#[cfg(feature = "NSObject")]
142unsafe impl MutableCopyingHelper for NSString {
143 type Result = NSMutableString;
144}
145
146unsafe impl NSObjectProtocol for NSString {}
147
148#[cfg(feature = "NSObject")]
149unsafe impl NSSecureCoding for NSString {}
150
151impl NSString {
152 extern_methods!(
153 #[unsafe(method(length))]
154 #[unsafe(method_family = none)]
155 pub fn length(&self) -> NSUInteger;
156
157 #[unsafe(method(characterAtIndex:))]
158 #[unsafe(method_family = none)]
159 pub unsafe fn characterAtIndex(&self, index: NSUInteger) -> unichar;
160
161 #[unsafe(method(init))]
162 #[unsafe(method_family = init)]
163 pub fn init(this: Allocated<Self>) -> Retained<Self>;
164
165 #[cfg(feature = "NSCoder")]
166 #[unsafe(method(initWithCoder:))]
167 #[unsafe(method_family = init)]
168 pub unsafe fn initWithCoder(
169 this: Allocated<Self>,
170 coder: &NSCoder,
171 ) -> Option<Retained<Self>>;
172 );
173}
174
175impl NSString {
177 extern_methods!(
178 #[unsafe(method(new))]
179 #[unsafe(method_family = new)]
180 pub fn new() -> Retained<Self>;
181 );
182}
183
184impl DefaultRetained for NSString {
185 #[inline]
186 fn default_retained() -> Retained<Self> {
187 Self::new()
188 }
189}
190
191#[repr(transparent)]
194#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
195pub struct NSStringEnumerationOptions(pub NSUInteger);
196bitflags::bitflags! {
197 impl NSStringEnumerationOptions: NSUInteger {
198 #[doc(alias = "NSStringEnumerationByLines")]
199 const ByLines = 0;
200 #[doc(alias = "NSStringEnumerationByParagraphs")]
201 const ByParagraphs = 1;
202 #[doc(alias = "NSStringEnumerationByComposedCharacterSequences")]
203 const ByComposedCharacterSequences = 2;
204 #[doc(alias = "NSStringEnumerationByWords")]
205 const ByWords = 3;
206 #[doc(alias = "NSStringEnumerationBySentences")]
207 const BySentences = 4;
208 #[doc(alias = "NSStringEnumerationByCaretPositions")]
209 const ByCaretPositions = 5;
210 #[doc(alias = "NSStringEnumerationByDeletionClusters")]
211 const ByDeletionClusters = 6;
212 #[doc(alias = "NSStringEnumerationReverse")]
213 const Reverse = 1<<8;
214 #[doc(alias = "NSStringEnumerationSubstringNotRequired")]
215 const SubstringNotRequired = 1<<9;
216 #[doc(alias = "NSStringEnumerationLocalized")]
217 const Localized = 1<<10;
218 }
219}
220
221unsafe impl Encode for NSStringEnumerationOptions {
222 const ENCODING: Encoding = NSUInteger::ENCODING;
223}
224
225unsafe impl RefEncode for NSStringEnumerationOptions {
226 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
227}
228
229pub type NSStringTransform = NSString;
232
233extern "C" {
234 pub static NSStringTransformLatinToKatakana: &'static NSStringTransform;
236}
237
238extern "C" {
239 pub static NSStringTransformLatinToHiragana: &'static NSStringTransform;
241}
242
243extern "C" {
244 pub static NSStringTransformLatinToHangul: &'static NSStringTransform;
246}
247
248extern "C" {
249 pub static NSStringTransformLatinToArabic: &'static NSStringTransform;
251}
252
253extern "C" {
254 pub static NSStringTransformLatinToHebrew: &'static NSStringTransform;
256}
257
258extern "C" {
259 pub static NSStringTransformLatinToThai: &'static NSStringTransform;
261}
262
263extern "C" {
264 pub static NSStringTransformLatinToCyrillic: &'static NSStringTransform;
266}
267
268extern "C" {
269 pub static NSStringTransformLatinToGreek: &'static NSStringTransform;
271}
272
273extern "C" {
274 pub static NSStringTransformToLatin: &'static NSStringTransform;
276}
277
278extern "C" {
279 pub static NSStringTransformMandarinToLatin: &'static NSStringTransform;
281}
282
283extern "C" {
284 pub static NSStringTransformHiraganaToKatakana: &'static NSStringTransform;
286}
287
288extern "C" {
289 pub static NSStringTransformFullwidthToHalfwidth: &'static NSStringTransform;
291}
292
293extern "C" {
294 pub static NSStringTransformToXMLHex: &'static NSStringTransform;
296}
297
298extern "C" {
299 pub static NSStringTransformToUnicodeName: &'static NSStringTransform;
301}
302
303extern "C" {
304 pub static NSStringTransformStripCombiningMarks: &'static NSStringTransform;
306}
307
308extern "C" {
309 pub static NSStringTransformStripDiacritics: &'static NSStringTransform;
311}
312
313impl NSString {
315 extern_methods!(
316 #[unsafe(method(substringFromIndex:))]
317 #[unsafe(method_family = none)]
318 pub unsafe fn substringFromIndex(&self, from: NSUInteger) -> Retained<NSString>;
319
320 #[unsafe(method(substringToIndex:))]
321 #[unsafe(method_family = none)]
322 pub unsafe fn substringToIndex(&self, to: NSUInteger) -> Retained<NSString>;
323
324 #[cfg(feature = "NSRange")]
325 #[unsafe(method(substringWithRange:))]
326 #[unsafe(method_family = none)]
327 pub unsafe fn substringWithRange(&self, range: NSRange) -> Retained<NSString>;
328
329 #[cfg(feature = "NSRange")]
330 #[unsafe(method(getCharacters:range:))]
331 #[unsafe(method_family = none)]
332 pub unsafe fn getCharacters_range(&self, buffer: NonNull<unichar>, range: NSRange);
333
334 #[cfg(feature = "NSObjCRuntime")]
335 #[unsafe(method(compare:))]
336 #[unsafe(method_family = none)]
337 pub fn compare(&self, string: &NSString) -> NSComparisonResult;
338
339 #[cfg(feature = "NSObjCRuntime")]
340 #[unsafe(method(compare:options:))]
341 #[unsafe(method_family = none)]
342 pub unsafe fn compare_options(
343 &self,
344 string: &NSString,
345 mask: NSStringCompareOptions,
346 ) -> NSComparisonResult;
347
348 #[cfg(all(feature = "NSObjCRuntime", feature = "NSRange"))]
349 #[unsafe(method(compare:options:range:))]
350 #[unsafe(method_family = none)]
351 pub unsafe fn compare_options_range(
352 &self,
353 string: &NSString,
354 mask: NSStringCompareOptions,
355 range_of_receiver_to_compare: NSRange,
356 ) -> NSComparisonResult;
357
358 #[cfg(all(feature = "NSObjCRuntime", feature = "NSRange"))]
359 #[unsafe(method(compare:options:range:locale:))]
360 #[unsafe(method_family = none)]
361 pub unsafe fn compare_options_range_locale(
362 &self,
363 string: &NSString,
364 mask: NSStringCompareOptions,
365 range_of_receiver_to_compare: NSRange,
366 locale: Option<&AnyObject>,
367 ) -> NSComparisonResult;
368
369 #[cfg(feature = "NSObjCRuntime")]
370 #[unsafe(method(caseInsensitiveCompare:))]
371 #[unsafe(method_family = none)]
372 pub unsafe fn caseInsensitiveCompare(&self, string: &NSString) -> NSComparisonResult;
373
374 #[cfg(feature = "NSObjCRuntime")]
375 #[unsafe(method(localizedCompare:))]
376 #[unsafe(method_family = none)]
377 pub unsafe fn localizedCompare(&self, string: &NSString) -> NSComparisonResult;
378
379 #[cfg(feature = "NSObjCRuntime")]
380 #[unsafe(method(localizedCaseInsensitiveCompare:))]
381 #[unsafe(method_family = none)]
382 pub unsafe fn localizedCaseInsensitiveCompare(
383 &self,
384 string: &NSString,
385 ) -> NSComparisonResult;
386
387 #[cfg(feature = "NSObjCRuntime")]
388 #[unsafe(method(localizedStandardCompare:))]
389 #[unsafe(method_family = none)]
390 pub unsafe fn localizedStandardCompare(&self, string: &NSString) -> NSComparisonResult;
391
392 #[unsafe(method(isEqualToString:))]
393 #[unsafe(method_family = none)]
394 pub unsafe fn isEqualToString(&self, a_string: &NSString) -> bool;
395
396 #[unsafe(method(hasPrefix:))]
397 #[unsafe(method_family = none)]
398 pub fn hasPrefix(&self, str: &NSString) -> bool;
399
400 #[unsafe(method(hasSuffix:))]
401 #[unsafe(method_family = none)]
402 pub fn hasSuffix(&self, str: &NSString) -> bool;
403
404 #[unsafe(method(commonPrefixWithString:options:))]
405 #[unsafe(method_family = none)]
406 pub unsafe fn commonPrefixWithString_options(
407 &self,
408 str: &NSString,
409 mask: NSStringCompareOptions,
410 ) -> Retained<NSString>;
411
412 #[unsafe(method(containsString:))]
413 #[unsafe(method_family = none)]
414 pub unsafe fn containsString(&self, str: &NSString) -> bool;
415
416 #[unsafe(method(localizedCaseInsensitiveContainsString:))]
417 #[unsafe(method_family = none)]
418 pub unsafe fn localizedCaseInsensitiveContainsString(&self, str: &NSString) -> bool;
419
420 #[unsafe(method(localizedStandardContainsString:))]
421 #[unsafe(method_family = none)]
422 pub unsafe fn localizedStandardContainsString(&self, str: &NSString) -> bool;
423
424 #[cfg(feature = "NSRange")]
425 #[unsafe(method(localizedStandardRangeOfString:))]
426 #[unsafe(method_family = none)]
427 pub unsafe fn localizedStandardRangeOfString(&self, str: &NSString) -> NSRange;
428
429 #[cfg(feature = "NSRange")]
430 #[unsafe(method(rangeOfString:))]
431 #[unsafe(method_family = none)]
432 pub unsafe fn rangeOfString(&self, search_string: &NSString) -> NSRange;
433
434 #[cfg(feature = "NSRange")]
435 #[unsafe(method(rangeOfString:options:))]
436 #[unsafe(method_family = none)]
437 pub unsafe fn rangeOfString_options(
438 &self,
439 search_string: &NSString,
440 mask: NSStringCompareOptions,
441 ) -> NSRange;
442
443 #[cfg(feature = "NSRange")]
444 #[unsafe(method(rangeOfString:options:range:))]
445 #[unsafe(method_family = none)]
446 pub unsafe fn rangeOfString_options_range(
447 &self,
448 search_string: &NSString,
449 mask: NSStringCompareOptions,
450 range_of_receiver_to_search: NSRange,
451 ) -> NSRange;
452
453 #[cfg(all(feature = "NSLocale", feature = "NSRange"))]
454 #[unsafe(method(rangeOfString:options:range:locale:))]
455 #[unsafe(method_family = none)]
456 pub unsafe fn rangeOfString_options_range_locale(
457 &self,
458 search_string: &NSString,
459 mask: NSStringCompareOptions,
460 range_of_receiver_to_search: NSRange,
461 locale: Option<&NSLocale>,
462 ) -> NSRange;
463
464 #[cfg(all(feature = "NSCharacterSet", feature = "NSRange"))]
465 #[unsafe(method(rangeOfCharacterFromSet:))]
466 #[unsafe(method_family = none)]
467 pub unsafe fn rangeOfCharacterFromSet(&self, search_set: &NSCharacterSet) -> NSRange;
468
469 #[cfg(all(feature = "NSCharacterSet", feature = "NSRange"))]
470 #[unsafe(method(rangeOfCharacterFromSet:options:))]
471 #[unsafe(method_family = none)]
472 pub unsafe fn rangeOfCharacterFromSet_options(
473 &self,
474 search_set: &NSCharacterSet,
475 mask: NSStringCompareOptions,
476 ) -> NSRange;
477
478 #[cfg(all(feature = "NSCharacterSet", feature = "NSRange"))]
479 #[unsafe(method(rangeOfCharacterFromSet:options:range:))]
480 #[unsafe(method_family = none)]
481 pub unsafe fn rangeOfCharacterFromSet_options_range(
482 &self,
483 search_set: &NSCharacterSet,
484 mask: NSStringCompareOptions,
485 range_of_receiver_to_search: NSRange,
486 ) -> NSRange;
487
488 #[cfg(feature = "NSRange")]
489 #[unsafe(method(rangeOfComposedCharacterSequenceAtIndex:))]
490 #[unsafe(method_family = none)]
491 pub unsafe fn rangeOfComposedCharacterSequenceAtIndex(&self, index: NSUInteger) -> NSRange;
492
493 #[cfg(feature = "NSRange")]
494 #[unsafe(method(rangeOfComposedCharacterSequencesForRange:))]
495 #[unsafe(method_family = none)]
496 pub unsafe fn rangeOfComposedCharacterSequencesForRange(&self, range: NSRange) -> NSRange;
497
498 #[unsafe(method(stringByAppendingString:))]
499 #[unsafe(method_family = none)]
500 pub fn stringByAppendingString(&self, a_string: &NSString) -> Retained<NSString>;
501
502 #[unsafe(method(doubleValue))]
503 #[unsafe(method_family = none)]
504 pub unsafe fn doubleValue(&self) -> c_double;
505
506 #[unsafe(method(floatValue))]
507 #[unsafe(method_family = none)]
508 pub unsafe fn floatValue(&self) -> c_float;
509
510 #[unsafe(method(intValue))]
511 #[unsafe(method_family = none)]
512 pub unsafe fn intValue(&self) -> c_int;
513
514 #[unsafe(method(integerValue))]
515 #[unsafe(method_family = none)]
516 pub unsafe fn integerValue(&self) -> NSInteger;
517
518 #[unsafe(method(longLongValue))]
519 #[unsafe(method_family = none)]
520 pub unsafe fn longLongValue(&self) -> c_longlong;
521
522 #[unsafe(method(boolValue))]
523 #[unsafe(method_family = none)]
524 pub unsafe fn boolValue(&self) -> bool;
525
526 #[unsafe(method(uppercaseString))]
527 #[unsafe(method_family = none)]
528 pub unsafe fn uppercaseString(&self) -> Retained<NSString>;
529
530 #[unsafe(method(lowercaseString))]
531 #[unsafe(method_family = none)]
532 pub unsafe fn lowercaseString(&self) -> Retained<NSString>;
533
534 #[unsafe(method(capitalizedString))]
535 #[unsafe(method_family = none)]
536 pub unsafe fn capitalizedString(&self) -> Retained<NSString>;
537
538 #[unsafe(method(localizedUppercaseString))]
539 #[unsafe(method_family = none)]
540 pub unsafe fn localizedUppercaseString(&self) -> Retained<NSString>;
541
542 #[unsafe(method(localizedLowercaseString))]
543 #[unsafe(method_family = none)]
544 pub unsafe fn localizedLowercaseString(&self) -> Retained<NSString>;
545
546 #[unsafe(method(localizedCapitalizedString))]
547 #[unsafe(method_family = none)]
548 pub unsafe fn localizedCapitalizedString(&self) -> Retained<NSString>;
549
550 #[cfg(feature = "NSLocale")]
551 #[unsafe(method(uppercaseStringWithLocale:))]
552 #[unsafe(method_family = none)]
553 pub unsafe fn uppercaseStringWithLocale(
554 &self,
555 locale: Option<&NSLocale>,
556 ) -> Retained<NSString>;
557
558 #[cfg(feature = "NSLocale")]
559 #[unsafe(method(lowercaseStringWithLocale:))]
560 #[unsafe(method_family = none)]
561 pub unsafe fn lowercaseStringWithLocale(
562 &self,
563 locale: Option<&NSLocale>,
564 ) -> Retained<NSString>;
565
566 #[cfg(feature = "NSLocale")]
567 #[unsafe(method(capitalizedStringWithLocale:))]
568 #[unsafe(method_family = none)]
569 pub unsafe fn capitalizedStringWithLocale(
570 &self,
571 locale: Option<&NSLocale>,
572 ) -> Retained<NSString>;
573
574 #[cfg(feature = "NSRange")]
575 #[unsafe(method(getLineStart:end:contentsEnd:forRange:))]
576 #[unsafe(method_family = none)]
577 pub unsafe fn getLineStart_end_contentsEnd_forRange(
578 &self,
579 start_ptr: *mut NSUInteger,
580 line_end_ptr: *mut NSUInteger,
581 contents_end_ptr: *mut NSUInteger,
582 range: NSRange,
583 );
584
585 #[cfg(feature = "NSRange")]
586 #[unsafe(method(lineRangeForRange:))]
587 #[unsafe(method_family = none)]
588 pub unsafe fn lineRangeForRange(&self, range: NSRange) -> NSRange;
589
590 #[cfg(feature = "NSRange")]
591 #[unsafe(method(getParagraphStart:end:contentsEnd:forRange:))]
592 #[unsafe(method_family = none)]
593 pub unsafe fn getParagraphStart_end_contentsEnd_forRange(
594 &self,
595 start_ptr: *mut NSUInteger,
596 par_end_ptr: *mut NSUInteger,
597 contents_end_ptr: *mut NSUInteger,
598 range: NSRange,
599 );
600
601 #[cfg(feature = "NSRange")]
602 #[unsafe(method(paragraphRangeForRange:))]
603 #[unsafe(method_family = none)]
604 pub unsafe fn paragraphRangeForRange(&self, range: NSRange) -> NSRange;
605
606 #[cfg(all(feature = "NSRange", feature = "block2"))]
607 #[unsafe(method(enumerateSubstringsInRange:options:usingBlock:))]
608 #[unsafe(method_family = none)]
609 pub unsafe fn enumerateSubstringsInRange_options_usingBlock(
610 &self,
611 range: NSRange,
612 opts: NSStringEnumerationOptions,
613 block: &block2::Block<dyn Fn(*mut NSString, NSRange, NSRange, NonNull<Bool>)>,
614 );
615
616 #[cfg(feature = "block2")]
617 #[unsafe(method(enumerateLinesUsingBlock:))]
618 #[unsafe(method_family = none)]
619 pub unsafe fn enumerateLinesUsingBlock(
620 &self,
621 block: &block2::Block<dyn Fn(NonNull<NSString>, NonNull<Bool>)>,
622 );
623
624 #[unsafe(method(UTF8String))]
625 #[unsafe(method_family = none)]
626 pub fn UTF8String(&self) -> *const c_char;
627
628 #[unsafe(method(fastestEncoding))]
629 #[unsafe(method_family = none)]
630 pub unsafe fn fastestEncoding(&self) -> NSStringEncoding;
631
632 #[unsafe(method(smallestEncoding))]
633 #[unsafe(method_family = none)]
634 pub unsafe fn smallestEncoding(&self) -> NSStringEncoding;
635
636 #[cfg(feature = "NSData")]
637 #[unsafe(method(dataUsingEncoding:allowLossyConversion:))]
638 #[unsafe(method_family = none)]
639 pub unsafe fn dataUsingEncoding_allowLossyConversion(
640 &self,
641 encoding: NSStringEncoding,
642 lossy: bool,
643 ) -> Option<Retained<NSData>>;
644
645 #[cfg(feature = "NSData")]
646 #[unsafe(method(dataUsingEncoding:))]
647 #[unsafe(method_family = none)]
648 pub unsafe fn dataUsingEncoding(
649 &self,
650 encoding: NSStringEncoding,
651 ) -> Option<Retained<NSData>>;
652
653 #[unsafe(method(canBeConvertedToEncoding:))]
654 #[unsafe(method_family = none)]
655 pub unsafe fn canBeConvertedToEncoding(&self, encoding: NSStringEncoding) -> bool;
656
657 #[unsafe(method(cStringUsingEncoding:))]
658 #[unsafe(method_family = none)]
659 pub unsafe fn cStringUsingEncoding(&self, encoding: NSStringEncoding) -> *const c_char;
660
661 #[unsafe(method(getCString:maxLength:encoding:))]
662 #[unsafe(method_family = none)]
663 pub unsafe fn getCString_maxLength_encoding(
664 &self,
665 buffer: NonNull<c_char>,
666 max_buffer_count: NSUInteger,
667 encoding: NSStringEncoding,
668 ) -> bool;
669
670 #[cfg(feature = "NSRange")]
671 #[unsafe(method(getBytes:maxLength:usedLength:encoding:options:range:remainingRange:))]
672 #[unsafe(method_family = none)]
673 pub unsafe fn getBytes_maxLength_usedLength_encoding_options_range_remainingRange(
674 &self,
675 buffer: *mut c_void,
676 max_buffer_count: NSUInteger,
677 used_buffer_count: *mut NSUInteger,
678 encoding: NSStringEncoding,
679 options: NSStringEncodingConversionOptions,
680 range: NSRange,
681 leftover: NSRangePointer,
682 ) -> bool;
683
684 #[unsafe(method(maximumLengthOfBytesUsingEncoding:))]
685 #[unsafe(method_family = none)]
686 pub unsafe fn maximumLengthOfBytesUsingEncoding(&self, enc: NSStringEncoding)
687 -> NSUInteger;
688
689 #[unsafe(method(lengthOfBytesUsingEncoding:))]
690 #[unsafe(method_family = none)]
691 pub fn lengthOfBytesUsingEncoding(&self, enc: NSStringEncoding) -> NSUInteger;
692
693 #[unsafe(method(availableStringEncodings))]
694 #[unsafe(method_family = none)]
695 pub unsafe fn availableStringEncodings() -> NonNull<NSStringEncoding>;
696
697 #[unsafe(method(localizedNameOfStringEncoding:))]
698 #[unsafe(method_family = none)]
699 pub unsafe fn localizedNameOfStringEncoding(
700 encoding: NSStringEncoding,
701 ) -> Retained<NSString>;
702
703 #[unsafe(method(defaultCStringEncoding))]
704 #[unsafe(method_family = none)]
705 pub unsafe fn defaultCStringEncoding() -> NSStringEncoding;
706
707 #[unsafe(method(decomposedStringWithCanonicalMapping))]
708 #[unsafe(method_family = none)]
709 pub unsafe fn decomposedStringWithCanonicalMapping(&self) -> Retained<NSString>;
710
711 #[unsafe(method(precomposedStringWithCanonicalMapping))]
712 #[unsafe(method_family = none)]
713 pub unsafe fn precomposedStringWithCanonicalMapping(&self) -> Retained<NSString>;
714
715 #[unsafe(method(decomposedStringWithCompatibilityMapping))]
716 #[unsafe(method_family = none)]
717 pub unsafe fn decomposedStringWithCompatibilityMapping(&self) -> Retained<NSString>;
718
719 #[unsafe(method(precomposedStringWithCompatibilityMapping))]
720 #[unsafe(method_family = none)]
721 pub unsafe fn precomposedStringWithCompatibilityMapping(&self) -> Retained<NSString>;
722
723 #[cfg(feature = "NSArray")]
724 #[unsafe(method(componentsSeparatedByString:))]
725 #[unsafe(method_family = none)]
726 pub unsafe fn componentsSeparatedByString(
727 &self,
728 separator: &NSString,
729 ) -> Retained<NSArray<NSString>>;
730
731 #[cfg(all(feature = "NSArray", feature = "NSCharacterSet"))]
732 #[unsafe(method(componentsSeparatedByCharactersInSet:))]
733 #[unsafe(method_family = none)]
734 pub unsafe fn componentsSeparatedByCharactersInSet(
735 &self,
736 separator: &NSCharacterSet,
737 ) -> Retained<NSArray<NSString>>;
738
739 #[cfg(feature = "NSCharacterSet")]
740 #[unsafe(method(stringByTrimmingCharactersInSet:))]
741 #[unsafe(method_family = none)]
742 pub unsafe fn stringByTrimmingCharactersInSet(
743 &self,
744 set: &NSCharacterSet,
745 ) -> Retained<NSString>;
746
747 #[unsafe(method(stringByPaddingToLength:withString:startingAtIndex:))]
748 #[unsafe(method_family = none)]
749 pub unsafe fn stringByPaddingToLength_withString_startingAtIndex(
750 &self,
751 new_length: NSUInteger,
752 pad_string: &NSString,
753 pad_index: NSUInteger,
754 ) -> Retained<NSString>;
755
756 #[cfg(feature = "NSLocale")]
757 #[unsafe(method(stringByFoldingWithOptions:locale:))]
758 #[unsafe(method_family = none)]
759 pub unsafe fn stringByFoldingWithOptions_locale(
760 &self,
761 options: NSStringCompareOptions,
762 locale: Option<&NSLocale>,
763 ) -> Retained<NSString>;
764
765 #[cfg(feature = "NSRange")]
766 #[unsafe(method(stringByReplacingOccurrencesOfString:withString:options:range:))]
767 #[unsafe(method_family = none)]
768 pub unsafe fn stringByReplacingOccurrencesOfString_withString_options_range(
769 &self,
770 target: &NSString,
771 replacement: &NSString,
772 options: NSStringCompareOptions,
773 search_range: NSRange,
774 ) -> Retained<NSString>;
775
776 #[unsafe(method(stringByReplacingOccurrencesOfString:withString:))]
777 #[unsafe(method_family = none)]
778 pub unsafe fn stringByReplacingOccurrencesOfString_withString(
779 &self,
780 target: &NSString,
781 replacement: &NSString,
782 ) -> Retained<NSString>;
783
784 #[cfg(feature = "NSRange")]
785 #[unsafe(method(stringByReplacingCharactersInRange:withString:))]
786 #[unsafe(method_family = none)]
787 pub unsafe fn stringByReplacingCharactersInRange_withString(
788 &self,
789 range: NSRange,
790 replacement: &NSString,
791 ) -> Retained<NSString>;
792
793 #[unsafe(method(stringByApplyingTransform:reverse:))]
794 #[unsafe(method_family = none)]
795 pub unsafe fn stringByApplyingTransform_reverse(
796 &self,
797 transform: &NSStringTransform,
798 reverse: bool,
799 ) -> Option<Retained<NSString>>;
800
801 #[cfg(all(feature = "NSError", feature = "NSURL"))]
802 #[unsafe(method(writeToURL:atomically:encoding:error:_))]
803 #[unsafe(method_family = none)]
804 pub unsafe fn writeToURL_atomically_encoding_error(
805 &self,
806 url: &NSURL,
807 use_auxiliary_file: bool,
808 enc: NSStringEncoding,
809 ) -> Result<(), Retained<NSError>>;
810
811 #[cfg(feature = "NSError")]
812 #[unsafe(method(writeToFile:atomically:encoding:error:_))]
813 #[unsafe(method_family = none)]
814 pub unsafe fn writeToFile_atomically_encoding_error(
815 &self,
816 path: &NSString,
817 use_auxiliary_file: bool,
818 enc: NSStringEncoding,
819 ) -> Result<(), Retained<NSError>>;
820
821 #[unsafe(method(description))]
822 #[unsafe(method_family = none)]
823 pub unsafe fn description(&self) -> Retained<NSString>;
824
825 #[unsafe(method(hash))]
826 #[unsafe(method_family = none)]
827 pub unsafe fn hash(&self) -> NSUInteger;
828
829 #[unsafe(method(initWithCharactersNoCopy:length:freeWhenDone:))]
830 #[unsafe(method_family = init)]
831 pub unsafe fn initWithCharactersNoCopy_length_freeWhenDone(
832 this: Allocated<Self>,
833 characters: NonNull<unichar>,
834 length: NSUInteger,
835 free_buffer: bool,
836 ) -> Retained<Self>;
837
838 #[cfg(feature = "block2")]
839 #[unsafe(method(initWithCharactersNoCopy:length:deallocator:))]
840 #[unsafe(method_family = init)]
841 pub unsafe fn initWithCharactersNoCopy_length_deallocator(
842 this: Allocated<Self>,
843 chars: NonNull<unichar>,
844 len: NSUInteger,
845 deallocator: Option<&block2::Block<dyn Fn(NonNull<unichar>, NSUInteger)>>,
846 ) -> Retained<Self>;
847
848 #[unsafe(method(initWithCharacters:length:))]
849 #[unsafe(method_family = init)]
850 pub unsafe fn initWithCharacters_length(
851 this: Allocated<Self>,
852 characters: NonNull<unichar>,
853 length: NSUInteger,
854 ) -> Retained<Self>;
855
856 #[unsafe(method(initWithUTF8String:))]
857 #[unsafe(method_family = init)]
858 pub unsafe fn initWithUTF8String(
859 this: Allocated<Self>,
860 null_terminated_c_string: NonNull<c_char>,
861 ) -> Option<Retained<Self>>;
862
863 #[unsafe(method(initWithString:))]
864 #[unsafe(method_family = init)]
865 pub fn initWithString(this: Allocated<Self>, a_string: &NSString) -> Retained<Self>;
866
867 #[cfg(feature = "NSData")]
868 #[unsafe(method(initWithData:encoding:))]
869 #[unsafe(method_family = init)]
870 pub unsafe fn initWithData_encoding(
871 this: Allocated<Self>,
872 data: &NSData,
873 encoding: NSStringEncoding,
874 ) -> Option<Retained<Self>>;
875
876 #[unsafe(method(initWithBytes:length:encoding:))]
877 #[unsafe(method_family = init)]
878 pub unsafe fn initWithBytes_length_encoding(
879 this: Allocated<Self>,
880 bytes: NonNull<c_void>,
881 len: NSUInteger,
882 encoding: NSStringEncoding,
883 ) -> Option<Retained<Self>>;
884
885 #[unsafe(method(initWithBytesNoCopy:length:encoding:freeWhenDone:))]
886 #[unsafe(method_family = init)]
887 pub unsafe fn initWithBytesNoCopy_length_encoding_freeWhenDone(
888 this: Allocated<Self>,
889 bytes: NonNull<c_void>,
890 len: NSUInteger,
891 encoding: NSStringEncoding,
892 free_buffer: bool,
893 ) -> Option<Retained<Self>>;
894
895 #[cfg(feature = "block2")]
896 #[unsafe(method(initWithBytesNoCopy:length:encoding:deallocator:))]
897 #[unsafe(method_family = init)]
898 pub unsafe fn initWithBytesNoCopy_length_encoding_deallocator(
899 this: Allocated<Self>,
900 bytes: NonNull<c_void>,
901 len: NSUInteger,
902 encoding: NSStringEncoding,
903 deallocator: Option<&block2::Block<dyn Fn(NonNull<c_void>, NSUInteger)>>,
904 ) -> Option<Retained<Self>>;
905
906 #[unsafe(method(string))]
907 #[unsafe(method_family = none)]
908 pub unsafe fn string() -> Retained<Self>;
909
910 #[unsafe(method(stringWithString:))]
911 #[unsafe(method_family = none)]
912 pub fn stringWithString(string: &NSString) -> Retained<Self>;
913
914 #[unsafe(method(stringWithCharacters:length:))]
915 #[unsafe(method_family = none)]
916 pub unsafe fn stringWithCharacters_length(
917 characters: NonNull<unichar>,
918 length: NSUInteger,
919 ) -> Retained<Self>;
920
921 #[unsafe(method(stringWithUTF8String:))]
922 #[unsafe(method_family = none)]
923 pub unsafe fn stringWithUTF8String(
924 null_terminated_c_string: NonNull<c_char>,
925 ) -> Option<Retained<Self>>;
926
927 #[unsafe(method(initWithCString:encoding:))]
928 #[unsafe(method_family = init)]
929 pub unsafe fn initWithCString_encoding(
930 this: Allocated<Self>,
931 null_terminated_c_string: NonNull<c_char>,
932 encoding: NSStringEncoding,
933 ) -> Option<Retained<Self>>;
934
935 #[unsafe(method(stringWithCString:encoding:))]
936 #[unsafe(method_family = none)]
937 pub unsafe fn stringWithCString_encoding(
938 c_string: NonNull<c_char>,
939 enc: NSStringEncoding,
940 ) -> Option<Retained<Self>>;
941
942 #[cfg(all(feature = "NSError", feature = "NSURL"))]
943 #[unsafe(method(initWithContentsOfURL:encoding:error:_))]
944 #[unsafe(method_family = init)]
945 pub unsafe fn initWithContentsOfURL_encoding_error(
946 this: Allocated<Self>,
947 url: &NSURL,
948 enc: NSStringEncoding,
949 ) -> Result<Retained<Self>, Retained<NSError>>;
950
951 #[cfg(feature = "NSError")]
952 #[unsafe(method(initWithContentsOfFile:encoding:error:_))]
953 #[unsafe(method_family = init)]
954 pub unsafe fn initWithContentsOfFile_encoding_error(
955 this: Allocated<Self>,
956 path: &NSString,
957 enc: NSStringEncoding,
958 ) -> Result<Retained<Self>, Retained<NSError>>;
959
960 #[cfg(all(feature = "NSError", feature = "NSURL"))]
961 #[unsafe(method(stringWithContentsOfURL:encoding:error:_))]
962 #[unsafe(method_family = none)]
963 pub unsafe fn stringWithContentsOfURL_encoding_error(
964 url: &NSURL,
965 enc: NSStringEncoding,
966 ) -> Result<Retained<Self>, Retained<NSError>>;
967
968 #[cfg(feature = "NSError")]
969 #[unsafe(method(stringWithContentsOfFile:encoding:error:_))]
970 #[unsafe(method_family = none)]
971 pub unsafe fn stringWithContentsOfFile_encoding_error(
972 path: &NSString,
973 enc: NSStringEncoding,
974 ) -> Result<Retained<Self>, Retained<NSError>>;
975
976 #[cfg(all(feature = "NSError", feature = "NSURL"))]
977 #[unsafe(method(initWithContentsOfURL:usedEncoding:error:_))]
978 #[unsafe(method_family = init)]
979 pub unsafe fn initWithContentsOfURL_usedEncoding_error(
980 this: Allocated<Self>,
981 url: &NSURL,
982 enc: *mut NSStringEncoding,
983 ) -> Result<Retained<Self>, Retained<NSError>>;
984
985 #[cfg(feature = "NSError")]
986 #[unsafe(method(initWithContentsOfFile:usedEncoding:error:_))]
987 #[unsafe(method_family = init)]
988 pub unsafe fn initWithContentsOfFile_usedEncoding_error(
989 this: Allocated<Self>,
990 path: &NSString,
991 enc: *mut NSStringEncoding,
992 ) -> Result<Retained<Self>, Retained<NSError>>;
993
994 #[cfg(all(feature = "NSError", feature = "NSURL"))]
995 #[unsafe(method(stringWithContentsOfURL:usedEncoding:error:_))]
996 #[unsafe(method_family = none)]
997 pub unsafe fn stringWithContentsOfURL_usedEncoding_error(
998 url: &NSURL,
999 enc: *mut NSStringEncoding,
1000 ) -> Result<Retained<Self>, Retained<NSError>>;
1001
1002 #[cfg(feature = "NSError")]
1003 #[unsafe(method(stringWithContentsOfFile:usedEncoding:error:_))]
1004 #[unsafe(method_family = none)]
1005 pub unsafe fn stringWithContentsOfFile_usedEncoding_error(
1006 path: &NSString,
1007 enc: *mut NSStringEncoding,
1008 ) -> Result<Retained<Self>, Retained<NSError>>;
1009 );
1010}
1011
1012impl NSMutableString {
1016 extern_methods!(
1017 #[unsafe(method(initWithCharactersNoCopy:length:freeWhenDone:))]
1018 #[unsafe(method_family = init)]
1019 pub unsafe fn initWithCharactersNoCopy_length_freeWhenDone(
1020 this: Allocated<Self>,
1021 characters: NonNull<unichar>,
1022 length: NSUInteger,
1023 free_buffer: bool,
1024 ) -> Retained<Self>;
1025
1026 #[cfg(feature = "block2")]
1027 #[unsafe(method(initWithCharactersNoCopy:length:deallocator:))]
1028 #[unsafe(method_family = init)]
1029 pub unsafe fn initWithCharactersNoCopy_length_deallocator(
1030 this: Allocated<Self>,
1031 chars: NonNull<unichar>,
1032 len: NSUInteger,
1033 deallocator: Option<&block2::Block<dyn Fn(NonNull<unichar>, NSUInteger)>>,
1034 ) -> Retained<Self>;
1035
1036 #[unsafe(method(initWithCharacters:length:))]
1037 #[unsafe(method_family = init)]
1038 pub unsafe fn initWithCharacters_length(
1039 this: Allocated<Self>,
1040 characters: NonNull<unichar>,
1041 length: NSUInteger,
1042 ) -> Retained<Self>;
1043
1044 #[unsafe(method(initWithUTF8String:))]
1045 #[unsafe(method_family = init)]
1046 pub unsafe fn initWithUTF8String(
1047 this: Allocated<Self>,
1048 null_terminated_c_string: NonNull<c_char>,
1049 ) -> Option<Retained<Self>>;
1050
1051 #[unsafe(method(initWithString:))]
1052 #[unsafe(method_family = init)]
1053 pub fn initWithString(this: Allocated<Self>, a_string: &NSString) -> Retained<Self>;
1054
1055 #[cfg(feature = "NSData")]
1056 #[unsafe(method(initWithData:encoding:))]
1057 #[unsafe(method_family = init)]
1058 pub unsafe fn initWithData_encoding(
1059 this: Allocated<Self>,
1060 data: &NSData,
1061 encoding: NSStringEncoding,
1062 ) -> Option<Retained<Self>>;
1063
1064 #[unsafe(method(initWithBytes:length:encoding:))]
1065 #[unsafe(method_family = init)]
1066 pub unsafe fn initWithBytes_length_encoding(
1067 this: Allocated<Self>,
1068 bytes: NonNull<c_void>,
1069 len: NSUInteger,
1070 encoding: NSStringEncoding,
1071 ) -> Option<Retained<Self>>;
1072
1073 #[unsafe(method(initWithBytesNoCopy:length:encoding:freeWhenDone:))]
1074 #[unsafe(method_family = init)]
1075 pub unsafe fn initWithBytesNoCopy_length_encoding_freeWhenDone(
1076 this: Allocated<Self>,
1077 bytes: NonNull<c_void>,
1078 len: NSUInteger,
1079 encoding: NSStringEncoding,
1080 free_buffer: bool,
1081 ) -> Option<Retained<Self>>;
1082
1083 #[cfg(feature = "block2")]
1084 #[unsafe(method(initWithBytesNoCopy:length:encoding:deallocator:))]
1085 #[unsafe(method_family = init)]
1086 pub unsafe fn initWithBytesNoCopy_length_encoding_deallocator(
1087 this: Allocated<Self>,
1088 bytes: NonNull<c_void>,
1089 len: NSUInteger,
1090 encoding: NSStringEncoding,
1091 deallocator: Option<&block2::Block<dyn Fn(NonNull<c_void>, NSUInteger)>>,
1092 ) -> Option<Retained<Self>>;
1093
1094 #[unsafe(method(string))]
1095 #[unsafe(method_family = none)]
1096 pub unsafe fn string() -> Retained<Self>;
1097
1098 #[unsafe(method(stringWithString:))]
1099 #[unsafe(method_family = none)]
1100 pub fn stringWithString(string: &NSString) -> Retained<Self>;
1101
1102 #[unsafe(method(stringWithCharacters:length:))]
1103 #[unsafe(method_family = none)]
1104 pub unsafe fn stringWithCharacters_length(
1105 characters: NonNull<unichar>,
1106 length: NSUInteger,
1107 ) -> Retained<Self>;
1108
1109 #[unsafe(method(stringWithUTF8String:))]
1110 #[unsafe(method_family = none)]
1111 pub unsafe fn stringWithUTF8String(
1112 null_terminated_c_string: NonNull<c_char>,
1113 ) -> Option<Retained<Self>>;
1114
1115 #[unsafe(method(initWithCString:encoding:))]
1116 #[unsafe(method_family = init)]
1117 pub unsafe fn initWithCString_encoding(
1118 this: Allocated<Self>,
1119 null_terminated_c_string: NonNull<c_char>,
1120 encoding: NSStringEncoding,
1121 ) -> Option<Retained<Self>>;
1122
1123 #[unsafe(method(stringWithCString:encoding:))]
1124 #[unsafe(method_family = none)]
1125 pub unsafe fn stringWithCString_encoding(
1126 c_string: NonNull<c_char>,
1127 enc: NSStringEncoding,
1128 ) -> Option<Retained<Self>>;
1129
1130 #[cfg(all(feature = "NSError", feature = "NSURL"))]
1131 #[unsafe(method(initWithContentsOfURL:encoding:error:_))]
1132 #[unsafe(method_family = init)]
1133 pub unsafe fn initWithContentsOfURL_encoding_error(
1134 this: Allocated<Self>,
1135 url: &NSURL,
1136 enc: NSStringEncoding,
1137 ) -> Result<Retained<Self>, Retained<NSError>>;
1138
1139 #[cfg(feature = "NSError")]
1140 #[unsafe(method(initWithContentsOfFile:encoding:error:_))]
1141 #[unsafe(method_family = init)]
1142 pub unsafe fn initWithContentsOfFile_encoding_error(
1143 this: Allocated<Self>,
1144 path: &NSString,
1145 enc: NSStringEncoding,
1146 ) -> Result<Retained<Self>, Retained<NSError>>;
1147
1148 #[cfg(all(feature = "NSError", feature = "NSURL"))]
1149 #[unsafe(method(stringWithContentsOfURL:encoding:error:_))]
1150 #[unsafe(method_family = none)]
1151 pub unsafe fn stringWithContentsOfURL_encoding_error(
1152 url: &NSURL,
1153 enc: NSStringEncoding,
1154 ) -> Result<Retained<Self>, Retained<NSError>>;
1155
1156 #[cfg(feature = "NSError")]
1157 #[unsafe(method(stringWithContentsOfFile:encoding:error:_))]
1158 #[unsafe(method_family = none)]
1159 pub unsafe fn stringWithContentsOfFile_encoding_error(
1160 path: &NSString,
1161 enc: NSStringEncoding,
1162 ) -> Result<Retained<Self>, Retained<NSError>>;
1163
1164 #[cfg(all(feature = "NSError", feature = "NSURL"))]
1165 #[unsafe(method(initWithContentsOfURL:usedEncoding:error:_))]
1166 #[unsafe(method_family = init)]
1167 pub unsafe fn initWithContentsOfURL_usedEncoding_error(
1168 this: Allocated<Self>,
1169 url: &NSURL,
1170 enc: *mut NSStringEncoding,
1171 ) -> Result<Retained<Self>, Retained<NSError>>;
1172
1173 #[cfg(feature = "NSError")]
1174 #[unsafe(method(initWithContentsOfFile:usedEncoding:error:_))]
1175 #[unsafe(method_family = init)]
1176 pub unsafe fn initWithContentsOfFile_usedEncoding_error(
1177 this: Allocated<Self>,
1178 path: &NSString,
1179 enc: *mut NSStringEncoding,
1180 ) -> Result<Retained<Self>, Retained<NSError>>;
1181
1182 #[cfg(all(feature = "NSError", feature = "NSURL"))]
1183 #[unsafe(method(stringWithContentsOfURL:usedEncoding:error:_))]
1184 #[unsafe(method_family = none)]
1185 pub unsafe fn stringWithContentsOfURL_usedEncoding_error(
1186 url: &NSURL,
1187 enc: *mut NSStringEncoding,
1188 ) -> Result<Retained<Self>, Retained<NSError>>;
1189
1190 #[cfg(feature = "NSError")]
1191 #[unsafe(method(stringWithContentsOfFile:usedEncoding:error:_))]
1192 #[unsafe(method_family = none)]
1193 pub unsafe fn stringWithContentsOfFile_usedEncoding_error(
1194 path: &NSString,
1195 enc: *mut NSStringEncoding,
1196 ) -> Result<Retained<Self>, Retained<NSError>>;
1197 );
1198}
1199
1200pub type NSStringEncodingDetectionOptionsKey = NSString;
1203
1204extern "C" {
1205 pub static NSStringEncodingDetectionSuggestedEncodingsKey:
1207 &'static NSStringEncodingDetectionOptionsKey;
1208}
1209
1210extern "C" {
1211 pub static NSStringEncodingDetectionDisallowedEncodingsKey:
1213 &'static NSStringEncodingDetectionOptionsKey;
1214}
1215
1216extern "C" {
1217 pub static NSStringEncodingDetectionUseOnlySuggestedEncodingsKey:
1219 &'static NSStringEncodingDetectionOptionsKey;
1220}
1221
1222extern "C" {
1223 pub static NSStringEncodingDetectionAllowLossyKey: &'static NSStringEncodingDetectionOptionsKey;
1225}
1226
1227extern "C" {
1228 pub static NSStringEncodingDetectionFromWindowsKey:
1230 &'static NSStringEncodingDetectionOptionsKey;
1231}
1232
1233extern "C" {
1234 pub static NSStringEncodingDetectionLossySubstitutionKey:
1236 &'static NSStringEncodingDetectionOptionsKey;
1237}
1238
1239extern "C" {
1240 pub static NSStringEncodingDetectionLikelyLanguageKey:
1242 &'static NSStringEncodingDetectionOptionsKey;
1243}
1244
1245impl NSString {
1247 extern_methods!(
1248 #[cfg(all(feature = "NSData", feature = "NSDictionary"))]
1249 #[unsafe(method(stringEncodingForData:encodingOptions:convertedString:usedLossyConversion:))]
1250 #[unsafe(method_family = none)]
1251 pub unsafe fn stringEncodingForData_encodingOptions_convertedString_usedLossyConversion(
1252 data: &NSData,
1253 opts: Option<&NSDictionary<NSStringEncodingDetectionOptionsKey, AnyObject>>,
1254 string: Option<&mut Option<Retained<NSString>>>,
1255 used_lossy_conversion: *mut Bool,
1256 ) -> NSStringEncoding;
1257 );
1258}
1259
1260impl NSString {
1262 extern_methods!();
1263}
1264
1265#[cfg(feature = "NSItemProvider")]
1266unsafe impl NSItemProviderReading for NSString {}
1267
1268#[cfg(feature = "NSItemProvider")]
1269unsafe impl NSItemProviderWriting for NSString {}
1270
1271extern_class!(
1272 #[unsafe(super(NSString, NSObject))]
1274 #[derive(Debug, PartialEq, Eq, Hash)]
1275 pub struct NSMutableString;
1276);
1277
1278#[cfg(feature = "NSObject")]
1279unsafe impl NSCoding for NSMutableString {}
1280
1281#[cfg(feature = "NSObject")]
1282unsafe impl NSCopying for NSMutableString {}
1283
1284#[cfg(feature = "NSObject")]
1285unsafe impl CopyingHelper for NSMutableString {
1286 type Result = NSString;
1287}
1288
1289#[cfg(feature = "NSObject")]
1290unsafe impl NSMutableCopying for NSMutableString {}
1291
1292#[cfg(feature = "NSObject")]
1293unsafe impl MutableCopyingHelper for NSMutableString {
1294 type Result = Self;
1295}
1296
1297unsafe impl NSObjectProtocol for NSMutableString {}
1298
1299#[cfg(feature = "NSObject")]
1300unsafe impl NSSecureCoding for NSMutableString {}
1301
1302impl NSMutableString {
1303 extern_methods!(
1304 #[cfg(feature = "NSRange")]
1305 #[unsafe(method(replaceCharactersInRange:withString:))]
1306 #[unsafe(method_family = none)]
1307 pub unsafe fn replaceCharactersInRange_withString(
1308 &self,
1309 range: NSRange,
1310 a_string: &NSString,
1311 );
1312 );
1313}
1314
1315impl NSMutableString {
1317 extern_methods!(
1318 #[unsafe(method(init))]
1319 #[unsafe(method_family = init)]
1320 pub fn init(this: Allocated<Self>) -> Retained<Self>;
1321
1322 #[cfg(feature = "NSCoder")]
1323 #[unsafe(method(initWithCoder:))]
1324 #[unsafe(method_family = init)]
1325 pub unsafe fn initWithCoder(
1326 this: Allocated<Self>,
1327 coder: &NSCoder,
1328 ) -> Option<Retained<Self>>;
1329 );
1330}
1331
1332impl NSMutableString {
1334 extern_methods!(
1335 #[unsafe(method(new))]
1336 #[unsafe(method_family = new)]
1337 pub fn new() -> Retained<Self>;
1338 );
1339}
1340
1341impl DefaultRetained for NSMutableString {
1342 #[inline]
1343 fn default_retained() -> Retained<Self> {
1344 Self::new()
1345 }
1346}
1347
1348impl NSMutableString {
1350 extern_methods!(
1351 #[unsafe(method(insertString:atIndex:))]
1352 #[unsafe(method_family = none)]
1353 pub unsafe fn insertString_atIndex(&self, a_string: &NSString, loc: NSUInteger);
1354
1355 #[cfg(feature = "NSRange")]
1356 #[unsafe(method(deleteCharactersInRange:))]
1357 #[unsafe(method_family = none)]
1358 pub unsafe fn deleteCharactersInRange(&self, range: NSRange);
1359
1360 #[unsafe(method(appendString:))]
1361 #[unsafe(method_family = none)]
1362 pub fn appendString(&self, a_string: &NSString);
1363
1364 #[unsafe(method(setString:))]
1365 #[unsafe(method_family = none)]
1366 pub fn setString(&self, a_string: &NSString);
1367
1368 #[cfg(feature = "NSRange")]
1369 #[unsafe(method(replaceOccurrencesOfString:withString:options:range:))]
1370 #[unsafe(method_family = none)]
1371 pub unsafe fn replaceOccurrencesOfString_withString_options_range(
1372 &self,
1373 target: &NSString,
1374 replacement: &NSString,
1375 options: NSStringCompareOptions,
1376 search_range: NSRange,
1377 ) -> NSUInteger;
1378
1379 #[cfg(feature = "NSRange")]
1380 #[unsafe(method(applyTransform:reverse:range:updatedRange:))]
1381 #[unsafe(method_family = none)]
1382 pub unsafe fn applyTransform_reverse_range_updatedRange(
1383 &self,
1384 transform: &NSStringTransform,
1385 reverse: bool,
1386 range: NSRange,
1387 resulting_range: NSRangePointer,
1388 ) -> bool;
1389
1390 #[unsafe(method(initWithCapacity:))]
1391 #[unsafe(method_family = init)]
1392 pub fn initWithCapacity(
1393 this: Allocated<Self>,
1394 capacity: NSUInteger,
1395 ) -> Retained<NSMutableString>;
1396
1397 #[unsafe(method(stringWithCapacity:))]
1398 #[unsafe(method_family = none)]
1399 pub fn stringWithCapacity(capacity: NSUInteger) -> Retained<NSMutableString>;
1400 );
1401}
1402
1403extern "C" {
1404 #[cfg(feature = "NSObjCRuntime")]
1406 pub static NSCharacterConversionException: &'static NSExceptionName;
1407}
1408
1409extern "C" {
1410 #[cfg(feature = "NSObjCRuntime")]
1412 pub static NSParseErrorException: &'static NSExceptionName;
1413}
1414
1415impl NSString {
1417 extern_methods!(
1418 #[unsafe(method(propertyList))]
1419 #[unsafe(method_family = none)]
1420 pub unsafe fn propertyList(&self) -> Retained<AnyObject>;
1421
1422 #[cfg(feature = "NSDictionary")]
1423 #[unsafe(method(propertyListFromStringsFileFormat))]
1424 #[unsafe(method_family = none)]
1425 pub unsafe fn propertyListFromStringsFileFormat(&self) -> Option<Retained<NSDictionary>>;
1426 );
1427}
1428
1429impl NSString {
1431 extern_methods!(
1432 #[deprecated = "Use -cStringUsingEncoding: instead"]
1433 #[unsafe(method(cString))]
1434 #[unsafe(method_family = none)]
1435 pub unsafe fn cString(&self) -> *const c_char;
1436
1437 #[deprecated = "Use -cStringUsingEncoding: instead"]
1438 #[unsafe(method(lossyCString))]
1439 #[unsafe(method_family = none)]
1440 pub unsafe fn lossyCString(&self) -> *const c_char;
1441
1442 #[deprecated = "Use -lengthOfBytesUsingEncoding: instead"]
1443 #[unsafe(method(cStringLength))]
1444 #[unsafe(method_family = none)]
1445 pub unsafe fn cStringLength(&self) -> NSUInteger;
1446
1447 #[deprecated = "Use -getCString:maxLength:encoding: instead"]
1448 #[unsafe(method(getCString:))]
1449 #[unsafe(method_family = none)]
1450 pub unsafe fn getCString(&self, bytes: NonNull<c_char>);
1451
1452 #[deprecated = "Use -getCString:maxLength:encoding: instead"]
1453 #[unsafe(method(getCString:maxLength:))]
1454 #[unsafe(method_family = none)]
1455 pub unsafe fn getCString_maxLength(&self, bytes: NonNull<c_char>, max_length: NSUInteger);
1456
1457 #[cfg(feature = "NSRange")]
1458 #[deprecated = "Use -getCString:maxLength:encoding: instead"]
1459 #[unsafe(method(getCString:maxLength:range:remainingRange:))]
1460 #[unsafe(method_family = none)]
1461 pub unsafe fn getCString_maxLength_range_remainingRange(
1462 &self,
1463 bytes: NonNull<c_char>,
1464 max_length: NSUInteger,
1465 a_range: NSRange,
1466 leftover_range: NSRangePointer,
1467 );
1468
1469 #[deprecated = "Use -writeToFile:atomically:encoding:error: instead"]
1470 #[unsafe(method(writeToFile:atomically:))]
1471 #[unsafe(method_family = none)]
1472 pub unsafe fn writeToFile_atomically(
1473 &self,
1474 path: &NSString,
1475 use_auxiliary_file: bool,
1476 ) -> bool;
1477
1478 #[cfg(feature = "NSURL")]
1479 #[deprecated = "Use -writeToURL:atomically:encoding:error: instead"]
1480 #[unsafe(method(writeToURL:atomically:))]
1481 #[unsafe(method_family = none)]
1482 pub unsafe fn writeToURL_atomically(&self, url: &NSURL, atomically: bool) -> bool;
1483
1484 #[deprecated = "Use -initWithContentsOfFile:encoding:error: instead"]
1485 #[unsafe(method(initWithContentsOfFile:))]
1486 #[unsafe(method_family = init)]
1487 pub unsafe fn initWithContentsOfFile(
1488 this: Allocated<Self>,
1489 path: &NSString,
1490 ) -> Option<Retained<Self>>;
1491
1492 #[cfg(feature = "NSURL")]
1493 #[deprecated = "Use -initWithContentsOfURL:encoding:error: instead"]
1494 #[unsafe(method(initWithContentsOfURL:))]
1495 #[unsafe(method_family = init)]
1496 pub unsafe fn initWithContentsOfURL(
1497 this: Allocated<Self>,
1498 url: &NSURL,
1499 ) -> Option<Retained<Self>>;
1500
1501 #[deprecated = "Use +stringWithContentsOfFile:encoding:error: instead"]
1502 #[unsafe(method(stringWithContentsOfFile:))]
1503 #[unsafe(method_family = none)]
1504 pub unsafe fn stringWithContentsOfFile(path: &NSString) -> Option<Retained<AnyObject>>;
1505
1506 #[cfg(feature = "NSURL")]
1507 #[deprecated = "Use +stringWithContentsOfURL:encoding:error: instead"]
1508 #[unsafe(method(stringWithContentsOfURL:))]
1509 #[unsafe(method_family = none)]
1510 pub unsafe fn stringWithContentsOfURL(url: &NSURL) -> Option<Retained<AnyObject>>;
1511
1512 #[deprecated = "Use -initWithCString:encoding: instead"]
1513 #[unsafe(method(initWithCStringNoCopy:length:freeWhenDone:))]
1514 #[unsafe(method_family = init)]
1515 pub unsafe fn initWithCStringNoCopy_length_freeWhenDone(
1516 this: Allocated<Self>,
1517 bytes: NonNull<c_char>,
1518 length: NSUInteger,
1519 free_buffer: bool,
1520 ) -> Option<Retained<Self>>;
1521
1522 #[deprecated = "Use -initWithCString:encoding: instead"]
1523 #[unsafe(method(initWithCString:length:))]
1524 #[unsafe(method_family = init)]
1525 pub unsafe fn initWithCString_length(
1526 this: Allocated<Self>,
1527 bytes: NonNull<c_char>,
1528 length: NSUInteger,
1529 ) -> Option<Retained<Self>>;
1530
1531 #[deprecated = "Use -initWithCString:encoding: instead"]
1532 #[unsafe(method(initWithCString:))]
1533 #[unsafe(method_family = init)]
1534 pub unsafe fn initWithCString(
1535 this: Allocated<Self>,
1536 bytes: NonNull<c_char>,
1537 ) -> Option<Retained<Self>>;
1538
1539 #[deprecated = "Use +stringWithCString:encoding:"]
1540 #[unsafe(method(stringWithCString:length:))]
1541 #[unsafe(method_family = none)]
1542 pub unsafe fn stringWithCString_length(
1543 bytes: NonNull<c_char>,
1544 length: NSUInteger,
1545 ) -> Option<Retained<AnyObject>>;
1546
1547 #[deprecated = "Use +stringWithCString:encoding: instead"]
1548 #[unsafe(method(stringWithCString:))]
1549 #[unsafe(method_family = none)]
1550 pub unsafe fn stringWithCString(bytes: NonNull<c_char>) -> Option<Retained<AnyObject>>;
1551
1552 #[unsafe(method(getCharacters:))]
1553 #[unsafe(method_family = none)]
1554 pub unsafe fn getCharacters(&self, buffer: NonNull<unichar>);
1555 );
1556}
1557
1558impl NSMutableString {
1562 extern_methods!(
1563 #[deprecated = "Use -initWithContentsOfFile:encoding:error: instead"]
1564 #[unsafe(method(initWithContentsOfFile:))]
1565 #[unsafe(method_family = init)]
1566 pub unsafe fn initWithContentsOfFile(
1567 this: Allocated<Self>,
1568 path: &NSString,
1569 ) -> Option<Retained<Self>>;
1570
1571 #[cfg(feature = "NSURL")]
1572 #[deprecated = "Use -initWithContentsOfURL:encoding:error: instead"]
1573 #[unsafe(method(initWithContentsOfURL:))]
1574 #[unsafe(method_family = init)]
1575 pub unsafe fn initWithContentsOfURL(
1576 this: Allocated<Self>,
1577 url: &NSURL,
1578 ) -> Option<Retained<Self>>;
1579
1580 #[deprecated = "Use -initWithCString:encoding: instead"]
1581 #[unsafe(method(initWithCStringNoCopy:length:freeWhenDone:))]
1582 #[unsafe(method_family = init)]
1583 pub unsafe fn initWithCStringNoCopy_length_freeWhenDone(
1584 this: Allocated<Self>,
1585 bytes: NonNull<c_char>,
1586 length: NSUInteger,
1587 free_buffer: bool,
1588 ) -> Option<Retained<Self>>;
1589
1590 #[deprecated = "Use -initWithCString:encoding: instead"]
1591 #[unsafe(method(initWithCString:length:))]
1592 #[unsafe(method_family = init)]
1593 pub unsafe fn initWithCString_length(
1594 this: Allocated<Self>,
1595 bytes: NonNull<c_char>,
1596 length: NSUInteger,
1597 ) -> Option<Retained<Self>>;
1598
1599 #[deprecated = "Use -initWithCString:encoding: instead"]
1600 #[unsafe(method(initWithCString:))]
1601 #[unsafe(method_family = init)]
1602 pub unsafe fn initWithCString(
1603 this: Allocated<Self>,
1604 bytes: NonNull<c_char>,
1605 ) -> Option<Retained<Self>>;
1606 );
1607}
1608
1609extern_class!(
1610 #[unsafe(super(NSString, NSObject))]
1612 #[derive(Debug, PartialEq, Eq, Hash)]
1613 pub struct NSSimpleCString;
1614);
1615
1616#[cfg(feature = "NSObject")]
1617unsafe impl NSCoding for NSSimpleCString {}
1618
1619unsafe impl NSObjectProtocol for NSSimpleCString {}
1620
1621#[cfg(feature = "NSObject")]
1622unsafe impl NSSecureCoding for NSSimpleCString {}
1623
1624impl NSSimpleCString {
1625 extern_methods!();
1626}
1627
1628impl NSSimpleCString {
1630 extern_methods!(
1631 #[unsafe(method(init))]
1632 #[unsafe(method_family = init)]
1633 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
1634
1635 #[cfg(feature = "NSCoder")]
1636 #[unsafe(method(initWithCoder:))]
1637 #[unsafe(method_family = init)]
1638 pub unsafe fn initWithCoder(
1639 this: Allocated<Self>,
1640 coder: &NSCoder,
1641 ) -> Option<Retained<Self>>;
1642 );
1643}
1644
1645impl NSSimpleCString {
1647 extern_methods!(
1648 #[unsafe(method(new))]
1649 #[unsafe(method_family = new)]
1650 pub unsafe fn new() -> Retained<Self>;
1651 );
1652}
1653
1654extern_class!(
1655 #[unsafe(super(NSSimpleCString, NSString, NSObject))]
1657 #[derive(Debug, PartialEq, Eq, Hash)]
1658 pub struct NSConstantString;
1659);
1660
1661#[cfg(feature = "NSObject")]
1662unsafe impl NSCoding for NSConstantString {}
1663
1664unsafe impl NSObjectProtocol for NSConstantString {}
1665
1666#[cfg(feature = "NSObject")]
1667unsafe impl NSSecureCoding for NSConstantString {}
1668
1669impl NSConstantString {
1670 extern_methods!();
1671}
1672
1673impl NSConstantString {
1675 extern_methods!(
1676 #[unsafe(method(init))]
1677 #[unsafe(method_family = init)]
1678 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
1679
1680 #[cfg(feature = "NSCoder")]
1681 #[unsafe(method(initWithCoder:))]
1682 #[unsafe(method_family = init)]
1683 pub unsafe fn initWithCoder(
1684 this: Allocated<Self>,
1685 coder: &NSCoder,
1686 ) -> Option<Retained<Self>>;
1687 );
1688}
1689
1690impl NSConstantString {
1692 extern_methods!(
1693 #[unsafe(method(new))]
1694 #[unsafe(method_family = new)]
1695 pub unsafe fn new() -> Retained<Self>;
1696 );
1697}