summaryrefslogtreecommitdiff
path: root/swift/src/Ice/OptionalFormat.swift
blob: 8e399125a2fcccf9259bcbeed5957ff5c184cab5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//
// Copyright (c) ZeroC, Inc. All rights reserved.
//

/// Helper for encoding of optional member or parameter.
public enum OptionalFormat: UInt8 {
    case F1 = 0
    case F2 = 1
    case F4 = 2
    case F8 = 3
    case Size = 4
    case VSize = 5
    case FSize = 6
    case Class = 7

    init?(fixedSize: Int) {
        switch fixedSize {
        case 1:
            self.init(rawValue: 0)
        case 2:
            self.init(rawValue: 1)
        case 4:
            self.init(rawValue: 2)
        case 8:
            self.init(rawValue: 3)
        default:
            return nil
        }
    }
}