2024-11-10 17:51:53 +11:00
|
|
|
/*
|
|
|
|
* darwin-apk © 2024 Gay Pizza Specifications
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
2024-11-08 21:22:33 +11:00
|
|
|
|
2024-11-15 19:54:35 +11:00
|
|
|
public struct ApkIndex {
|
|
|
|
public let packages: [ApkIndexPackage]
|
2024-11-08 21:22:33 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
extension ApkIndex {
|
|
|
|
func first(name: String) -> ApkIndexPackage? {
|
|
|
|
self.packages.first {
|
|
|
|
$0.name == name
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-11-15 19:54:35 +11:00
|
|
|
public extension ApkIndex {
|
2024-11-08 21:22:33 +11:00
|
|
|
static func merge<S: Sequence>(_ tables: S) -> Self where S.Element == Self {
|
|
|
|
Self.init(packages: tables.flatMap(\.packages))
|
|
|
|
}
|
|
|
|
|
|
|
|
static func merge(_ tables: Self...) -> ApkIndex {
|
|
|
|
Self.init(packages: tables.flatMap(\.packages))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
extension ApkIndex {
|
|
|
|
init(raw: ApkRawIndex) throws {
|
|
|
|
self.packages = try raw.packages.map {
|
|
|
|
try ApkIndexPackage(raw: $0)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-11-10 17:35:07 +11:00
|
|
|
|
|
|
|
extension ApkIndex: CustomStringConvertible {
|
2024-11-15 19:54:35 +11:00
|
|
|
public var description: String {
|
2024-11-10 17:35:07 +11:00
|
|
|
self.packages.map(String.init).joined(separator: "\n")
|
|
|
|
}
|
|
|
|
}
|