Value
open class Value : ValueBase, ExpressibleByStringLiteral, ExpressibleByIntegerLiteral, ExpressibleByFloatLiteral, ExpressibleByBooleanLiteral
This class is the main Swift wrapper with memory management
for underlying GValues
(the opaque GLib structure used to
hold different types of values.
Note
this class conforms to ExpressibleBy*Literal for storage of primitive types such asString
, Int
, Double
, or Bool
-
Declaration
Swift
public typealias StringLiteralType = StaticString
-
Declaration
Swift
public typealias ExtendedGraphemeClusterLiteralType = StaticString
-
Declaration
Swift
public typealias UnicodeScalarLiteralType = StaticString
-
Declaration
Swift
public typealias IntegerLiteralType = Int
-
Declaration
Swift
public typealias FloatLiteralType = Double
-
Declaration
Swift
public typealias BooleanLiteralType = Bool
-
Designated initialiser, allocating a value in memory
Declaration
Swift
@inlinable required public init()
-
Convenience, optional value constructor
Note
The value container will beunset
if the value isnil
Declaration
Swift
@inlinable convenience override public init<T>(_ v: T?)
Parameters
v
optional value to initialise with (or
unset
ifnil
) -
Creates an instance initialized to the given string value.
Do not call this initializer directly. Instead, initialize a variable or constant using an integer literal. For example:
let s: Value = "string"
Declaration
Swift
@inlinable public required convenience init(stringLiteral value: StringLiteralType)
Parameters
value
The value of the new instance.
-
Creates an instance initialized to the given value.
Do not call this initializer directly. Instead, initialize a variable or constant using an integer literal. For example:
let s: Value = "string"
Declaration
Swift
@inlinable public required convenience init(extendedGraphemeClusterLiteral value: ExtendedGraphemeClusterLiteralType)
Parameters
value
The value of the new instance.
-
Creates an instance initialized to the given value.
Do not call this initializer directly. Instead, initialize a variable or constant using an integer literal. For example:
let s: Value = "string"
Declaration
Swift
@inlinable public required convenience init(unicodeScalarLiteral value: UnicodeScalarLiteralType)
Parameters
value
The value of the new instance.
-
Creates an instance initialized to the specified integer value.
Do not call this initializer directly. Instead, initialize a variable or constant using an integer literal. For example:
let x: Value = 23
In this example, the assignment to the
x
constant calls this integer literal initializer behind the scenes.Declaration
Swift
@inlinable public required convenience init(integerLiteral value: IntegerLiteralType)
Parameters
value
The value to create.
-
Creates an instance initialized to the specified floating-point value.
Do not call this initializer directly. Instead, initialize a variable or constant using a floating-point literal. For example:
let x: Value = 21.5
In this example, the assignment to the
x
constant calls this floating-point literal initializer behind the scenes.Declaration
Swift
@inlinable public required convenience init(floatLiteral value: FloatLiteralType)
Parameters
value
The value to create.
-
Creates an instance initialized to the given Boolean value.
Do not call this initializer directly. Instead, initialize a variable or constant using one of the Boolean literals
true
andfalse
. For example:let twasBrilling: Value = true
In this example, the assignment to the
twasBrillig
constant calls this Boolean literal initializer behind the scenes.Declaration
Swift
@inlinable public required convenience init(booleanLiteral value: BooleanLiteralType)
Parameters
value
The value of the new instance.
-
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
StringProtocol
.Declaration
Swift
@inlinable required public init(raw p: UnsafeMutableRawPointer)
Parameters
p
raw pointer to the underlying object