2018-08-01 17:28:52 +02:00
|
|
|
//
|
|
|
|
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
|
|
|
|
// WARNING: This code is generated. Only edit within the markers.
|
|
|
|
|
|
|
|
public enum FingerprintProtoError: Error {
|
|
|
|
case invalidProtobuf(description: String)
|
|
|
|
}
|
|
|
|
|
|
|
|
// MARK: - FingerprintProtoLogicalFingerprint
|
|
|
|
|
|
|
|
@objc public class FingerprintProtoLogicalFingerprint: NSObject {
|
|
|
|
|
2018-08-02 20:28:13 +02:00
|
|
|
// MARK: - FingerprintProtoLogicalFingerprintBuilder
|
2018-08-01 17:28:52 +02:00
|
|
|
|
2018-09-25 21:12:45 +02:00
|
|
|
@objc public class func builder(identityData: Data) -> FingerprintProtoLogicalFingerprintBuilder {
|
|
|
|
return FingerprintProtoLogicalFingerprintBuilder(identityData: identityData)
|
2018-09-25 19:09:55 +02:00
|
|
|
}
|
|
|
|
|
2018-08-02 20:28:13 +02:00
|
|
|
@objc public class FingerprintProtoLogicalFingerprintBuilder: NSObject {
|
|
|
|
|
|
|
|
private var proto = FingerprintProtos_LogicalFingerprint()
|
|
|
|
|
2018-09-25 21:12:45 +02:00
|
|
|
@objc fileprivate override init() {}
|
2018-08-02 20:28:13 +02:00
|
|
|
|
2018-09-25 21:12:45 +02:00
|
|
|
@objc fileprivate init(identityData: Data) {
|
2018-08-08 19:08:47 +02:00
|
|
|
super.init()
|
|
|
|
|
|
|
|
setIdentityData(identityData)
|
|
|
|
}
|
|
|
|
|
2018-08-02 20:28:13 +02:00
|
|
|
@objc public func setIdentityData(_ valueParam: Data) {
|
|
|
|
proto.identityData = valueParam
|
|
|
|
}
|
|
|
|
|
|
|
|
@objc public func build() throws -> FingerprintProtoLogicalFingerprint {
|
2018-08-03 20:52:55 +02:00
|
|
|
return try FingerprintProtoLogicalFingerprint.parseProto(proto)
|
|
|
|
}
|
|
|
|
|
|
|
|
@objc public func buildSerializedData() throws -> Data {
|
|
|
|
return try FingerprintProtoLogicalFingerprint.parseProto(proto).serializedData()
|
2018-08-02 20:28:13 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fileprivate let proto: FingerprintProtos_LogicalFingerprint
|
|
|
|
|
2018-08-03 20:03:02 +02:00
|
|
|
@objc public let identityData: Data
|
2018-08-02 20:28:13 +02:00
|
|
|
|
2018-08-03 20:03:02 +02:00
|
|
|
private init(proto: FingerprintProtos_LogicalFingerprint,
|
|
|
|
identityData: Data) {
|
2018-08-02 20:28:13 +02:00
|
|
|
self.proto = proto
|
2018-08-03 20:03:02 +02:00
|
|
|
self.identityData = identityData
|
2018-08-01 17:44:29 +02:00
|
|
|
}
|
2018-08-01 17:28:52 +02:00
|
|
|
|
2018-08-01 17:44:29 +02:00
|
|
|
@objc
|
|
|
|
public func serializedData() throws -> Data {
|
2018-08-02 20:28:13 +02:00
|
|
|
return try self.proto.serializedData()
|
2018-08-01 17:44:29 +02:00
|
|
|
}
|
2018-08-01 17:28:52 +02:00
|
|
|
|
2018-08-01 17:44:29 +02:00
|
|
|
@objc public class func parseData(_ serializedData: Data) throws -> FingerprintProtoLogicalFingerprint {
|
|
|
|
let proto = try FingerprintProtos_LogicalFingerprint(serializedData: serializedData)
|
|
|
|
return try parseProto(proto)
|
|
|
|
}
|
2018-08-01 17:28:52 +02:00
|
|
|
|
2018-08-01 17:44:29 +02:00
|
|
|
fileprivate class func parseProto(_ proto: FingerprintProtos_LogicalFingerprint) throws -> FingerprintProtoLogicalFingerprint {
|
2018-08-03 20:03:02 +02:00
|
|
|
guard proto.hasIdentityData else {
|
|
|
|
throw FingerprintProtoError.invalidProtobuf(description: "\(logTag) missing required field: identityData")
|
|
|
|
}
|
|
|
|
let identityData = proto.identityData
|
|
|
|
|
2018-08-01 17:44:29 +02:00
|
|
|
// MARK: - Begin Validation Logic for FingerprintProtoLogicalFingerprint -
|
2018-08-01 17:28:52 +02:00
|
|
|
|
2018-08-01 17:44:29 +02:00
|
|
|
// MARK: - End Validation Logic for FingerprintProtoLogicalFingerprint -
|
2018-08-01 17:28:52 +02:00
|
|
|
|
2018-08-03 20:03:02 +02:00
|
|
|
let result = FingerprintProtoLogicalFingerprint(proto: proto,
|
|
|
|
identityData: identityData)
|
2018-08-01 17:44:29 +02:00
|
|
|
return result
|
|
|
|
}
|
2018-08-01 17:28:52 +02:00
|
|
|
}
|
|
|
|
|
2018-08-22 02:40:55 +02:00
|
|
|
#if DEBUG
|
|
|
|
|
|
|
|
extension FingerprintProtoLogicalFingerprint {
|
|
|
|
@objc public func serializedDataIgnoringErrors() -> Data? {
|
|
|
|
return try! self.serializedData()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
extension FingerprintProtoLogicalFingerprint.FingerprintProtoLogicalFingerprintBuilder {
|
|
|
|
@objc public func buildIgnoringErrors() -> FingerprintProtoLogicalFingerprint? {
|
|
|
|
return try! self.build()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2018-08-01 17:28:52 +02:00
|
|
|
// MARK: - FingerprintProtoLogicalFingerprints
|
|
|
|
|
|
|
|
@objc public class FingerprintProtoLogicalFingerprints: NSObject {
|
|
|
|
|
2018-08-02 20:28:13 +02:00
|
|
|
// MARK: - FingerprintProtoLogicalFingerprintsBuilder
|
|
|
|
|
2018-09-25 21:12:45 +02:00
|
|
|
@objc public class func builder(version: UInt32, localFingerprint: FingerprintProtoLogicalFingerprint, remoteFingerprint: FingerprintProtoLogicalFingerprint) -> FingerprintProtoLogicalFingerprintsBuilder {
|
|
|
|
return FingerprintProtoLogicalFingerprintsBuilder(version: version, localFingerprint: localFingerprint, remoteFingerprint: remoteFingerprint)
|
2018-09-25 19:09:55 +02:00
|
|
|
}
|
|
|
|
|
2018-08-02 20:28:13 +02:00
|
|
|
@objc public class FingerprintProtoLogicalFingerprintsBuilder: NSObject {
|
|
|
|
|
|
|
|
private var proto = FingerprintProtos_LogicalFingerprints()
|
|
|
|
|
2018-09-25 21:12:45 +02:00
|
|
|
@objc fileprivate override init() {}
|
2018-08-02 20:28:13 +02:00
|
|
|
|
2018-09-25 21:12:45 +02:00
|
|
|
@objc fileprivate init(version: UInt32, localFingerprint: FingerprintProtoLogicalFingerprint, remoteFingerprint: FingerprintProtoLogicalFingerprint) {
|
2018-08-08 19:08:47 +02:00
|
|
|
super.init()
|
|
|
|
|
|
|
|
setVersion(version)
|
|
|
|
setLocalFingerprint(localFingerprint)
|
|
|
|
setRemoteFingerprint(remoteFingerprint)
|
|
|
|
}
|
|
|
|
|
2018-08-02 20:28:13 +02:00
|
|
|
@objc public func setVersion(_ valueParam: UInt32) {
|
|
|
|
proto.version = valueParam
|
|
|
|
}
|
|
|
|
|
|
|
|
@objc public func setLocalFingerprint(_ valueParam: FingerprintProtoLogicalFingerprint) {
|
|
|
|
proto.localFingerprint = valueParam.proto
|
|
|
|
}
|
|
|
|
|
|
|
|
@objc public func setRemoteFingerprint(_ valueParam: FingerprintProtoLogicalFingerprint) {
|
|
|
|
proto.remoteFingerprint = valueParam.proto
|
|
|
|
}
|
|
|
|
|
|
|
|
@objc public func build() throws -> FingerprintProtoLogicalFingerprints {
|
2018-08-03 20:52:55 +02:00
|
|
|
return try FingerprintProtoLogicalFingerprints.parseProto(proto)
|
|
|
|
}
|
|
|
|
|
|
|
|
@objc public func buildSerializedData() throws -> Data {
|
|
|
|
return try FingerprintProtoLogicalFingerprints.parseProto(proto).serializedData()
|
2018-08-02 20:28:13 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fileprivate let proto: FingerprintProtos_LogicalFingerprints
|
|
|
|
|
2018-08-03 20:03:02 +02:00
|
|
|
@objc public let version: UInt32
|
2018-08-03 20:35:22 +02:00
|
|
|
|
2018-08-03 20:03:02 +02:00
|
|
|
@objc public let localFingerprint: FingerprintProtoLogicalFingerprint
|
2018-08-03 20:35:22 +02:00
|
|
|
|
2018-08-03 20:03:02 +02:00
|
|
|
@objc public let remoteFingerprint: FingerprintProtoLogicalFingerprint
|
2018-08-02 20:28:13 +02:00
|
|
|
|
|
|
|
private init(proto: FingerprintProtos_LogicalFingerprints,
|
2018-08-03 20:03:02 +02:00
|
|
|
version: UInt32,
|
|
|
|
localFingerprint: FingerprintProtoLogicalFingerprint,
|
|
|
|
remoteFingerprint: FingerprintProtoLogicalFingerprint) {
|
2018-08-02 20:28:13 +02:00
|
|
|
self.proto = proto
|
2018-08-03 20:03:02 +02:00
|
|
|
self.version = version
|
2018-08-01 17:44:29 +02:00
|
|
|
self.localFingerprint = localFingerprint
|
|
|
|
self.remoteFingerprint = remoteFingerprint
|
|
|
|
}
|
|
|
|
|
|
|
|
@objc
|
|
|
|
public func serializedData() throws -> Data {
|
2018-08-02 20:28:13 +02:00
|
|
|
return try self.proto.serializedData()
|
2018-08-01 17:44:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@objc public class func parseData(_ serializedData: Data) throws -> FingerprintProtoLogicalFingerprints {
|
|
|
|
let proto = try FingerprintProtos_LogicalFingerprints(serializedData: serializedData)
|
|
|
|
return try parseProto(proto)
|
|
|
|
}
|
|
|
|
|
|
|
|
fileprivate class func parseProto(_ proto: FingerprintProtos_LogicalFingerprints) throws -> FingerprintProtoLogicalFingerprints {
|
2018-08-03 20:03:02 +02:00
|
|
|
guard proto.hasVersion else {
|
|
|
|
throw FingerprintProtoError.invalidProtobuf(description: "\(logTag) missing required field: version")
|
|
|
|
}
|
|
|
|
let version = proto.version
|
|
|
|
|
|
|
|
guard proto.hasLocalFingerprint else {
|
|
|
|
throw FingerprintProtoError.invalidProtobuf(description: "\(logTag) missing required field: localFingerprint")
|
2018-08-01 17:44:29 +02:00
|
|
|
}
|
2018-08-03 20:03:02 +02:00
|
|
|
let localFingerprint = try FingerprintProtoLogicalFingerprint.parseProto(proto.localFingerprint)
|
2018-08-01 17:44:29 +02:00
|
|
|
|
2018-08-03 20:03:02 +02:00
|
|
|
guard proto.hasRemoteFingerprint else {
|
|
|
|
throw FingerprintProtoError.invalidProtobuf(description: "\(logTag) missing required field: remoteFingerprint")
|
2018-08-01 17:44:29 +02:00
|
|
|
}
|
2018-08-03 20:03:02 +02:00
|
|
|
let remoteFingerprint = try FingerprintProtoLogicalFingerprint.parseProto(proto.remoteFingerprint)
|
2018-08-01 17:44:29 +02:00
|
|
|
|
|
|
|
// MARK: - Begin Validation Logic for FingerprintProtoLogicalFingerprints -
|
|
|
|
|
|
|
|
// MARK: - End Validation Logic for FingerprintProtoLogicalFingerprints -
|
|
|
|
|
2018-08-02 20:28:13 +02:00
|
|
|
let result = FingerprintProtoLogicalFingerprints(proto: proto,
|
2018-08-03 20:03:02 +02:00
|
|
|
version: version,
|
2018-08-01 17:44:29 +02:00
|
|
|
localFingerprint: localFingerprint,
|
|
|
|
remoteFingerprint: remoteFingerprint)
|
|
|
|
return result
|
|
|
|
}
|
2018-08-01 17:28:52 +02:00
|
|
|
}
|
2018-08-22 02:40:55 +02:00
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
|
|
|
|
extension FingerprintProtoLogicalFingerprints {
|
|
|
|
@objc public func serializedDataIgnoringErrors() -> Data? {
|
|
|
|
return try! self.serializedData()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
extension FingerprintProtoLogicalFingerprints.FingerprintProtoLogicalFingerprintsBuilder {
|
|
|
|
@objc public func buildIgnoringErrors() -> FingerprintProtoLogicalFingerprints? {
|
|
|
|
return try! self.build()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|