2024-11-10 17:51:53 +11:00
|
|
|
/*
|
|
|
|
* darwin-apk © 2024 Gay Pizza Specifications
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
2024-11-10 03:30:55 +11:00
|
|
|
|
|
|
|
protocol ApkIndexRequirementRef: Equatable, Hashable {
|
|
|
|
var name: String { get }
|
|
|
|
var invert: Bool { get }
|
|
|
|
|
2024-11-10 21:00:07 +11:00
|
|
|
init(name: String, version spec: ApkVersionSpecification)
|
2024-11-10 03:30:55 +11:00
|
|
|
|
|
|
|
func satisfied(by other: ApkIndexPackage) -> Bool
|
|
|
|
}
|
|
|
|
|
|
|
|
extension ApkIndexRequirementRef {
|
|
|
|
var invert: Bool { false }
|
|
|
|
func satisfied(by _: ApkIndexPackage) -> Bool { true }
|
|
|
|
|
|
|
|
static func extract<T: ApkIndexRequirementRef>(_ blob: String) throws(ApkRequirement.ParseError) -> [T] {
|
|
|
|
return try blob.components(separatedBy: " ")
|
|
|
|
.map { token throws(ApkRequirement.ParseError) in
|
2024-11-10 21:00:07 +11:00
|
|
|
let (name, versionSpec) = try ApkRequirement.extract(blob: token)
|
|
|
|
return .init(name: name, version: versionSpec)
|
2024-11-10 03:30:55 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|