StaticString

struct StaticString

An simple string designed to represent text that is "knowable at compile-time".

Logically speaking, each instance looks something like this:

 enum StaticString {
    case ASCII(start: UnsafePointer<UInt8>, length: Int)
    case UTF8(start: UnsafePointer<UInt8>, length: Int)
    case Scalar(UnicodeScalar)
 }
Inheritance CustomDebugStringConvertible, CustomStringConvertible, ExtendedGraphemeClusterLiteralConvertible, StringLiteralConvertible, UnicodeScalarLiteralConvertible, _Reflectable View Protocol Hierarchy →
Import import Swift

Initializers

init()

Create an empty instance.

Declaration

init()
init(_builtinExtendedGraphemeClusterLiteral:byteSize:isASCII:)

Declaration

init(_builtinExtendedGraphemeClusterLiteral start: Builtin.RawPointer, byteSize: Builtin.Word, isASCII: Builtin.Int1)
init(_builtinStringLiteral:byteSize:isASCII:)

Declaration

init(_builtinStringLiteral start: Builtin.RawPointer, byteSize: Builtin.Word, isASCII: Builtin.Int1)
init(_builtinUnicodeScalarLiteral:)

Declaration

init(_builtinUnicodeScalarLiteral value: Builtin.Int32)
init(extendedGraphemeClusterLiteral:)

Create an instance initialized to value.

Declaration

init(extendedGraphemeClusterLiteral value: StaticString)
init(stringLiteral:)

Create an instance initialized to value.

Declaration

init(stringLiteral value: StaticString)
init(unicodeScalarLiteral:)

Create an instance initialized to value.

Declaration

init(unicodeScalarLiteral value: StaticString)

Instance Variables

var byteSize: Int

If self stores a pointer to ASCII or UTF-8 code units, the length in bytes of that data.

If self stores a single Unicode scalar value, the value of byteSize is unspecified.

Declaration

var byteSize: Int { get }
var debugDescription: String

A textual representation of self, suitable for debugging.

Declaration

var debugDescription: String { get }
var description: String

A textual representation of self.

Declaration

var description: String { get }
var hasPointerRepresentation: Bool

true iff self stores a pointer to ASCII or UTF-8 code units.

Declaration

var hasPointerRepresentation: Bool { get }
var isASCII: Bool

true if self stores a pointer to ASCII code units.

If self stores a single Unicode scalar value, the value of isASCII is unspecified.

Declaration

var isASCII: Bool { get }
var stringValue: String

Return a String representing the same sequence of Unicode scalar values as self does.

Declaration

var stringValue: String { get }
var unicodeScalar: UnicodeScalar

The stored Unicode scalar value.

Requires: self stores a single Unicode scalar value.

Declaration

var unicodeScalar: UnicodeScalar { get }
var utf8Start: UnsafePointer<UInt8>

A pointer to the beginning of UTF-8 code units.

Requires: self stores a pointer to either ASCII or UTF-8 code units.

Declaration

var utf8Start: UnsafePointer<UInt8> { get }

Instance Methods

func withUTF8Buffer(_:)

Invoke body with a buffer containing the UTF-8 code units of self.

This method works regardless of what self stores.

Declaration

func withUTF8Buffer<R>(@noescape body: (UnsafeBufferPointer<UInt8>) -> R) -> R