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