FormatStyle
- iOS
- 15.0+
- macOS
- 12.0+
- tvOS
- 15.0+
- watchOS
- 8.0+
struct FormatStyle
struct FormatStyle
s20FoundationEssentials7DecimalV0A20InternationalizationE11FormatStyleV
What are these?9ESES
import FoundationInternationalization
import FoundationEssentials
struct Decimal
init(_ value: String, format: Decimal.FormatStyle.Percent, lenient: Bool = true) throws
init(_ value: String, format: Decimal.FormatStyle.Currency, lenient: Bool = true) throws
init(_ value: String, format: Decimal.FormatStyle, lenient: Bool = true) throws
init<S>(_ value: S.ParseInput, strategy: S) throws where S : ParseStrategy, S.ParseOutput == Decimal
Initialize an instance by parsing value
with the given strategy
.
func formatted() -> String
Format self
using Decimal.FormatStyle
func formatted<S>(_ format: S) -> S.FormatOutput where S : FormatStyle, S.FormatInput == Decimal
Format self
with the given format.
struct ParseStrategy<Format> where Format : FormatStyle, Format.FormatInput == Decimal
protocol Copyable
A type whose values can be implicitly or explicitly copied.
protocol CustomConsumingRegexComponent : RegexComponent
protocol Decodable
A type that can decode itself from an external representation.
protocol Encodable
A type that can encode itself to an external representation.
protocol Equatable
A type that can be compared for value equality.
protocol Escapable
protocol FormatStyle : Decodable, Encodable, Hashable
A type that can convert a given data type into a representation.
protocol Hashable : Equatable
A type that can be hashed into a Hasher
to produce an integer hash value.
protocol ParseableFormatStyle : FormatStyle
A type that can convert a given data type into a representation.
protocol RegexComponent<RegexOutput>
A type that represents a regular expression.
protocol Sendable
init(from decoder: any Decoder) throws
init(locale: Locale = .autoupdatingCurrent)
var attributed: Decimal.FormatStyle.Attributed { get }
var locale: Locale
var parseStrategy: Decimal.ParseStrategy<Decimal.FormatStyle> { get }
func consuming(_ input: String, startingAt index: String.Index, in bounds: Range<String.Index>) throws -> (upperBound: String.Index, output: Decimal)?
func decimalSeparator(strategy: Decimal.FormatStyle.Configuration.DecimalSeparatorDisplayStrategy) -> Decimal.FormatStyle
func format(_ value: Decimal) -> String
func grouping(_ group: Decimal.FormatStyle.Configuration.Grouping) -> Decimal.FormatStyle
func locale(_ locale: Locale) -> Decimal.FormatStyle
func notation(_ notation: Decimal.FormatStyle.Configuration.Notation) -> Decimal.FormatStyle
func precision(_ p: Decimal.FormatStyle.Configuration.Precision) -> Decimal.FormatStyle
func rounded(rule: Decimal.FormatStyle.Configuration.RoundingRule = .toNearestOrEven, increment: Int? = nil) -> Decimal.FormatStyle
func scale(_ multiplicand: Double) -> Decimal.FormatStyle
func sign(strategy: Decimal.FormatStyle.Configuration.SignDisplayStrategy) -> Decimal.FormatStyle
struct Attributed
struct Currency
struct Percent
typealias Configuration = NumberFormatStyleConfiguration
typealias RegexOutput = Decimal
static var number: Decimal.FormatStyle { get }
static var number: Decimal.FormatStyle { get }
static func currency<Value>(code: String) -> Self where Self == FloatingPointFormatStyle<Value>.Currency, Value : BinaryFloatingPoint
static func currency<V>(code: String) -> Self where Self == IntegerFormatStyle<V>.Currency, V : BinaryInteger
static func list<MemberStyle, Base>(memberStyle: MemberStyle, type: ListFormatStyle<MemberStyle, Base>.ListType, width: ListFormatStyle<MemberStyle, Base>.Width = .standard) -> Self where Self == ListFormatStyle<MemberStyle, Base>, MemberStyle : FormatStyle, Base : Sequence, MemberStyle.FormatInput == Base.Element, MemberStyle.FormatOutput == String
static func list<Base>(type: ListFormatStyle<StringStyle, Base>.ListType, width: ListFormatStyle<StringStyle, Base>.Width = .standard) -> Self where Self == ListFormatStyle<StringStyle, Base>, Base : Sequence, Base.Element == String
static func localizedDecimal(locale: Locale) -> Self
Creates a regex component to match a localized number string and capture it as a Decimal
.
var regex: Regex<Self.RegexOutput> { get }
static func != (lhs: Self, rhs: Self) -> Bool
Returns a Boolean value indicating whether two values are not equal.