Skip to content

Commit

Permalink
authority ID convenience initializers
Browse files Browse the repository at this point in the history
  • Loading branch information
lhoward committed Oct 30, 2023
1 parent d81d467 commit d3e829c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Sources/SwiftOCA/OCC/ControlDataTypes/BaseDataTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,22 @@ public struct OcaClassID: Codable, Hashable, Sendable, CustomStringConvertible {
fields = parent.fields + [integer]
}

private init(parent: OcaClassID, authority: OcaOrganizationID, _ extraFields: [OcaUint16]) {
fields = parent.fields + [
Self.ProprietaryClassField,
OcaUint16(authority.id.0),
OcaUint16(authority.id.1 << 8 | authority.id.2),
] + extraFields
}

public init(parent: OcaClassID, authority: OcaOrganizationID, _ string: String) {
self.init(parent: parent, authority: authority, OcaClassID(string).fields)
}

public init(parent: OcaClassID, authority: OcaOrganizationID, _ integer: OcaUint16) {
self.init(parent: parent, authority: authority, [integer])
}

public var parent: OcaClassID? {
guard fieldCount > 1 else {
return nil
Expand Down

0 comments on commit d3e829c

Please sign in to comment.