File tree Expand file tree Collapse file tree 2 files changed +70
-47
lines changed
Expand file tree Collapse file tree 2 files changed +70
-47
lines changed Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright © 2025 Dustin Collins (Strega's Gate)
3+ * All Rights Reserved.
4+ *
5+ * http://stregasgate.com
6+ */
7+
8+ public enum BuildConfiguration {
9+ /// The DEBUG build configuration
10+ case debug
11+ /// The RELEASE build configuration
12+ case release
13+ /// The DISTRIBUTE package trait. Enable the DISTRIBUTE package trait when importing GateEngine as a dependency.
14+ case distribute
15+ }
16+
17+ /**
18+ Returns true when the desired config matches the build config.
19+ - parameter config: The desired build configuration.
20+ - returns: `true` when the current build configuration matches `config`
21+ */
22+ @_transparent
23+ @inlinable
24+ public func when( _ config: BuildConfiguration ) -> Bool {
25+ switch config {
26+ case . debug:
27+ #if DEBUG
28+ return true
29+ #else
30+ return false
31+ #endif
32+ case . release:
33+ #if RELEASE
34+ return true
35+ #else
36+ return false
37+ #endif
38+ case . distribute:
39+ #if DISTRIBUTE
40+ return true
41+ #else
42+ return false
43+ #endif
44+ }
45+ }
46+
47+ @_transparent
48+ @inlinable
49+ public func when( not config: BuildConfiguration ) -> Bool {
50+ return when ( config) == false
51+ }
52+
53+ /**
54+ Returns a given value when the desired config matches the build config.
55+ - parameter config: The desired build configuration.
56+ - parameter trueValue: The value to return when the config is a match.
57+ - parameter falseValue: The value to return when the config is **not** a match.
58+ - returns: `trueValue` when the current build configuration matches `config`, otherwsie `falseValue`
59+ */
60+ @_transparent
61+ @inlinable
62+ public func when< T> ( _ config: BuildConfiguration , use trueValue: T , else falseValue: T ) -> T {
63+ return when ( config) ? trueValue : falseValue
64+ }
65+
66+ @_transparent
67+ @inlinable
68+ public func when< T> ( not config: BuildConfiguration , use trueValue: T , else falseValue: T ) -> T {
69+ return when ( config) == false ? trueValue : falseValue
70+ }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments