mirror of
https://github.com/GLEGram/GLEGram-iOS.git
synced 2026-04-23 11:26:54 +02:00
4647310322
Based on Swiftgram 12.5 (Telegram iOS 12.5). All GLEGram features ported and organized in GLEGram/ folder. Features: Ghost Mode, Saved Deleted Messages, Content Protection Bypass, Font Replacement, Fake Profile, Chat Export, Plugin System, and more. See CHANGELOG_12.5.md for full details.
58 lines
1.3 KiB
Swift
58 lines
1.3 KiB
Swift
import Foundation
|
|
import JSONUtilities
|
|
|
|
public struct TargetReference: Hashable {
|
|
public var name: String
|
|
public var location: Location
|
|
|
|
public enum Location: Hashable {
|
|
case local
|
|
case project(String)
|
|
}
|
|
|
|
public init(name: String, location: Location) {
|
|
self.name = name
|
|
self.location = location
|
|
}
|
|
}
|
|
|
|
extension TargetReference {
|
|
public init(_ string: String) throws {
|
|
let paths = string.split(separator: "/")
|
|
switch paths.count {
|
|
case 2:
|
|
location = .project(String(paths[0]))
|
|
name = String(paths[1])
|
|
case 1:
|
|
location = .local
|
|
name = String(paths[0])
|
|
default:
|
|
throw SpecParsingError.invalidTargetReference(string)
|
|
}
|
|
}
|
|
|
|
public static func local(_ name: String) -> TargetReference {
|
|
TargetReference(name: name, location: .local)
|
|
}
|
|
}
|
|
|
|
extension TargetReference: ExpressibleByStringLiteral {
|
|
public init(stringLiteral value: String) {
|
|
try! self.init(value)
|
|
}
|
|
}
|
|
|
|
extension TargetReference: CustomStringConvertible {
|
|
public var reference: String {
|
|
switch location {
|
|
case .local: return name
|
|
case .project(let root):
|
|
return "\(root)/\(name)"
|
|
}
|
|
}
|
|
|
|
public var description: String {
|
|
reference
|
|
}
|
|
}
|