- Rename source module from RDReaderView to RDEpubReaderView - Move all source files from Sources/RDReaderView/ to Sources/RDEpubReaderView/ - Update podspec: RDReaderView.podspec -> RDEpubReaderView.podspec - Update Podfile, demo project, and CocoaPods config for new pod name - Delete old RDReaderView pod support files from ReadViewDemo/Pods - Add new RDEpubReaderView pod support files - Update documentation (API ref, architecture, UML, conventions, etc.) - Add FixedLayoutRotationTests - Update .gitignore: exclude .DS_Store, manual unpack backups, _ssoft-output
40 lines
1.2 KiB
Swift
40 lines
1.2 KiB
Swift
import Foundation
|
|
|
|
public struct RDEPUBCFIPath: Codable, Equatable, Hashable {
|
|
|
|
public var steps: [RDEPUBCFIStep]
|
|
|
|
public init(steps: [RDEPUBCFIStep] = []) {
|
|
self.steps = steps
|
|
}
|
|
|
|
public func commonPrefix(with other: RDEPUBCFIPath) -> RDEPUBCFIPath {
|
|
var prefix: [RDEPUBCFIStep] = []
|
|
let upperBound = min(steps.count, other.steps.count)
|
|
for index in 0..<upperBound {
|
|
guard steps[index] == other.steps[index] else { break }
|
|
prefix.append(steps[index])
|
|
}
|
|
return RDEPUBCFIPath(steps: prefix)
|
|
}
|
|
|
|
public func droppingPrefix(_ prefix: RDEPUBCFIPath) -> RDEPUBCFIPath {
|
|
guard prefix.steps.count <= steps.count else { return self }
|
|
let candidate = Array(steps.prefix(prefix.steps.count))
|
|
guard candidate == prefix.steps else { return self }
|
|
return RDEPUBCFIPath(steps: Array(steps.dropFirst(prefix.steps.count)))
|
|
}
|
|
}
|
|
|
|
public struct RDEPUBCFIStep: Codable, Equatable, Hashable {
|
|
|
|
public var index: Int
|
|
|
|
public var idAssertion: String?
|
|
|
|
public init(index: Int, idAssertion: String? = nil) {
|
|
self.index = index
|
|
self.idAssertion = idAssertion?.rd_nilIfEmpty
|
|
}
|
|
}
|