-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathenum.swift
More file actions
60 lines (56 loc) · 2.01 KB
/
Copy pathenum.swift
File metadata and controls
60 lines (56 loc) · 2.01 KB
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
//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2023 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
extension Templates {
static let enumTemplate = """
{{%CONTENT_TYPE:TEXT}}
{{#isExtensible}}
{{scope}} struct {{name}}: RawRepresentable, Equatable, Codable, Sendable, CodingKeyRepresentable {
{{scope}} var rawValue: String
{{scope}} init(rawValue: String) {
self.rawValue = rawValue
}
{{#stringValues.values}}
{{#documentation}}
{{>comment}}
{{/documentation}}
{{scope}} static var {{case}}: Self { .init(rawValue: "{{rawValue}}") }
{{/stringValues.values}}
}
{{/isExtensible}}
{{^isExtensible}}
{{#stringValues}}
{{scope}} enum {{name}}: String, CustomStringConvertible, Codable, Sendable, CodingKeyRepresentable {
{{#values}}
{{#documentation}}
{{>comment}}
{{/documentation}}
case {{case}} = "{{rawValue}}"
{{/values}}
{{scope}} var description: String { return self.rawValue }
}
{{/stringValues}}
{{#intValues}}
{{scope}} enum {{name}}: Int, CustomStringConvertible, Codable, Sendable, CodingKeyRepresentable {
{{#values}}
{{#documentation}}
{{>comment}}
{{/documentation}}
case {{case}} = {{rawValue}}
{{/values}}
{{scope}} var description: String { return "\\(self.rawValue)" }
}
{{/intValues}}
{{/isExtensible}}
"""
}