-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathBase64Binary.swift
87 lines (59 loc) · 1.75 KB
/
Base64Binary.swift
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//
// Base64Binary.swift
// SwiftFHIR
//
// Created by Pascal Pfiffner on 07.12.16.
// 2016, SMART Health IT.
//
import Foundation
/**
Data encoded as a base-64 string.
*/
public struct Base64Binary: FHIRPrimitive, FHIRJSONType, ExpressibleByStringLiteral, CustomStringConvertible {
/// The base-64 string.
public var value: String
/// An optional id of the element.
public var id: String?
/// The parent/owner of the receiver, if any. Used to dereference resources.
public weak var _owner: FHIRAbstractBase?
/// Optional extensions of the element.
public var extension_fhir: [Extension]?
/**
Designated initializer.
- parameter value: The Base64 string representing data of the receiver
*/
public init(value: String) {
self.value = value
}
// MARK: - FHIRJSONType
public typealias JSONType = String
public init(json: JSONType, owner: FHIRAbstractBase?, context: inout FHIRInstantiationContext) {
self.init(value: json)
_owner = owner
}
public func asJSON(errors: inout [FHIRValidationError]) -> JSONType {
return value
}
// MARK: - ExpressibleByStringLiteral
public init(stringLiteral value: StringLiteralType) {
self.value = value
}
public init(unicodeScalarLiteral value: Character) {
self.value = "\(value)"
}
public init(extendedGraphemeClusterLiteral value: StringLiteralType) {
self.value = value
}
// MARK: - Printable, Equatable and Comparable
public var description: String {
return "<Base64Binary; \(value.count) chars>"
}
}
extension Base64Binary: Equatable, Comparable {
public static func ==(lhs: Base64Binary, rhs: Base64Binary) -> Bool {
return lhs.value == rhs.value
}
public static func <(lh: Base64Binary, rh: Base64Binary) -> Bool {
return lh.value < rh.value
}
}