File: PersonNameComponentsFormatter.swift

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (96 lines) | stat: -rw-r--r-- 4,928 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//


@available(*, deprecated, message: "Person name components formatting isn't available in swift-corelibs-foundation")
extension PersonNameComponentsFormatter {
    public enum Style : Int, Sendable {
        
        case `default`
        
        /* Relies on user preferences and language defaults to display shortened form appropriate
          for display in space-constrained settings, e.g. C Darwin */
        case short
        
        /* The minimally necessary features for differentiation in a casual setting , e.g. Charles Darwin */
        case medium
        
        /* The fully-qualified name complete with all known components, e.g. Charles Robert Darwin, FRS */
        case long
        
        /* The maximally-abbreviated form of a name suitable for monograms, e.g. CRD) */
        case abbreviated
    }

    public struct Options : OptionSet, Sendable {
        public let rawValue : UInt
        public init(rawValue: UInt) { self.rawValue = rawValue }
        
        /* Indicates that the formatter should format the component object's phoneticRepresentation components instead of its own components.
         The developer must have populated these manually. e.g.: Developer creates components object with the following properties:
         <family:"Family", given:"Given", phoneticRepresentation:<family:"FamilyPhonetic", given:"GivenPhonetic">>.
         If this option is specified, we perform formatting operations on <family "FamilyPhonetic", given "GivenPhonetic"> instead. */
        public static let phonetic = Options(rawValue: 1 << 1)
    }
}

@available(*, deprecated, message: "Person name components formatting isn't available in swift-corelibs-foundation")
open class PersonNameComponentsFormatter : Formatter, @unchecked Sendable {
    
    @available(*, unavailable, message: "Person name components formatting isn't available in swift-corelibs-foundation")
    public required init?(coder: NSCoder) {
        NSUnsupported()
    }
    
    /* Specify the formatting style for the formatted string on an instance. ShortStyle will fall back to user preferences and language-specific defaults
     */
    open var style: Style
    
    /* Specify that the formatter should only format the components object's phoneticRepresentation
     */
    open var isPhonetic: Bool
    
    /* Shortcut for converting an NSPersonNameComponents object into a string without explicitly creating an instance.
        Create an instance for greater customizability.
     */
    @available(*, unavailable, message: "Person name components formatting isn't available in swift-corelibs-foundation")
    open class func localizedString(from components: PersonNameComponents, style nameFormatStyle: Style, options nameOptions: Options = []) -> String { NSUnsupported() }
    
    /* Convenience method on string(for:):. Returns a string containing the formatted value of the provided components object.
     */
    @available(*, unavailable, message: "Person name components formatting isn't available in swift-corelibs-foundation")
    open func string(from components: PersonNameComponents) -> String { NSUnsupported() }
    
    /* Returns attributed string with annotations for each component. For each range, attributes can be obtained by querying
        dictionary key NSPersonNameComponentKey , using NSPersonNameComponent constant values.
     */
    @available(*, unavailable, message: "Person name components formatting isn't available in swift-corelibs-foundation")
    open func annotatedString(from components: PersonNameComponents) -> NSAttributedString { NSUnsupported() }
    
    @available(*, unavailable, message: "Person name components formatting isn't available in swift-corelibs-foundation")
    open func personNameComponents(from string: String) -> PersonNameComponents? { NSUnsupported() }
}

// Attributed String identifier key string
public let NSPersonNameComponentKey: String = "NSPersonNameComponentKey"

// Constants for attributed strings
public let NSPersonNameComponentGivenName: String = "givenName"
public let NSPersonNameComponentFamilyName: String = "familyName"
public let NSPersonNameComponentMiddleName: String = "middleName"
public let NSPersonNameComponentPrefix: String = "namePrefix"
public let NSPersonNameComponentSuffix: String = "nameSuffix"
public let NSPersonNameComponentNickname: String = "nickname"

/* The delimiter is the character or characters used to separate name components.
 For CJK languages there is no delimiter.
 */
public let NSPersonNameComponentDelimiter: String = "delimiter"