Documentation Language: Swift

Method

createFromString(_:_:)

Creates a value from a string literal for the given data type.

func createFromString(_ eDataType: EDataType, _ literal: String) -> (any EcoreValue)?

Parameters

eDataType

The data type to create a value for.

literal

The string literal to convert.

Return Value

The converted value, or nil if conversion fails.

Discussion

Converts a string representation to a typed value. This is used during deserialisation (e.g., from XMI or JSON) to convert attribute values from strings to their proper Swift types.

Supported Conversions

Example

let intType = EDataType(name: "EInt")
if let value = factory.createFromString(intType, "42") as? Int {
    print("Parsed: \(value)")  // 42
}