mirror of
https://github.com/exyte/Macaw.git
synced 2024-10-26 13:01:25 +03:00
Cathage project dependencies attached as sources
This commit is contained in:
parent
a05516495b
commit
23dadfd5e0
617
Dependencies/SWXMLHash/SWXMLHash+TypeConversion.swift
vendored
Normal file
617
Dependencies/SWXMLHash/SWXMLHash+TypeConversion.swift
vendored
Normal file
@ -0,0 +1,617 @@
|
|||||||
|
//
|
||||||
|
// SWXMLHash+TypeConversion.swift
|
||||||
|
// SWXMLHash
|
||||||
|
//
|
||||||
|
// Created by Maciek Grzybowski on 29.02.2016.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
// swiftlint:disable line_length
|
||||||
|
// swiftlint:disable file_length
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
// MARK: - XMLIndexerDeserializable
|
||||||
|
|
||||||
|
/// Provides XMLIndexer deserialization / type transformation support
|
||||||
|
public protocol XMLIndexerDeserializable {
|
||||||
|
/// Method for deserializing elements from XMLIndexer
|
||||||
|
static func deserialize(_ element: XMLIndexer) throws -> Self
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Provides XMLIndexer deserialization / type transformation support
|
||||||
|
public extension XMLIndexerDeserializable {
|
||||||
|
/**
|
||||||
|
A default implementation that will throw an error if it is called
|
||||||
|
|
||||||
|
- parameters:
|
||||||
|
- element: the XMLIndexer to be deserialized
|
||||||
|
- throws: an XMLDeserializationError.ImplementationIsMissing if no implementation is found
|
||||||
|
- returns: this won't ever return because of the error being thrown
|
||||||
|
*/
|
||||||
|
static func deserialize(_ element: XMLIndexer) throws -> Self {
|
||||||
|
throw XMLDeserializationError.ImplementationIsMissing(
|
||||||
|
method: "XMLIndexerDeserializable.deserialize(element: XMLIndexer)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// MARK: - XMLElementDeserializable
|
||||||
|
|
||||||
|
/// Provides XMLElement deserialization / type transformation support
|
||||||
|
public protocol XMLElementDeserializable {
|
||||||
|
/// Method for deserializing elements from XMLElement
|
||||||
|
static func deserialize(_ element: XMLElement) throws -> Self
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Provides XMLElement deserialization / type transformation support
|
||||||
|
public extension XMLElementDeserializable {
|
||||||
|
/**
|
||||||
|
A default implementation that will throw an error if it is called
|
||||||
|
|
||||||
|
- parameters:
|
||||||
|
- element: the XMLElement to be deserialized
|
||||||
|
- throws: an XMLDeserializationError.ImplementationIsMissing if no implementation is found
|
||||||
|
- returns: this won't ever return because of the error being thrown
|
||||||
|
*/
|
||||||
|
static func deserialize(_ element: XMLElement) throws -> Self {
|
||||||
|
throw XMLDeserializationError.ImplementationIsMissing(
|
||||||
|
method: "XMLElementDeserializable.deserialize(element: XMLElement)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - XMLAttributeDeserializable
|
||||||
|
|
||||||
|
/// Provides XMLAttribute deserialization / type transformation support
|
||||||
|
public protocol XMLAttributeDeserializable {
|
||||||
|
static func deserialize(_ attribute: XMLAttribute) throws -> Self
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Provides XMLAttribute deserialization / type transformation support
|
||||||
|
public extension XMLAttributeDeserializable {
|
||||||
|
/**
|
||||||
|
A default implementation that will throw an error if it is called
|
||||||
|
|
||||||
|
- parameters:
|
||||||
|
- attribute: The XMLAttribute to be deserialized
|
||||||
|
- throws: an XMLDeserializationError.ImplementationIsMissing if no implementation is found
|
||||||
|
- returns: this won't ever return because of the error being thrown
|
||||||
|
*/
|
||||||
|
static func deserialize(attribute: XMLAttribute) throws -> Self {
|
||||||
|
throw XMLDeserializationError.ImplementationIsMissing(
|
||||||
|
method: "XMLAttributeDeserializable(element: XMLAttribute)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - XMLIndexer Extensions
|
||||||
|
|
||||||
|
public extension XMLIndexer {
|
||||||
|
|
||||||
|
// MARK: - XMLAttributeDeserializable
|
||||||
|
|
||||||
|
/**
|
||||||
|
Attempts to deserialize the value of the specified attribute of the current XMLIndexer
|
||||||
|
element to `T`
|
||||||
|
|
||||||
|
- parameter attr: The attribute to deserialize
|
||||||
|
- throws: an XMLDeserializationError if there is a problem with deserialization
|
||||||
|
- returns: The deserialized `T` value
|
||||||
|
*/
|
||||||
|
func value<T: XMLAttributeDeserializable>(ofAttribute attr: String) throws -> T {
|
||||||
|
switch self {
|
||||||
|
case .Element(let element):
|
||||||
|
return try element.value(ofAttribute: attr)
|
||||||
|
case .Stream(let opStream):
|
||||||
|
return try opStream.findElements().value(ofAttribute: attr)
|
||||||
|
default:
|
||||||
|
throw XMLDeserializationError.NodeIsInvalid(node: self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Attempts to deserialize the value of the specified attribute of the current XMLIndexer
|
||||||
|
element to `T?`
|
||||||
|
|
||||||
|
- parameter attr: The attribute to deserialize
|
||||||
|
- returns: The deserialized `T?` value, or nil if the attribute does not exist
|
||||||
|
*/
|
||||||
|
func value<T: XMLAttributeDeserializable>(ofAttribute attr: String) -> T? {
|
||||||
|
switch self {
|
||||||
|
case .Element(let element):
|
||||||
|
return element.value(ofAttribute: attr)
|
||||||
|
case .Stream(let opStream):
|
||||||
|
return opStream.findElements().value(ofAttribute: attr)
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Attempts to deserialize the value of the specified attribute of the current XMLIndexer
|
||||||
|
element to `[T]`
|
||||||
|
|
||||||
|
- parameter attr: The attribute to deserialize
|
||||||
|
- throws: an XMLDeserializationError if there is a problem with deserialization
|
||||||
|
- returns: The deserialized `[T]` value
|
||||||
|
*/
|
||||||
|
func value<T: XMLAttributeDeserializable>(ofAttribute attr: String) throws -> [T] {
|
||||||
|
switch self {
|
||||||
|
case .List(let elements):
|
||||||
|
return try elements.map { try $0.value(ofAttribute: attr) }
|
||||||
|
case .Element(let element):
|
||||||
|
return try [element].map { try $0.value(ofAttribute: attr) }
|
||||||
|
case .Stream(let opStream):
|
||||||
|
return try opStream.findElements().value(ofAttribute: attr)
|
||||||
|
default:
|
||||||
|
throw XMLDeserializationError.NodeIsInvalid(node: self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Attempts to deserialize the value of the specified attribute of the current XMLIndexer
|
||||||
|
element to `[T]?`
|
||||||
|
|
||||||
|
- parameter attr: The attribute to deserialize
|
||||||
|
- throws: an XMLDeserializationError if there is a problem with deserialization
|
||||||
|
- returns: The deserialized `[T]?` value
|
||||||
|
*/
|
||||||
|
func value<T: XMLAttributeDeserializable>(ofAttribute attr: String) throws -> [T]? {
|
||||||
|
switch self {
|
||||||
|
case .List(let elements):
|
||||||
|
return try elements.map { try $0.value(ofAttribute: attr) }
|
||||||
|
case .Element(let element):
|
||||||
|
return try [element].map { try $0.value(ofAttribute: attr) }
|
||||||
|
case .Stream(let opStream):
|
||||||
|
return try opStream.findElements().value(ofAttribute: attr)
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Attempts to deserialize the value of the specified attribute of the current XMLIndexer
|
||||||
|
element to `[T?]`
|
||||||
|
|
||||||
|
- parameter attr: The attribute to deserialize
|
||||||
|
- throws: an XMLDeserializationError if there is a problem with deserialization
|
||||||
|
- returns: The deserialized `[T?]` value
|
||||||
|
*/
|
||||||
|
func value<T: XMLAttributeDeserializable>(ofAttribute attr: String) throws -> [T?] {
|
||||||
|
switch self {
|
||||||
|
case .List(let elements):
|
||||||
|
return elements.map { $0.value(ofAttribute: attr) }
|
||||||
|
case .Element(let element):
|
||||||
|
return [element].map { $0.value(ofAttribute: attr) }
|
||||||
|
case .Stream(let opStream):
|
||||||
|
return try opStream.findElements().value(ofAttribute: attr)
|
||||||
|
default:
|
||||||
|
throw XMLDeserializationError.NodeIsInvalid(node: self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - XMLElementDeserializable
|
||||||
|
|
||||||
|
/**
|
||||||
|
Attempts to deserialize the current XMLElement element to `T`
|
||||||
|
|
||||||
|
- throws: an XMLDeserializationError.NodeIsInvalid if the current indexed level isn't an Element
|
||||||
|
- returns: the deserialized `T` value
|
||||||
|
*/
|
||||||
|
func value<T: XMLElementDeserializable>() throws -> T {
|
||||||
|
switch self {
|
||||||
|
case .Element(let element):
|
||||||
|
return try T.deserialize(element)
|
||||||
|
case .Stream(let opStream):
|
||||||
|
return try opStream.findElements().value()
|
||||||
|
default:
|
||||||
|
throw XMLDeserializationError.NodeIsInvalid(node: self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Attempts to deserialize the current XMLElement element to `T?`
|
||||||
|
|
||||||
|
- returns: the deserialized `T?` value
|
||||||
|
- throws: an XMLDeserializationError is there is a problem with deserialization
|
||||||
|
*/
|
||||||
|
func value<T: XMLElementDeserializable>() throws -> T? {
|
||||||
|
switch self {
|
||||||
|
case .Element(let element):
|
||||||
|
return try T.deserialize(element)
|
||||||
|
case .Stream(let opStream):
|
||||||
|
return try opStream.findElements().value()
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Attempts to deserialize the current XMLElement element to `[T]`
|
||||||
|
|
||||||
|
- returns: the deserialized `[T]` value
|
||||||
|
- throws: an XMLDeserializationError is there is a problem with deserialization
|
||||||
|
*/
|
||||||
|
func value<T: XMLElementDeserializable>() throws -> [T] {
|
||||||
|
switch self {
|
||||||
|
case .List(let elements):
|
||||||
|
return try elements.map { try T.deserialize($0) }
|
||||||
|
case .Element(let element):
|
||||||
|
return try [element].map { try T.deserialize($0) }
|
||||||
|
case .Stream(let opStream):
|
||||||
|
return try opStream.findElements().value()
|
||||||
|
default:
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Attempts to deserialize the current XMLElement element to `[T]?`
|
||||||
|
|
||||||
|
- returns: the deserialized `[T]?` value
|
||||||
|
- throws: an XMLDeserializationError is there is a problem with deserialization
|
||||||
|
*/
|
||||||
|
func value<T: XMLElementDeserializable>() throws -> [T]? {
|
||||||
|
switch self {
|
||||||
|
case .List(let elements):
|
||||||
|
return try elements.map { try T.deserialize($0) }
|
||||||
|
case .Element(let element):
|
||||||
|
return try [element].map { try T.deserialize($0) }
|
||||||
|
case .Stream(let opStream):
|
||||||
|
return try opStream.findElements().value()
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Attempts to deserialize the current XMLElement element to `[T?]`
|
||||||
|
|
||||||
|
- returns: the deserialized `[T?]` value
|
||||||
|
- throws: an XMLDeserializationError is there is a problem with deserialization
|
||||||
|
*/
|
||||||
|
func value<T: XMLElementDeserializable>() throws -> [T?] {
|
||||||
|
switch self {
|
||||||
|
case .List(let elements):
|
||||||
|
return try elements.map { try T.deserialize($0) }
|
||||||
|
case .Element(let element):
|
||||||
|
return try [element].map { try T.deserialize($0) }
|
||||||
|
case .Stream(let opStream):
|
||||||
|
return try opStream.findElements().value()
|
||||||
|
default:
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// MARK: - XMLIndexerDeserializable
|
||||||
|
|
||||||
|
/**
|
||||||
|
Attempts to deserialize the current XMLIndexer element to `T`
|
||||||
|
|
||||||
|
- returns: the deserialized `T` value
|
||||||
|
- throws: an XMLDeserializationError is there is a problem with deserialization
|
||||||
|
*/
|
||||||
|
func value<T: XMLIndexerDeserializable>() throws -> T {
|
||||||
|
switch self {
|
||||||
|
case .Element:
|
||||||
|
return try T.deserialize(self)
|
||||||
|
case .Stream(let opStream):
|
||||||
|
return try opStream.findElements().value()
|
||||||
|
default:
|
||||||
|
throw XMLDeserializationError.NodeIsInvalid(node: self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Attempts to deserialize the current XMLIndexer element to `T?`
|
||||||
|
|
||||||
|
- returns: the deserialized `T?` value
|
||||||
|
- throws: an XMLDeserializationError is there is a problem with deserialization
|
||||||
|
*/
|
||||||
|
func value<T: XMLIndexerDeserializable>() throws -> T? {
|
||||||
|
switch self {
|
||||||
|
case .Element:
|
||||||
|
return try T.deserialize(self)
|
||||||
|
case .Stream(let opStream):
|
||||||
|
return try opStream.findElements().value()
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Attempts to deserialize the current XMLIndexer element to `[T]`
|
||||||
|
|
||||||
|
- returns: the deserialized `[T]` value
|
||||||
|
- throws: an XMLDeserializationError is there is a problem with deserialization
|
||||||
|
*/
|
||||||
|
func value<T>() throws -> [T] where T: XMLIndexerDeserializable {
|
||||||
|
switch self {
|
||||||
|
case .List(let elements):
|
||||||
|
return try elements.map { try T.deserialize( XMLIndexer($0) ) }
|
||||||
|
case .Element(let element):
|
||||||
|
return try [element].map { try T.deserialize( XMLIndexer($0) ) }
|
||||||
|
case .Stream(let opStream):
|
||||||
|
return try opStream.findElements().value()
|
||||||
|
default:
|
||||||
|
throw XMLDeserializationError.NodeIsInvalid(node: self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Attempts to deserialize the current XMLIndexer element to `[T]?`
|
||||||
|
|
||||||
|
- returns: the deserialized `[T]?` value
|
||||||
|
- throws: an XMLDeserializationError is there is a problem with deserialization
|
||||||
|
*/
|
||||||
|
func value<T: XMLIndexerDeserializable>() throws -> [T]? {
|
||||||
|
switch self {
|
||||||
|
case .List(let elements):
|
||||||
|
return try elements.map { try T.deserialize( XMLIndexer($0) ) }
|
||||||
|
case .Element(let element):
|
||||||
|
return try [element].map { try T.deserialize( XMLIndexer($0) ) }
|
||||||
|
case .Stream(let opStream):
|
||||||
|
return try opStream.findElements().value()
|
||||||
|
default:
|
||||||
|
throw XMLDeserializationError.NodeIsInvalid(node: self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Attempts to deserialize the current XMLIndexer element to `[T?]`
|
||||||
|
|
||||||
|
- returns: the deserialized `[T?]` value
|
||||||
|
- throws: an XMLDeserializationError is there is a problem with deserialization
|
||||||
|
*/
|
||||||
|
func value<T: XMLIndexerDeserializable>() throws -> [T?] {
|
||||||
|
switch self {
|
||||||
|
case .List(let elements):
|
||||||
|
return try elements.map { try T.deserialize( XMLIndexer($0) ) }
|
||||||
|
case .Element(let element):
|
||||||
|
return try [element].map { try T.deserialize( XMLIndexer($0) ) }
|
||||||
|
case .Stream(let opStream):
|
||||||
|
return try opStream.findElements().value()
|
||||||
|
default:
|
||||||
|
throw XMLDeserializationError.NodeIsInvalid(node: self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - XMLElement Extensions
|
||||||
|
|
||||||
|
extension XMLElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
Attempts to deserialize the specified attribute of the current XMLElement to `T`
|
||||||
|
|
||||||
|
- parameter attr: The attribute to deserialize
|
||||||
|
- throws: an XMLDeserializationError if there is a problem with deserialization
|
||||||
|
- returns: The deserialized `T` value
|
||||||
|
*/
|
||||||
|
public func value<T: XMLAttributeDeserializable>(ofAttribute attr: String) throws -> T {
|
||||||
|
if let attr = self.attribute(by: attr) {
|
||||||
|
return try T.deserialize(attr)
|
||||||
|
} else {
|
||||||
|
throw XMLDeserializationError.AttributeDoesNotExist(element: self, attribute: attr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Attempts to deserialize the specified attribute of the current XMLElement to `T?`
|
||||||
|
|
||||||
|
- parameter attr: The attribute to deserialize
|
||||||
|
- returns: The deserialized `T?` value, or nil if the attribute does not exist.
|
||||||
|
*/
|
||||||
|
public func value<T: XMLAttributeDeserializable>(ofAttribute attr: String) -> T? {
|
||||||
|
if let attr = self.attribute(by: attr) {
|
||||||
|
return try? T.deserialize(attr)
|
||||||
|
} else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Gets the text associated with this element, or throws an exception if the text is empty
|
||||||
|
|
||||||
|
- throws: XMLDeserializationError.NodeHasNoValue if the element text is empty
|
||||||
|
- returns: The element text
|
||||||
|
*/
|
||||||
|
internal func nonEmptyTextOrThrow() throws -> String {
|
||||||
|
if let textVal = text, !textVal.characters.isEmpty {
|
||||||
|
return textVal
|
||||||
|
}
|
||||||
|
|
||||||
|
throw XMLDeserializationError.NodeHasNoValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - XMLDeserializationError
|
||||||
|
|
||||||
|
/// The error that is thrown if there is a problem with deserialization
|
||||||
|
public enum XMLDeserializationError: Error, CustomStringConvertible {
|
||||||
|
case ImplementationIsMissing(method: String)
|
||||||
|
case NodeIsInvalid(node: XMLIndexer)
|
||||||
|
case NodeHasNoValue
|
||||||
|
case TypeConversionFailed(type: String, element: XMLElement)
|
||||||
|
case AttributeDoesNotExist(element: XMLElement, attribute: String)
|
||||||
|
case AttributeDeserializationFailed(type: String, attribute: XMLAttribute)
|
||||||
|
|
||||||
|
/// The text description for the error thrown
|
||||||
|
public var description: String {
|
||||||
|
switch self {
|
||||||
|
case .ImplementationIsMissing(let method):
|
||||||
|
return "This deserialization method is not implemented: \(method)"
|
||||||
|
case .NodeIsInvalid(let node):
|
||||||
|
return "This node is invalid: \(node)"
|
||||||
|
case .NodeHasNoValue:
|
||||||
|
return "This node is empty"
|
||||||
|
case .TypeConversionFailed(let type, let node):
|
||||||
|
return "Can't convert node \(node) to value of type \(type)"
|
||||||
|
case .AttributeDoesNotExist(let element, let attribute):
|
||||||
|
return "Element \(element) does not contain attribute: \(attribute)"
|
||||||
|
case .AttributeDeserializationFailed(let type, let attribute):
|
||||||
|
return "Can't convert attribute \(attribute) to value of type \(type)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// MARK: - Common types deserialization
|
||||||
|
|
||||||
|
extension String: XMLElementDeserializable, XMLAttributeDeserializable {
|
||||||
|
/**
|
||||||
|
Attempts to deserialize XML element content to a String
|
||||||
|
|
||||||
|
- parameters:
|
||||||
|
- element: the XMLElement to be deserialized
|
||||||
|
- throws: an XMLDeserializationError.TypeConversionFailed if the element cannot be deserialized
|
||||||
|
- returns: the deserialized String value
|
||||||
|
*/
|
||||||
|
public static func deserialize(_ element: XMLElement) throws -> String {
|
||||||
|
guard let text = element.text else {
|
||||||
|
throw XMLDeserializationError.TypeConversionFailed(type: "String", element: element)
|
||||||
|
}
|
||||||
|
return text
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Attempts to deserialize XML Attribute content to a String
|
||||||
|
|
||||||
|
- parameter attribute: the XMLAttribute to be deserialized
|
||||||
|
- returns: the deserialized String value
|
||||||
|
*/
|
||||||
|
public static func deserialize(_ attribute: XMLAttribute) -> String {
|
||||||
|
return attribute.text
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Int: XMLElementDeserializable, XMLAttributeDeserializable {
|
||||||
|
/**
|
||||||
|
Attempts to deserialize XML element content to a Int
|
||||||
|
|
||||||
|
- parameters:
|
||||||
|
- element: the XMLElement to be deserialized
|
||||||
|
- throws: an XMLDeserializationError.TypeConversionFailed if the element cannot be deserialized
|
||||||
|
- returns: the deserialized Int value
|
||||||
|
*/
|
||||||
|
public static func deserialize(_ element: XMLElement) throws -> Int {
|
||||||
|
guard let value = Int(try element.nonEmptyTextOrThrow()) else {
|
||||||
|
throw XMLDeserializationError.TypeConversionFailed(type: "Int", element: element)
|
||||||
|
}
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Attempts to deserialize XML attribute content to an Int
|
||||||
|
|
||||||
|
- parameter attribute: The XMLAttribute to be deserialized
|
||||||
|
- throws: an XMLDeserializationError.AttributeDeserializationFailed if the attribute cannot be
|
||||||
|
deserialized
|
||||||
|
- returns: the deserialized Int value
|
||||||
|
*/
|
||||||
|
public static func deserialize(_ attribute: XMLAttribute) throws -> Int {
|
||||||
|
guard let value = Int(attribute.text) else {
|
||||||
|
throw XMLDeserializationError.AttributeDeserializationFailed(
|
||||||
|
type: "Int", attribute: attribute)
|
||||||
|
}
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Double: XMLElementDeserializable, XMLAttributeDeserializable {
|
||||||
|
/**
|
||||||
|
Attempts to deserialize XML element content to a Double
|
||||||
|
|
||||||
|
- parameters:
|
||||||
|
- element: the XMLElement to be deserialized
|
||||||
|
- throws: an XMLDeserializationError.TypeConversionFailed if the element cannot be deserialized
|
||||||
|
- returns: the deserialized Double value
|
||||||
|
*/
|
||||||
|
public static func deserialize(_ element: XMLElement) throws -> Double {
|
||||||
|
guard let value = Double(try element.nonEmptyTextOrThrow()) else {
|
||||||
|
throw XMLDeserializationError.TypeConversionFailed(type: "Double", element: element)
|
||||||
|
}
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Attempts to deserialize XML attribute content to a Double
|
||||||
|
|
||||||
|
- parameter attribute: The XMLAttribute to be deserialized
|
||||||
|
- throws: an XMLDeserializationError.AttributeDeserializationFailed if the attribute cannot be
|
||||||
|
deserialized
|
||||||
|
- returns: the deserialized Double value
|
||||||
|
*/
|
||||||
|
public static func deserialize(_ attribute: XMLAttribute) throws -> Double {
|
||||||
|
guard let value = Double(attribute.text) else {
|
||||||
|
throw XMLDeserializationError.AttributeDeserializationFailed(
|
||||||
|
type: "Double", attribute: attribute)
|
||||||
|
}
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Float: XMLElementDeserializable, XMLAttributeDeserializable {
|
||||||
|
/**
|
||||||
|
Attempts to deserialize XML element content to a Float
|
||||||
|
|
||||||
|
- parameters:
|
||||||
|
- element: the XMLElement to be deserialized
|
||||||
|
- throws: an XMLDeserializationError.TypeConversionFailed if the element cannot be deserialized
|
||||||
|
- returns: the deserialized Float value
|
||||||
|
*/
|
||||||
|
public static func deserialize(_ element: XMLElement) throws -> Float {
|
||||||
|
guard let value = Float(try element.nonEmptyTextOrThrow()) else {
|
||||||
|
throw XMLDeserializationError.TypeConversionFailed(type: "Float", element: element)
|
||||||
|
}
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Attempts to deserialize XML attribute content to a Float
|
||||||
|
|
||||||
|
- parameter attribute: The XMLAttribute to be deserialized
|
||||||
|
- throws: an XMLDeserializationError.AttributeDeserializationFailed if the attribute cannot be
|
||||||
|
deserialized
|
||||||
|
- returns: the deserialized Float value
|
||||||
|
*/
|
||||||
|
public static func deserialize(_ attribute: XMLAttribute) throws -> Float {
|
||||||
|
guard let value = Float(attribute.text) else {
|
||||||
|
throw XMLDeserializationError.AttributeDeserializationFailed(
|
||||||
|
type: "Float", attribute: attribute)
|
||||||
|
}
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Bool: XMLElementDeserializable, XMLAttributeDeserializable {
|
||||||
|
// swiftlint:disable line_length
|
||||||
|
/**
|
||||||
|
Attempts to deserialize XML element content to a Bool. This uses NSString's 'boolValue'
|
||||||
|
described [here](https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/#//apple_ref/occ/instp/NSString/boolValue)
|
||||||
|
|
||||||
|
- parameters:
|
||||||
|
- element: the XMLElement to be deserialized
|
||||||
|
- throws: an XMLDeserializationError.TypeConversionFailed if the element cannot be deserialized
|
||||||
|
- returns: the deserialized Bool value
|
||||||
|
*/
|
||||||
|
public static func deserialize(_ element: XMLElement) throws -> Bool {
|
||||||
|
let value = Bool(NSString(string: try element.nonEmptyTextOrThrow()).boolValue)
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Attempts to deserialize XML attribute content to a Bool. This uses NSString's 'boolValue'
|
||||||
|
described [here](https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/#//apple_ref/occ/instp/NSString/boolValue)
|
||||||
|
|
||||||
|
- parameter attribute: The XMLAttribute to be deserialized
|
||||||
|
- throws: an XMLDeserializationError.AttributeDeserializationFailed if the attribute cannot be
|
||||||
|
deserialized
|
||||||
|
- returns: the deserialized Bool value
|
||||||
|
*/
|
||||||
|
public static func deserialize(_ attribute: XMLAttribute) throws -> Bool {
|
||||||
|
let value = Bool(NSString(string: attribute.text).boolValue)
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
// swiftlint:enable line_length
|
||||||
|
}
|
825
Dependencies/SWXMLHash/SWXMLHash.swift
vendored
Normal file
825
Dependencies/SWXMLHash/SWXMLHash.swift
vendored
Normal file
@ -0,0 +1,825 @@
|
|||||||
|
//
|
||||||
|
// SWXMLHash.swift
|
||||||
|
//
|
||||||
|
// Copyright (c) 2014 David Mohundro
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
// swiftlint exceptions:
|
||||||
|
// - Disabled file_length because there are a number of users that still pull the
|
||||||
|
// source down as is and it makes pulling the code into a project easier.
|
||||||
|
|
||||||
|
// swiftlint:disable file_length
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
let rootElementName = "SWXMLHash_Root_Element"
|
||||||
|
|
||||||
|
/// Parser options
|
||||||
|
public class SWXMLHashOptions {
|
||||||
|
internal init() {}
|
||||||
|
|
||||||
|
/// determines whether to parse the XML with lazy parsing or not
|
||||||
|
public var shouldProcessLazily = false
|
||||||
|
|
||||||
|
/// determines whether to parse XML namespaces or not (forwards to
|
||||||
|
/// `XMLParser.shouldProcessNamespaces`)
|
||||||
|
public var shouldProcessNamespaces = false
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Simple XML parser
|
||||||
|
public class SWXMLHash {
|
||||||
|
let options: SWXMLHashOptions
|
||||||
|
|
||||||
|
private init(_ options: SWXMLHashOptions = SWXMLHashOptions()) {
|
||||||
|
self.options = options
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Method to configure how parsing works.
|
||||||
|
|
||||||
|
- parameters:
|
||||||
|
- configAction: a block that passes in an `SWXMLHashOptions` object with
|
||||||
|
options to be set
|
||||||
|
- returns: an `SWXMLHash` instance
|
||||||
|
*/
|
||||||
|
class public func config(_ configAction: (SWXMLHashOptions) -> ()) -> SWXMLHash {
|
||||||
|
let opts = SWXMLHashOptions()
|
||||||
|
configAction(opts)
|
||||||
|
return SWXMLHash(opts)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Begins parsing the passed in XML string.
|
||||||
|
|
||||||
|
- parameters:
|
||||||
|
- xml: an XML string. __Note__ that this is not a URL but a
|
||||||
|
string containing XML.
|
||||||
|
- returns: an `XMLIndexer` instance that can be iterated over
|
||||||
|
*/
|
||||||
|
public func parse(_ xml: String) -> XMLIndexer {
|
||||||
|
return parse(xml.data(using: String.Encoding.utf8)!)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Begins parsing the passed in XML string.
|
||||||
|
|
||||||
|
- parameters:
|
||||||
|
- data: a `Data` instance containing XML
|
||||||
|
- returns: an `XMLIndexer` instance that can be iterated over
|
||||||
|
*/
|
||||||
|
public func parse(_ data: Data) -> XMLIndexer {
|
||||||
|
let parser: SimpleXmlParser = options.shouldProcessLazily
|
||||||
|
? LazyXMLParser(options)
|
||||||
|
: FullXMLParser(options)
|
||||||
|
return parser.parse(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Method to parse XML passed in as a string.
|
||||||
|
|
||||||
|
- parameter xml: The XML to be parsed
|
||||||
|
- returns: An XMLIndexer instance that is used to look up elements in the XML
|
||||||
|
*/
|
||||||
|
class public func parse(_ xml: String) -> XMLIndexer {
|
||||||
|
return SWXMLHash().parse(xml)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Method to parse XML passed in as a Data instance.
|
||||||
|
|
||||||
|
- parameter data: The XML to be parsed
|
||||||
|
- returns: An XMLIndexer instance that is used to look up elements in the XML
|
||||||
|
*/
|
||||||
|
class public func parse(_ data: Data) -> XMLIndexer {
|
||||||
|
return SWXMLHash().parse(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Method to lazily parse XML passed in as a string.
|
||||||
|
|
||||||
|
- parameter xml: The XML to be parsed
|
||||||
|
- returns: An XMLIndexer instance that is used to look up elements in the XML
|
||||||
|
*/
|
||||||
|
class public func lazy(_ xml: String) -> XMLIndexer {
|
||||||
|
return config { conf in conf.shouldProcessLazily = true }.parse(xml)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Method to lazily parse XML passed in as a Data instance.
|
||||||
|
|
||||||
|
- parameter data: The XML to be parsed
|
||||||
|
- returns: An XMLIndexer instance that is used to look up elements in the XML
|
||||||
|
*/
|
||||||
|
class public func lazy(_ data: Data) -> XMLIndexer {
|
||||||
|
return config { conf in conf.shouldProcessLazily = true }.parse(data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Stack<T> {
|
||||||
|
var items = [T]()
|
||||||
|
mutating func push(_ item: T) {
|
||||||
|
items.append(item)
|
||||||
|
}
|
||||||
|
mutating func pop() -> T {
|
||||||
|
return items.removeLast()
|
||||||
|
}
|
||||||
|
mutating func drop() {
|
||||||
|
let _ = pop()
|
||||||
|
}
|
||||||
|
mutating func removeAll() {
|
||||||
|
items.removeAll(keepingCapacity: false)
|
||||||
|
}
|
||||||
|
func top() -> T {
|
||||||
|
return items[items.count - 1]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protocol SimpleXmlParser {
|
||||||
|
init(_ options: SWXMLHashOptions)
|
||||||
|
func parse(_ data: Data) -> XMLIndexer
|
||||||
|
}
|
||||||
|
|
||||||
|
#if os(Linux)
|
||||||
|
|
||||||
|
extension XMLParserDelegate {
|
||||||
|
|
||||||
|
func parserDidStartDocument(_ parser: Foundation.XMLParser) { }
|
||||||
|
func parserDidEndDocument(_ parser: Foundation.XMLParser) { }
|
||||||
|
|
||||||
|
func parser(_ parser: Foundation.XMLParser, foundNotationDeclarationWithName name: String, publicID: String?, systemID: String?) { }
|
||||||
|
|
||||||
|
func parser(_ parser: Foundation.XMLParser, foundUnparsedEntityDeclarationWithName name: String, publicID: String?, systemID: String?, notationName: String?) { }
|
||||||
|
|
||||||
|
func parser(_ parser: Foundation.XMLParser, foundAttributeDeclarationWithName attributeName: String, forElement elementName: String, type: String?, defaultValue: String?) { }
|
||||||
|
|
||||||
|
func parser(_ parser: Foundation.XMLParser, foundElementDeclarationWithName elementName: String, model: String) { }
|
||||||
|
|
||||||
|
func parser(_ parser: Foundation.XMLParser, foundInternalEntityDeclarationWithName name: String, value: String?) { }
|
||||||
|
|
||||||
|
func parser(_ parser: Foundation.XMLParser, foundExternalEntityDeclarationWithName name: String, publicID: String?, systemID: String?) { }
|
||||||
|
|
||||||
|
func parser(_ parser: Foundation.XMLParser, didStartElement elementName: String, namespaceURI: String?, qualifiedName qName: String?, attributes attributeDict: [String : String]) { }
|
||||||
|
|
||||||
|
func parser(_ parser: Foundation.XMLParser, didEndElement elementName: String, namespaceURI: String?, qualifiedName qName: String?) { }
|
||||||
|
|
||||||
|
func parser(_ parser: Foundation.XMLParser, didStartMappingPrefix prefix: String, toURI namespaceURI: String) { }
|
||||||
|
|
||||||
|
func parser(_ parser: Foundation.XMLParser, didEndMappingPrefix prefix: String) { }
|
||||||
|
|
||||||
|
func parser(_ parser: Foundation.XMLParser, foundCharacters string: String) { }
|
||||||
|
|
||||||
|
func parser(_ parser: Foundation.XMLParser, foundIgnorableWhitespace whitespaceString: String) { }
|
||||||
|
|
||||||
|
func parser(_ parser: Foundation.XMLParser, foundProcessingInstructionWithTarget target: String, data: String?) { }
|
||||||
|
|
||||||
|
func parser(_ parser: Foundation.XMLParser, foundComment comment: String) { }
|
||||||
|
|
||||||
|
func parser(_ parser: Foundation.XMLParser, foundCDATA CDATABlock: Data) { }
|
||||||
|
|
||||||
|
func parser(_ parser: Foundation.XMLParser, resolveExternalEntityName name: String, systemID: String?) -> Data? { return nil }
|
||||||
|
|
||||||
|
func parser(_ parser: Foundation.XMLParser, parseErrorOccurred parseError: NSError) { }
|
||||||
|
|
||||||
|
func parser(_ parser: Foundation.XMLParser, validationErrorOccurred validationError: NSError) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/// The implementation of XMLParserDelegate and where the lazy parsing actually happens.
|
||||||
|
class LazyXMLParser: NSObject, SimpleXmlParser, XMLParserDelegate {
|
||||||
|
required init(_ options: SWXMLHashOptions) {
|
||||||
|
self.options = options
|
||||||
|
super.init()
|
||||||
|
}
|
||||||
|
|
||||||
|
var root = XMLElement(name: rootElementName)
|
||||||
|
var parentStack = Stack<XMLElement>()
|
||||||
|
var elementStack = Stack<String>()
|
||||||
|
|
||||||
|
var data: Data?
|
||||||
|
var ops: [IndexOp] = []
|
||||||
|
let options: SWXMLHashOptions
|
||||||
|
|
||||||
|
func parse(_ data: Data) -> XMLIndexer {
|
||||||
|
self.data = data
|
||||||
|
return XMLIndexer(self)
|
||||||
|
}
|
||||||
|
|
||||||
|
func startParsing(_ ops: [IndexOp]) {
|
||||||
|
// clear any prior runs of parse... expected that this won't be necessary,
|
||||||
|
// but you never know
|
||||||
|
parentStack.removeAll()
|
||||||
|
root = XMLElement(name: rootElementName)
|
||||||
|
parentStack.push(root)
|
||||||
|
|
||||||
|
self.ops = ops
|
||||||
|
let parser = Foundation.XMLParser(data: data!)
|
||||||
|
parser.shouldProcessNamespaces = options.shouldProcessNamespaces
|
||||||
|
parser.delegate = self
|
||||||
|
_ = parser.parse()
|
||||||
|
}
|
||||||
|
|
||||||
|
func parser(_ parser: Foundation.XMLParser,
|
||||||
|
didStartElement elementName: String,
|
||||||
|
namespaceURI: String?,
|
||||||
|
qualifiedName qName: String?,
|
||||||
|
attributes attributeDict: [String: String]) {
|
||||||
|
|
||||||
|
elementStack.push(elementName)
|
||||||
|
|
||||||
|
if !onMatch() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
#if os(Linux)
|
||||||
|
let attributeNSDict = NSDictionary(objects: attributeDict.values.flatMap({ $0 as? AnyObject }), forKeys: attributeDict.keys.map({ NSString(string: $0) as NSObject }))
|
||||||
|
let currentNode = parentStack.top().addElement(elementName, withAttributes: attributeNSDict)
|
||||||
|
#else
|
||||||
|
let currentNode = parentStack.top().addElement(elementName, withAttributes: attributeDict as NSDictionary)
|
||||||
|
#endif
|
||||||
|
parentStack.push(currentNode)
|
||||||
|
}
|
||||||
|
|
||||||
|
func parser(_ parser: Foundation.XMLParser, foundCharacters string: String) {
|
||||||
|
if !onMatch() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
let current = parentStack.top()
|
||||||
|
|
||||||
|
current.addText(string)
|
||||||
|
}
|
||||||
|
|
||||||
|
func parser(_ parser: Foundation.XMLParser,
|
||||||
|
didEndElement elementName: String,
|
||||||
|
namespaceURI: String?,
|
||||||
|
qualifiedName qName: String?) {
|
||||||
|
|
||||||
|
let match = onMatch()
|
||||||
|
|
||||||
|
elementStack.drop()
|
||||||
|
|
||||||
|
if match {
|
||||||
|
parentStack.drop()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func onMatch() -> Bool {
|
||||||
|
// we typically want to compare against the elementStack to see if it matches ops, *but*
|
||||||
|
// if we're on the first element, we'll instead compare the other direction.
|
||||||
|
if elementStack.items.count > ops.count {
|
||||||
|
return elementStack.items.starts(with: ops.map { $0.key })
|
||||||
|
} else {
|
||||||
|
return ops.map { $0.key }.starts(with: elementStack.items)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The implementation of XMLParserDelegate and where the parsing actually happens.
|
||||||
|
class FullXMLParser: NSObject, SimpleXmlParser, XMLParserDelegate {
|
||||||
|
required init(_ options: SWXMLHashOptions) {
|
||||||
|
self.options = options
|
||||||
|
super.init()
|
||||||
|
}
|
||||||
|
|
||||||
|
var root = XMLElement(name: rootElementName)
|
||||||
|
var parentStack = Stack<XMLElement>()
|
||||||
|
let options: SWXMLHashOptions
|
||||||
|
|
||||||
|
func parse(_ data: Data) -> XMLIndexer {
|
||||||
|
// clear any prior runs of parse... expected that this won't be necessary,
|
||||||
|
// but you never know
|
||||||
|
parentStack.removeAll()
|
||||||
|
|
||||||
|
parentStack.push(root)
|
||||||
|
|
||||||
|
let parser = Foundation.XMLParser(data: data)
|
||||||
|
parser.shouldProcessNamespaces = options.shouldProcessNamespaces
|
||||||
|
parser.delegate = self
|
||||||
|
_ = parser.parse()
|
||||||
|
|
||||||
|
return XMLIndexer(root)
|
||||||
|
}
|
||||||
|
|
||||||
|
func parser(_ parser: Foundation.XMLParser,
|
||||||
|
didStartElement elementName: String,
|
||||||
|
namespaceURI: String?,
|
||||||
|
qualifiedName qName: String?,
|
||||||
|
attributes attributeDict: [String: String]) {
|
||||||
|
#if os(Linux)
|
||||||
|
let attributeNSDict = NSDictionary(objects: attributeDict.values.flatMap({ $0 as? AnyObject }), forKeys: attributeDict.keys.map({ NSString(string: $0) as NSObject }))
|
||||||
|
let currentNode = parentStack.top().addElement(elementName, withAttributes: attributeNSDict)
|
||||||
|
#else
|
||||||
|
let currentNode = parentStack.top().addElement(elementName, withAttributes: attributeDict as NSDictionary)
|
||||||
|
#endif
|
||||||
|
parentStack.push(currentNode)
|
||||||
|
}
|
||||||
|
|
||||||
|
func parser(_ parser: Foundation.XMLParser, foundCharacters string: String) {
|
||||||
|
let current = parentStack.top()
|
||||||
|
|
||||||
|
current.addText(string)
|
||||||
|
}
|
||||||
|
|
||||||
|
func parser(_ parser: Foundation.XMLParser,
|
||||||
|
didEndElement elementName: String,
|
||||||
|
namespaceURI: String?,
|
||||||
|
qualifiedName qName: String?) {
|
||||||
|
|
||||||
|
parentStack.drop()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Represents an indexed operation against a lazily parsed `XMLIndexer`
|
||||||
|
public class IndexOp {
|
||||||
|
var index: Int
|
||||||
|
let key: String
|
||||||
|
|
||||||
|
init(_ key: String) {
|
||||||
|
self.key = key
|
||||||
|
self.index = -1
|
||||||
|
}
|
||||||
|
|
||||||
|
func toString() -> String {
|
||||||
|
if index >= 0 {
|
||||||
|
return key + " " + index.description
|
||||||
|
}
|
||||||
|
|
||||||
|
return key
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Represents a collection of `IndexOp` instances. Provides a means of iterating them
|
||||||
|
/// to find a match in a lazily parsed `XMLIndexer` instance.
|
||||||
|
public class IndexOps {
|
||||||
|
var ops: [IndexOp] = []
|
||||||
|
|
||||||
|
let parser: LazyXMLParser
|
||||||
|
|
||||||
|
init(parser: LazyXMLParser) {
|
||||||
|
self.parser = parser
|
||||||
|
}
|
||||||
|
|
||||||
|
func findElements() -> XMLIndexer {
|
||||||
|
parser.startParsing(ops)
|
||||||
|
let indexer = XMLIndexer(parser.root)
|
||||||
|
var childIndex = indexer
|
||||||
|
for op in ops {
|
||||||
|
childIndex = childIndex[op.key]
|
||||||
|
if op.index >= 0 {
|
||||||
|
childIndex = childIndex[op.index]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ops.removeAll(keepingCapacity: false)
|
||||||
|
return childIndex
|
||||||
|
}
|
||||||
|
|
||||||
|
func stringify() -> String {
|
||||||
|
var s = ""
|
||||||
|
for op in ops {
|
||||||
|
s += "[" + op.toString() + "]"
|
||||||
|
}
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Error type that is thrown when an indexing or parsing operation fails.
|
||||||
|
public enum IndexingError: Error {
|
||||||
|
case Attribute(attr: String)
|
||||||
|
case AttributeValue(attr: String, value: String)
|
||||||
|
case Key(key: String)
|
||||||
|
case Index(idx: Int)
|
||||||
|
case Init(instance: AnyObject)
|
||||||
|
case Error
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returned from SWXMLHash, allows easy element lookup into XML data.
|
||||||
|
public enum XMLIndexer: Sequence {
|
||||||
|
case Element(XMLElement)
|
||||||
|
case List([XMLElement])
|
||||||
|
case Stream(IndexOps)
|
||||||
|
case XMLError(IndexingError)
|
||||||
|
|
||||||
|
|
||||||
|
/// The underlying XMLElement at the currently indexed level of XML.
|
||||||
|
public var element: XMLElement? {
|
||||||
|
switch self {
|
||||||
|
case .Element(let elem):
|
||||||
|
return elem
|
||||||
|
case .Stream(let ops):
|
||||||
|
let list = ops.findElements()
|
||||||
|
return list.element
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// All elements at the currently indexed level
|
||||||
|
public var all: [XMLIndexer] {
|
||||||
|
switch self {
|
||||||
|
case .List(let list):
|
||||||
|
var xmlList = [XMLIndexer]()
|
||||||
|
for elem in list {
|
||||||
|
xmlList.append(XMLIndexer(elem))
|
||||||
|
}
|
||||||
|
return xmlList
|
||||||
|
case .Element(let elem):
|
||||||
|
return [XMLIndexer(elem)]
|
||||||
|
case .Stream(let ops):
|
||||||
|
let list = ops.findElements()
|
||||||
|
return list.all
|
||||||
|
default:
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// All child elements from the currently indexed level
|
||||||
|
public var children: [XMLIndexer] {
|
||||||
|
var list = [XMLIndexer]()
|
||||||
|
for elem in all.map({ $0.element! }).flatMap({ $0 }) {
|
||||||
|
for elem in elem.xmlChildren {
|
||||||
|
list.append(XMLIndexer(elem))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Allows for element lookup by matching attribute values.
|
||||||
|
|
||||||
|
- parameters:
|
||||||
|
- attr: should the name of the attribute to match on
|
||||||
|
- value: should be the value of the attribute to match on
|
||||||
|
- throws: an XMLIndexer.XMLError if an element with the specified attribute isn't found
|
||||||
|
- returns: instance of XMLIndexer
|
||||||
|
*/
|
||||||
|
public func withAttr(_ attr: String, _ value: String) throws -> XMLIndexer {
|
||||||
|
switch self {
|
||||||
|
case .Stream(let opStream):
|
||||||
|
let match = opStream.findElements()
|
||||||
|
return try match.withAttr(attr, value)
|
||||||
|
case .List(let list):
|
||||||
|
if let elem = list.filter({$0.attribute(by: attr)?.text == value}).first {
|
||||||
|
return .Element(elem)
|
||||||
|
}
|
||||||
|
throw IndexingError.AttributeValue(attr: attr, value: value)
|
||||||
|
case .Element(let elem):
|
||||||
|
if elem.attribute(by: attr)?.text == value {
|
||||||
|
return .Element(elem)
|
||||||
|
}
|
||||||
|
throw IndexingError.AttributeValue(attr: attr, value: value)
|
||||||
|
default:
|
||||||
|
throw IndexingError.Attribute(attr: attr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Initializes the XMLIndexer
|
||||||
|
|
||||||
|
- parameter _: should be an instance of XMLElement, but supports other values for error handling
|
||||||
|
- throws: an Error if the object passed in isn't an XMLElement or LaxyXMLParser
|
||||||
|
*/
|
||||||
|
public init(_ rawObject: AnyObject) throws {
|
||||||
|
switch rawObject {
|
||||||
|
case let value as XMLElement:
|
||||||
|
self = .Element(value)
|
||||||
|
case let value as LazyXMLParser:
|
||||||
|
self = .Stream(IndexOps(parser: value))
|
||||||
|
default:
|
||||||
|
throw IndexingError.Init(instance: rawObject)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Initializes the XMLIndexer
|
||||||
|
|
||||||
|
- parameter _: an instance of XMLElement
|
||||||
|
*/
|
||||||
|
public init(_ elem: XMLElement) {
|
||||||
|
self = .Element(elem)
|
||||||
|
}
|
||||||
|
|
||||||
|
init(_ stream: LazyXMLParser) {
|
||||||
|
self = .Stream(IndexOps(parser: stream))
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Find an XML element at the current level by element name
|
||||||
|
|
||||||
|
- parameter key: The element name to index by
|
||||||
|
- returns: instance of XMLIndexer to match the element (or elements) found by key
|
||||||
|
- throws: Throws an XMLIndexingError.Key if no element was found
|
||||||
|
*/
|
||||||
|
public func byKey(_ key: String) throws -> XMLIndexer {
|
||||||
|
switch self {
|
||||||
|
case .Stream(let opStream):
|
||||||
|
let op = IndexOp(key)
|
||||||
|
opStream.ops.append(op)
|
||||||
|
return .Stream(opStream)
|
||||||
|
case .Element(let elem):
|
||||||
|
let match = elem.xmlChildren.filter({ $0.name == key })
|
||||||
|
if !match.isEmpty {
|
||||||
|
if match.count == 1 {
|
||||||
|
return .Element(match[0])
|
||||||
|
} else {
|
||||||
|
return .List(match)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fallthrough
|
||||||
|
default:
|
||||||
|
throw IndexingError.Key(key: key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Find an XML element at the current level by element name
|
||||||
|
|
||||||
|
- parameter key: The element name to index by
|
||||||
|
- returns: instance of XMLIndexer to match the element (or elements) found by
|
||||||
|
*/
|
||||||
|
public subscript(key: String) -> XMLIndexer {
|
||||||
|
do {
|
||||||
|
return try self.byKey(key)
|
||||||
|
} catch let error as IndexingError {
|
||||||
|
return .XMLError(error)
|
||||||
|
} catch {
|
||||||
|
return .XMLError(IndexingError.Key(key: key))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Find an XML element by index within a list of XML Elements at the current level
|
||||||
|
|
||||||
|
- parameter index: The 0-based index to index by
|
||||||
|
- throws: XMLIndexer.XMLError if the index isn't found
|
||||||
|
- returns: instance of XMLIndexer to match the element (or elements) found by index
|
||||||
|
*/
|
||||||
|
public func byIndex(_ index: Int) throws -> XMLIndexer {
|
||||||
|
switch self {
|
||||||
|
case .Stream(let opStream):
|
||||||
|
opStream.ops[opStream.ops.count - 1].index = index
|
||||||
|
return .Stream(opStream)
|
||||||
|
case .List(let list):
|
||||||
|
if index <= list.count {
|
||||||
|
return .Element(list[index])
|
||||||
|
}
|
||||||
|
return .XMLError(IndexingError.Index(idx: index))
|
||||||
|
case .Element(let elem):
|
||||||
|
if index == 0 {
|
||||||
|
return .Element(elem)
|
||||||
|
}
|
||||||
|
fallthrough
|
||||||
|
default:
|
||||||
|
return .XMLError(IndexingError.Index(idx: index))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Find an XML element by index
|
||||||
|
|
||||||
|
- parameter index: The 0-based index to index by
|
||||||
|
- returns: instance of XMLIndexer to match the element (or elements) found by index
|
||||||
|
*/
|
||||||
|
public subscript(index: Int) -> XMLIndexer {
|
||||||
|
do {
|
||||||
|
return try byIndex(index)
|
||||||
|
} catch let error as IndexingError {
|
||||||
|
return .XMLError(error)
|
||||||
|
} catch {
|
||||||
|
return .XMLError(IndexingError.Index(idx: index))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
typealias GeneratorType = XMLIndexer
|
||||||
|
|
||||||
|
/**
|
||||||
|
Method to iterate (for-in) over the `all` collection
|
||||||
|
|
||||||
|
- returns: an array of `XMLIndexer` instances
|
||||||
|
*/
|
||||||
|
public func makeIterator() -> IndexingIterator<[XMLIndexer]> {
|
||||||
|
return all.makeIterator()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// XMLIndexer extensions
|
||||||
|
/*
|
||||||
|
extension XMLIndexer: Boolean {
|
||||||
|
/// True if a valid XMLIndexer, false if an error type
|
||||||
|
public var boolValue: Bool {
|
||||||
|
switch self {
|
||||||
|
case .XMLError:
|
||||||
|
return false
|
||||||
|
default:
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
extension XMLIndexer: CustomStringConvertible {
|
||||||
|
/// The XML representation of the XMLIndexer at the current level
|
||||||
|
public var description: String {
|
||||||
|
switch self {
|
||||||
|
case .List(let list):
|
||||||
|
return list.map { $0.description }.joined(separator: "")
|
||||||
|
case .Element(let elem):
|
||||||
|
if elem.name == rootElementName {
|
||||||
|
return elem.children.map { $0.description }.joined(separator: "")
|
||||||
|
}
|
||||||
|
|
||||||
|
return elem.description
|
||||||
|
default:
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension IndexingError: CustomStringConvertible {
|
||||||
|
/// The description for the `IndexingError`.
|
||||||
|
public var description: String {
|
||||||
|
switch self {
|
||||||
|
case .Attribute(let attr):
|
||||||
|
return "XML Attribute Error: Missing attribute [\"\(attr)\"]"
|
||||||
|
case .AttributeValue(let attr, let value):
|
||||||
|
return "XML Attribute Error: Missing attribute [\"\(attr)\"] with value [\"\(value)\"]"
|
||||||
|
case .Key(let key):
|
||||||
|
return "XML Element Error: Incorrect key [\"\(key)\"]"
|
||||||
|
case .Index(let index):
|
||||||
|
return "XML Element Error: Incorrect index [\"\(index)\"]"
|
||||||
|
case .Init(let instance):
|
||||||
|
return "XML Indexer Error: initialization with Object [\"\(instance)\"]"
|
||||||
|
case .Error:
|
||||||
|
return "Unknown Error"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Models content for an XML doc, whether it is text or XML
|
||||||
|
public protocol XMLContent: CustomStringConvertible { }
|
||||||
|
|
||||||
|
/// Models a text element
|
||||||
|
public class TextElement: XMLContent {
|
||||||
|
/// The underlying text value
|
||||||
|
public let text: String
|
||||||
|
init(text: String) {
|
||||||
|
self.text = text
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct XMLAttribute {
|
||||||
|
public let name: String
|
||||||
|
public let text: String
|
||||||
|
init(name: String, text: String) {
|
||||||
|
self.name = name
|
||||||
|
self.text = text
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Models an XML element, including name, text and attributes
|
||||||
|
public class XMLElement: XMLContent {
|
||||||
|
/// The name of the element
|
||||||
|
public let name: String
|
||||||
|
|
||||||
|
/// The attributes of the element
|
||||||
|
@available(*, deprecated, message: "See `allAttributes` instead, which introduces the XMLAttribute type over a simple String type")
|
||||||
|
public var attributes: [String:String] {
|
||||||
|
var attrMap = [String: String]()
|
||||||
|
for (name, attr) in allAttributes {
|
||||||
|
attrMap[name] = attr.text
|
||||||
|
}
|
||||||
|
return attrMap
|
||||||
|
}
|
||||||
|
|
||||||
|
public var allAttributes = [String:XMLAttribute]()
|
||||||
|
|
||||||
|
public func attribute(by name: String) -> XMLAttribute? {
|
||||||
|
return allAttributes[name]
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The inner text of the element, if it exists
|
||||||
|
public var text: String? {
|
||||||
|
return children
|
||||||
|
.map({ $0 as? TextElement })
|
||||||
|
.flatMap({ $0 })
|
||||||
|
.reduce("", { $0 + $1!.text })
|
||||||
|
}
|
||||||
|
|
||||||
|
/// All child elements (text or XML)
|
||||||
|
public var children = [XMLContent]()
|
||||||
|
var count: Int = 0
|
||||||
|
var index: Int
|
||||||
|
|
||||||
|
var xmlChildren: [XMLElement] {
|
||||||
|
return children.map { $0 as? XMLElement }.flatMap { $0 }
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Initialize an XMLElement instance
|
||||||
|
|
||||||
|
- parameters:
|
||||||
|
- name: The name of the element to be initialized
|
||||||
|
- index: The index of the element to be initialized
|
||||||
|
*/
|
||||||
|
init(name: String, index: Int = 0) {
|
||||||
|
self.name = name
|
||||||
|
self.index = index
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Adds a new XMLElement underneath this instance of XMLElement
|
||||||
|
|
||||||
|
- parameters:
|
||||||
|
- name: The name of the new element to be added
|
||||||
|
- withAttributes: The attributes dictionary for the element being added
|
||||||
|
- returns: The XMLElement that has now been added
|
||||||
|
*/
|
||||||
|
func addElement(_ name: String, withAttributes attributes: NSDictionary) -> XMLElement {
|
||||||
|
let element = XMLElement(name: name, index: count)
|
||||||
|
count += 1
|
||||||
|
|
||||||
|
children.append(element)
|
||||||
|
|
||||||
|
for (keyAny, valueAny) in attributes {
|
||||||
|
if let key = keyAny as? String,
|
||||||
|
let value = valueAny as? String {
|
||||||
|
element.allAttributes[key] = XMLAttribute(name: key, text: value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return element
|
||||||
|
}
|
||||||
|
|
||||||
|
func addText(_ text: String) {
|
||||||
|
let elem = TextElement(text: text)
|
||||||
|
|
||||||
|
children.append(elem)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension TextElement: CustomStringConvertible {
|
||||||
|
/// The text value for a `TextElement` instance.
|
||||||
|
public var description: String {
|
||||||
|
return text
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension XMLAttribute: CustomStringConvertible {
|
||||||
|
/// The textual representation of an `XMLAttribute` instance.
|
||||||
|
public var description: String {
|
||||||
|
return "\(name)=\"\(text)\""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension XMLElement: CustomStringConvertible {
|
||||||
|
/// The tag, attributes and content for a `XMLElement` instance (<elem id="foo">content</elem>)
|
||||||
|
public var description: String {
|
||||||
|
var attributesString = allAttributes.map { $0.1.description }.joined(separator: " ")
|
||||||
|
if !attributesString.isEmpty {
|
||||||
|
attributesString = " " + attributesString
|
||||||
|
}
|
||||||
|
|
||||||
|
if !children.isEmpty {
|
||||||
|
var xmlReturn = [String]()
|
||||||
|
xmlReturn.append("<\(name)\(attributesString)>")
|
||||||
|
for child in children {
|
||||||
|
xmlReturn.append(child.description)
|
||||||
|
}
|
||||||
|
xmlReturn.append("</\(name)>")
|
||||||
|
return xmlReturn.joined(separator: "")
|
||||||
|
}
|
||||||
|
|
||||||
|
if text != nil {
|
||||||
|
return "<\(name)\(attributesString)>\(text!)</\(name)>"
|
||||||
|
} else {
|
||||||
|
return "<\(name)\(attributesString)/>"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Workaround for "'XMLElement' is ambiguous for type lookup in this context" error on macOS.
|
||||||
|
//
|
||||||
|
// On macOS, `XMLElement` is defined in Foundation.
|
||||||
|
// So, the code referencing `XMLElement` generates above error.
|
||||||
|
// Following code allow to using `SWXMLhash.XMLElement` in client codes.
|
||||||
|
extension SWXMLHash {
|
||||||
|
public typealias XMLElement = SWXMLHashXMLElement
|
||||||
|
}
|
||||||
|
|
||||||
|
public typealias SWXMLHashXMLElement = XMLElement
|
@ -1,151 +0,0 @@
|
|||||||
// Generated by Apple Swift version 3.0.1 (swiftlang-800.0.58.6 clang-800.0.42.1)
|
|
||||||
#pragma clang diagnostic push
|
|
||||||
|
|
||||||
#if defined(__has_include) && __has_include(<swift/objc-prologue.h>)
|
|
||||||
# include <swift/objc-prologue.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#pragma clang diagnostic ignored "-Wauto-import"
|
|
||||||
#include <objc/NSObject.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
#if !defined(SWIFT_TYPEDEFS)
|
|
||||||
# define SWIFT_TYPEDEFS 1
|
|
||||||
# if defined(__has_include) && __has_include(<uchar.h>)
|
|
||||||
# include <uchar.h>
|
|
||||||
# elif !defined(__cplusplus) || __cplusplus < 201103L
|
|
||||||
typedef uint_least16_t char16_t;
|
|
||||||
typedef uint_least32_t char32_t;
|
|
||||||
# endif
|
|
||||||
typedef float swift_float2 __attribute__((__ext_vector_type__(2)));
|
|
||||||
typedef float swift_float3 __attribute__((__ext_vector_type__(3)));
|
|
||||||
typedef float swift_float4 __attribute__((__ext_vector_type__(4)));
|
|
||||||
typedef double swift_double2 __attribute__((__ext_vector_type__(2)));
|
|
||||||
typedef double swift_double3 __attribute__((__ext_vector_type__(3)));
|
|
||||||
typedef double swift_double4 __attribute__((__ext_vector_type__(4)));
|
|
||||||
typedef int swift_int2 __attribute__((__ext_vector_type__(2)));
|
|
||||||
typedef int swift_int3 __attribute__((__ext_vector_type__(3)));
|
|
||||||
typedef int swift_int4 __attribute__((__ext_vector_type__(4)));
|
|
||||||
typedef unsigned int swift_uint2 __attribute__((__ext_vector_type__(2)));
|
|
||||||
typedef unsigned int swift_uint3 __attribute__((__ext_vector_type__(3)));
|
|
||||||
typedef unsigned int swift_uint4 __attribute__((__ext_vector_type__(4)));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(SWIFT_PASTE)
|
|
||||||
# define SWIFT_PASTE_HELPER(x, y) x##y
|
|
||||||
# define SWIFT_PASTE(x, y) SWIFT_PASTE_HELPER(x, y)
|
|
||||||
#endif
|
|
||||||
#if !defined(SWIFT_METATYPE)
|
|
||||||
# define SWIFT_METATYPE(X) Class
|
|
||||||
#endif
|
|
||||||
#if !defined(SWIFT_CLASS_PROPERTY)
|
|
||||||
# if __has_feature(objc_class_property)
|
|
||||||
# define SWIFT_CLASS_PROPERTY(...) __VA_ARGS__
|
|
||||||
# else
|
|
||||||
# define SWIFT_CLASS_PROPERTY(...)
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__has_attribute) && __has_attribute(objc_runtime_name)
|
|
||||||
# define SWIFT_RUNTIME_NAME(X) __attribute__((objc_runtime_name(X)))
|
|
||||||
#else
|
|
||||||
# define SWIFT_RUNTIME_NAME(X)
|
|
||||||
#endif
|
|
||||||
#if defined(__has_attribute) && __has_attribute(swift_name)
|
|
||||||
# define SWIFT_COMPILE_NAME(X) __attribute__((swift_name(X)))
|
|
||||||
#else
|
|
||||||
# define SWIFT_COMPILE_NAME(X)
|
|
||||||
#endif
|
|
||||||
#if defined(__has_attribute) && __has_attribute(objc_method_family)
|
|
||||||
# define SWIFT_METHOD_FAMILY(X) __attribute__((objc_method_family(X)))
|
|
||||||
#else
|
|
||||||
# define SWIFT_METHOD_FAMILY(X)
|
|
||||||
#endif
|
|
||||||
#if defined(__has_attribute) && __has_attribute(noescape)
|
|
||||||
# define SWIFT_NOESCAPE __attribute__((noescape))
|
|
||||||
#else
|
|
||||||
# define SWIFT_NOESCAPE
|
|
||||||
#endif
|
|
||||||
#if !defined(SWIFT_CLASS_EXTRA)
|
|
||||||
# define SWIFT_CLASS_EXTRA
|
|
||||||
#endif
|
|
||||||
#if !defined(SWIFT_PROTOCOL_EXTRA)
|
|
||||||
# define SWIFT_PROTOCOL_EXTRA
|
|
||||||
#endif
|
|
||||||
#if !defined(SWIFT_ENUM_EXTRA)
|
|
||||||
# define SWIFT_ENUM_EXTRA
|
|
||||||
#endif
|
|
||||||
#if !defined(SWIFT_CLASS)
|
|
||||||
# if defined(__has_attribute) && __has_attribute(objc_subclassing_restricted)
|
|
||||||
# define SWIFT_CLASS(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) __attribute__((objc_subclassing_restricted)) SWIFT_CLASS_EXTRA
|
|
||||||
# define SWIFT_CLASS_NAMED(SWIFT_NAME) __attribute__((objc_subclassing_restricted)) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA
|
|
||||||
# else
|
|
||||||
# define SWIFT_CLASS(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA
|
|
||||||
# define SWIFT_CLASS_NAMED(SWIFT_NAME) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(SWIFT_PROTOCOL)
|
|
||||||
# define SWIFT_PROTOCOL(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) SWIFT_PROTOCOL_EXTRA
|
|
||||||
# define SWIFT_PROTOCOL_NAMED(SWIFT_NAME) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_PROTOCOL_EXTRA
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(SWIFT_EXTENSION)
|
|
||||||
# define SWIFT_EXTENSION(M) SWIFT_PASTE(M##_Swift_, __LINE__)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(OBJC_DESIGNATED_INITIALIZER)
|
|
||||||
# if defined(__has_attribute) && __has_attribute(objc_designated_initializer)
|
|
||||||
# define OBJC_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer))
|
|
||||||
# else
|
|
||||||
# define OBJC_DESIGNATED_INITIALIZER
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
#if !defined(SWIFT_ENUM)
|
|
||||||
# define SWIFT_ENUM(_type, _name) enum _name : _type _name; enum SWIFT_ENUM_EXTRA _name : _type
|
|
||||||
# if defined(__has_feature) && __has_feature(generalized_swift_name)
|
|
||||||
# define SWIFT_ENUM_NAMED(_type, _name, SWIFT_NAME) enum _name : _type _name SWIFT_COMPILE_NAME(SWIFT_NAME); enum SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_ENUM_EXTRA _name : _type
|
|
||||||
# else
|
|
||||||
# define SWIFT_ENUM_NAMED(_type, _name, SWIFT_NAME) SWIFT_ENUM(_type, _name)
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
#if !defined(SWIFT_UNAVAILABLE)
|
|
||||||
# define SWIFT_UNAVAILABLE __attribute__((unavailable))
|
|
||||||
#endif
|
|
||||||
#if defined(__has_feature) && __has_feature(modules)
|
|
||||||
@import ObjectiveC;
|
|
||||||
@import Foundation;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#pragma clang diagnostic ignored "-Wproperty-attribute-mismatch"
|
|
||||||
#pragma clang diagnostic ignored "-Wduplicate-method-arg"
|
|
||||||
@class NSXMLParser;
|
|
||||||
|
|
||||||
/**
|
|
||||||
The implementation of XMLParserDelegate and where the parsing actually happens.
|
|
||||||
*/
|
|
||||||
SWIFT_CLASS("_TtC9SWXMLHash13FullXMLParser")
|
|
||||||
@interface FullXMLParser : NSObject <NSXMLParserDelegate>
|
|
||||||
- (void)parser:(NSXMLParser * _Nonnull)parser didStartElement:(NSString * _Nonnull)elementName namespaceURI:(NSString * _Nullable)namespaceURI qualifiedName:(NSString * _Nullable)qName attributes:(NSDictionary<NSString *, NSString *> * _Nonnull)attributeDict;
|
|
||||||
- (void)parser:(NSXMLParser * _Nonnull)parser foundCharacters:(NSString * _Nonnull)string;
|
|
||||||
- (void)parser:(NSXMLParser * _Nonnull)parser didEndElement:(NSString * _Nonnull)elementName namespaceURI:(NSString * _Nullable)namespaceURI qualifiedName:(NSString * _Nullable)qName;
|
|
||||||
- (nonnull instancetype)init SWIFT_UNAVAILABLE;
|
|
||||||
@end
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
The implementation of XMLParserDelegate and where the lazy parsing actually happens.
|
|
||||||
*/
|
|
||||||
SWIFT_CLASS("_TtC9SWXMLHash13LazyXMLParser")
|
|
||||||
@interface LazyXMLParser : NSObject <NSXMLParserDelegate>
|
|
||||||
@property (nonatomic, copy) NSData * _Nullable data;
|
|
||||||
- (void)parser:(NSXMLParser * _Nonnull)parser didStartElement:(NSString * _Nonnull)elementName namespaceURI:(NSString * _Nullable)namespaceURI qualifiedName:(NSString * _Nullable)qName attributes:(NSDictionary<NSString *, NSString *> * _Nonnull)attributeDict;
|
|
||||||
- (void)parser:(NSXMLParser * _Nonnull)parser foundCharacters:(NSString * _Nonnull)string;
|
|
||||||
- (void)parser:(NSXMLParser * _Nonnull)parser didEndElement:(NSString * _Nonnull)elementName namespaceURI:(NSString * _Nullable)namespaceURI qualifiedName:(NSString * _Nullable)qName;
|
|
||||||
- (BOOL)onMatch;
|
|
||||||
- (nonnull instancetype)init SWIFT_UNAVAILABLE;
|
|
||||||
@end
|
|
||||||
|
|
||||||
#pragma clang diagnostic pop
|
|
@ -1,19 +0,0 @@
|
|||||||
//
|
|
||||||
// SWXMLHash.h
|
|
||||||
// SWXMLHash
|
|
||||||
//
|
|
||||||
// Created by David Mohundro on 7/8/14.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
|
||||||
|
|
||||||
//! Project version number for SWXMLHash.
|
|
||||||
FOUNDATION_EXPORT double SWXMLHashVersionNumber;
|
|
||||||
|
|
||||||
//! Project version string for SWXMLHash.
|
|
||||||
FOUNDATION_EXPORT const unsigned char SWXMLHashVersionString[];
|
|
||||||
|
|
||||||
// In this header, you should import all the public headers of your framework using statements like #import <SWXMLHash/PublicHeader.h>
|
|
||||||
|
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,10 +0,0 @@
|
|||||||
framework module SWXMLHash {
|
|
||||||
umbrella header "SWXMLHash.h"
|
|
||||||
|
|
||||||
export *
|
|
||||||
module * { export * }
|
|
||||||
}
|
|
||||||
|
|
||||||
module SWXMLHash.Swift {
|
|
||||||
header "SWXMLHash-Swift.h"
|
|
||||||
}
|
|
Binary file not shown.
@ -7,6 +7,8 @@
|
|||||||
objects = {
|
objects = {
|
||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
|
572CEFC71E2CED4B008C7C83 /* SWXMLHash+TypeConversion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 572CEFC51E2CED4B008C7C83 /* SWXMLHash+TypeConversion.swift */; };
|
||||||
|
572CEFC81E2CED4B008C7C83 /* SWXMLHash.swift in Sources */ = {isa = PBXBuildFile; fileRef = 572CEFC61E2CED4B008C7C83 /* SWXMLHash.swift */; };
|
||||||
573525971E0BC8FE00EB4AAB /* AnimatableVariable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 573525291E0BC8FE00EB4AAB /* AnimatableVariable.swift */; };
|
573525971E0BC8FE00EB4AAB /* AnimatableVariable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 573525291E0BC8FE00EB4AAB /* AnimatableVariable.swift */; };
|
||||||
573525981E0BC8FE00EB4AAB /* Animation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5735252A1E0BC8FE00EB4AAB /* Animation.swift */; };
|
573525981E0BC8FE00EB4AAB /* Animation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5735252A1E0BC8FE00EB4AAB /* Animation.swift */; };
|
||||||
573525991E0BC8FE00EB4AAB /* AnimationImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5735252B1E0BC8FE00EB4AAB /* AnimationImpl.swift */; };
|
573525991E0BC8FE00EB4AAB /* AnimationImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5735252B1E0BC8FE00EB4AAB /* AnimationImpl.swift */; };
|
||||||
@ -42,7 +44,6 @@
|
|||||||
573525B71E0BC8FE00EB4AAB /* PinchEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 573525501E0BC8FE00EB4AAB /* PinchEvent.swift */; };
|
573525B71E0BC8FE00EB4AAB /* PinchEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 573525501E0BC8FE00EB4AAB /* PinchEvent.swift */; };
|
||||||
573525B81E0BC8FE00EB4AAB /* RotateEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 573525511E0BC8FE00EB4AAB /* RotateEvent.swift */; };
|
573525B81E0BC8FE00EB4AAB /* RotateEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 573525511E0BC8FE00EB4AAB /* RotateEvent.swift */; };
|
||||||
573525B91E0BC8FE00EB4AAB /* TapEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 573525521E0BC8FE00EB4AAB /* TapEvent.swift */; };
|
573525B91E0BC8FE00EB4AAB /* TapEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 573525521E0BC8FE00EB4AAB /* TapEvent.swift */; };
|
||||||
573525BA1E0BC8FE00EB4AAB /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 573525531E0BC8FE00EB4AAB /* Info.plist */; };
|
|
||||||
573525BB1E0BC8FE00EB4AAB /* Align.swift in Sources */ = {isa = PBXBuildFile; fileRef = 573525561E0BC8FE00EB4AAB /* Align.swift */; };
|
573525BB1E0BC8FE00EB4AAB /* Align.swift in Sources */ = {isa = PBXBuildFile; fileRef = 573525561E0BC8FE00EB4AAB /* Align.swift */; };
|
||||||
573525BC1E0BC8FE00EB4AAB /* AspectRatio.swift in Sources */ = {isa = PBXBuildFile; fileRef = 573525571E0BC8FE00EB4AAB /* AspectRatio.swift */; };
|
573525BC1E0BC8FE00EB4AAB /* AspectRatio.swift in Sources */ = {isa = PBXBuildFile; fileRef = 573525571E0BC8FE00EB4AAB /* AspectRatio.swift */; };
|
||||||
573525BD1E0BC8FE00EB4AAB /* Baseline.swift in Sources */ = {isa = PBXBuildFile; fileRef = 573525581E0BC8FE00EB4AAB /* Baseline.swift */; };
|
573525BD1E0BC8FE00EB4AAB /* Baseline.swift in Sources */ = {isa = PBXBuildFile; fileRef = 573525581E0BC8FE00EB4AAB /* Baseline.swift */; };
|
||||||
@ -101,8 +102,6 @@
|
|||||||
573525F21E0BC8FF00EB4AAB /* MacawView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 573525941E0BC8FE00EB4AAB /* MacawView.swift */; };
|
573525F21E0BC8FF00EB4AAB /* MacawView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 573525941E0BC8FE00EB4AAB /* MacawView.swift */; };
|
||||||
573525F31E0BC8FF00EB4AAB /* NodesMap.swift in Sources */ = {isa = PBXBuildFile; fileRef = 573525951E0BC8FE00EB4AAB /* NodesMap.swift */; };
|
573525F31E0BC8FF00EB4AAB /* NodesMap.swift in Sources */ = {isa = PBXBuildFile; fileRef = 573525951E0BC8FE00EB4AAB /* NodesMap.swift */; };
|
||||||
573525F41E0BC8FF00EB4AAB /* ShapeLayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 573525961E0BC8FE00EB4AAB /* ShapeLayer.swift */; };
|
573525F41E0BC8FF00EB4AAB /* ShapeLayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 573525961E0BC8FE00EB4AAB /* ShapeLayer.swift */; };
|
||||||
57CAB11C1D78177900FD8E47 /* SWXMLHash.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 57CAB11B1D78177900FD8E47 /* SWXMLHash.framework */; };
|
|
||||||
57CAB11D1D78178000FD8E47 /* SWXMLHash.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 57CAB11B1D78177900FD8E47 /* SWXMLHash.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
|
||||||
57CAB1231D782DFC00FD8E47 /* TestUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 57CAB1221D782DFC00FD8E47 /* TestUtils.swift */; };
|
57CAB1231D782DFC00FD8E47 /* TestUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 57CAB1221D782DFC00FD8E47 /* TestUtils.swift */; };
|
||||||
57CAB12E1D7832E000FD8E47 /* circle.svg in Resources */ = {isa = PBXBuildFile; fileRef = 57CAB1251D7832E000FD8E47 /* circle.svg */; };
|
57CAB12E1D7832E000FD8E47 /* circle.svg in Resources */ = {isa = PBXBuildFile; fileRef = 57CAB1251D7832E000FD8E47 /* circle.svg */; };
|
||||||
57CAB12F1D7832E000FD8E47 /* ellipse.svg in Resources */ = {isa = PBXBuildFile; fileRef = 57CAB1261D7832E000FD8E47 /* ellipse.svg */; };
|
57CAB12F1D7832E000FD8E47 /* ellipse.svg in Resources */ = {isa = PBXBuildFile; fileRef = 57CAB1261D7832E000FD8E47 /* ellipse.svg */; };
|
||||||
@ -134,13 +133,14 @@
|
|||||||
dstPath = "";
|
dstPath = "";
|
||||||
dstSubfolderSpec = 10;
|
dstSubfolderSpec = 10;
|
||||||
files = (
|
files = (
|
||||||
57CAB11D1D78178000FD8E47 /* SWXMLHash.framework in CopyFiles */,
|
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
/* End PBXCopyFilesBuildPhase section */
|
/* End PBXCopyFilesBuildPhase section */
|
||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
|
572CEFC51E2CED4B008C7C83 /* SWXMLHash+TypeConversion.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "SWXMLHash+TypeConversion.swift"; sourceTree = "<group>"; };
|
||||||
|
572CEFC61E2CED4B008C7C83 /* SWXMLHash.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SWXMLHash.swift; sourceTree = "<group>"; };
|
||||||
573525291E0BC8FE00EB4AAB /* AnimatableVariable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AnimatableVariable.swift; sourceTree = "<group>"; };
|
573525291E0BC8FE00EB4AAB /* AnimatableVariable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AnimatableVariable.swift; sourceTree = "<group>"; };
|
||||||
5735252A1E0BC8FE00EB4AAB /* Animation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Animation.swift; sourceTree = "<group>"; };
|
5735252A1E0BC8FE00EB4AAB /* Animation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Animation.swift; sourceTree = "<group>"; };
|
||||||
5735252B1E0BC8FE00EB4AAB /* AnimationImpl.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AnimationImpl.swift; sourceTree = "<group>"; };
|
5735252B1E0BC8FE00EB4AAB /* AnimationImpl.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AnimationImpl.swift; sourceTree = "<group>"; };
|
||||||
@ -235,7 +235,6 @@
|
|||||||
573525941E0BC8FE00EB4AAB /* MacawView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MacawView.swift; sourceTree = "<group>"; };
|
573525941E0BC8FE00EB4AAB /* MacawView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MacawView.swift; sourceTree = "<group>"; };
|
||||||
573525951E0BC8FE00EB4AAB /* NodesMap.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NodesMap.swift; sourceTree = "<group>"; };
|
573525951E0BC8FE00EB4AAB /* NodesMap.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NodesMap.swift; sourceTree = "<group>"; };
|
||||||
573525961E0BC8FE00EB4AAB /* ShapeLayer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ShapeLayer.swift; sourceTree = "<group>"; };
|
573525961E0BC8FE00EB4AAB /* ShapeLayer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ShapeLayer.swift; sourceTree = "<group>"; };
|
||||||
57CAB11B1D78177900FD8E47 /* SWXMLHash.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SWXMLHash.framework; path = iOS/SWXMLHash.framework; sourceTree = "<group>"; };
|
|
||||||
57CAB1221D782DFC00FD8E47 /* TestUtils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestUtils.swift; sourceTree = "<group>"; };
|
57CAB1221D782DFC00FD8E47 /* TestUtils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestUtils.swift; sourceTree = "<group>"; };
|
||||||
57CAB1251D7832E000FD8E47 /* circle.svg */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = circle.svg; sourceTree = "<group>"; };
|
57CAB1251D7832E000FD8E47 /* circle.svg */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = circle.svg; sourceTree = "<group>"; };
|
||||||
57CAB1261D7832E000FD8E47 /* ellipse.svg */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = ellipse.svg; sourceTree = "<group>"; };
|
57CAB1261D7832E000FD8E47 /* ellipse.svg */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = ellipse.svg; sourceTree = "<group>"; };
|
||||||
@ -257,7 +256,6 @@
|
|||||||
isa = PBXFrameworksBuildPhase;
|
isa = PBXFrameworksBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
57CAB11C1D78177900FD8E47 /* SWXMLHash.framework in Frameworks */,
|
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
@ -272,6 +270,23 @@
|
|||||||
/* End PBXFrameworksBuildPhase section */
|
/* End PBXFrameworksBuildPhase section */
|
||||||
|
|
||||||
/* Begin PBXGroup section */
|
/* Begin PBXGroup section */
|
||||||
|
572CEFC31E2CED4B008C7C83 /* Dependencies */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
572CEFC41E2CED4B008C7C83 /* SWXMLHash */,
|
||||||
|
);
|
||||||
|
path = Dependencies;
|
||||||
|
sourceTree = SOURCE_ROOT;
|
||||||
|
};
|
||||||
|
572CEFC41E2CED4B008C7C83 /* SWXMLHash */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
572CEFC51E2CED4B008C7C83 /* SWXMLHash+TypeConversion.swift */,
|
||||||
|
572CEFC61E2CED4B008C7C83 /* SWXMLHash.swift */,
|
||||||
|
);
|
||||||
|
path = SWXMLHash;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
573525271E0BC8FE00EB4AAB /* Source */ = {
|
573525271E0BC8FE00EB4AAB /* Source */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
@ -525,22 +540,6 @@
|
|||||||
path = svg;
|
path = svg;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
57D2020D1D78044A00A90D4F /* Dependencies */ = {
|
|
||||||
isa = PBXGroup;
|
|
||||||
children = (
|
|
||||||
57D202131D78044A00A90D4F /* SWXMLHash */,
|
|
||||||
);
|
|
||||||
path = Dependencies;
|
|
||||||
sourceTree = SOURCE_ROOT;
|
|
||||||
};
|
|
||||||
57D202131D78044A00A90D4F /* SWXMLHash */ = {
|
|
||||||
isa = PBXGroup;
|
|
||||||
children = (
|
|
||||||
57CAB11B1D78177900FD8E47 /* SWXMLHash.framework */,
|
|
||||||
);
|
|
||||||
path = SWXMLHash;
|
|
||||||
sourceTree = "<group>";
|
|
||||||
};
|
|
||||||
57FCD2621D76EA4600CC0FB6 = {
|
57FCD2621D76EA4600CC0FB6 = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
@ -562,8 +561,8 @@
|
|||||||
57FCD26E1D76EA4600CC0FB6 /* Macaw */ = {
|
57FCD26E1D76EA4600CC0FB6 /* Macaw */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
572CEFC31E2CED4B008C7C83 /* Dependencies */,
|
||||||
573525271E0BC8FE00EB4AAB /* Source */,
|
573525271E0BC8FE00EB4AAB /* Source */,
|
||||||
57D2020D1D78044A00A90D4F /* Dependencies */,
|
|
||||||
);
|
);
|
||||||
path = Macaw;
|
path = Macaw;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -601,7 +600,6 @@
|
|||||||
57FCD2691D76EA4600CC0FB6 /* Headers */,
|
57FCD2691D76EA4600CC0FB6 /* Headers */,
|
||||||
57FCD26A1D76EA4600CC0FB6 /* Resources */,
|
57FCD26A1D76EA4600CC0FB6 /* Resources */,
|
||||||
57D202181D78047000A90D4F /* CopyFiles */,
|
57D202181D78047000A90D4F /* CopyFiles */,
|
||||||
57C13F371E2CC9A70052B419 /* ShellScript */,
|
|
||||||
);
|
);
|
||||||
buildRules = (
|
buildRules = (
|
||||||
);
|
);
|
||||||
@ -637,7 +635,7 @@
|
|||||||
isa = PBXProject;
|
isa = PBXProject;
|
||||||
attributes = {
|
attributes = {
|
||||||
LastSwiftUpdateCheck = 0730;
|
LastSwiftUpdateCheck = 0730;
|
||||||
LastUpgradeCheck = 0800;
|
LastUpgradeCheck = 0820;
|
||||||
ORGANIZATIONNAME = Exyte;
|
ORGANIZATIONNAME = Exyte;
|
||||||
TargetAttributes = {
|
TargetAttributes = {
|
||||||
57FCD26B1D76EA4600CC0FB6 = {
|
57FCD26B1D76EA4600CC0FB6 = {
|
||||||
@ -673,7 +671,6 @@
|
|||||||
isa = PBXResourcesBuildPhase;
|
isa = PBXResourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
573525BA1E0BC8FE00EB4AAB /* Info.plist in Resources */,
|
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
@ -695,23 +692,6 @@
|
|||||||
};
|
};
|
||||||
/* End PBXResourcesBuildPhase section */
|
/* End PBXResourcesBuildPhase section */
|
||||||
|
|
||||||
/* Begin PBXShellScriptBuildPhase section */
|
|
||||||
57C13F371E2CC9A70052B419 /* ShellScript */ = {
|
|
||||||
isa = PBXShellScriptBuildPhase;
|
|
||||||
buildActionMask = 2147483647;
|
|
||||||
files = (
|
|
||||||
);
|
|
||||||
inputPaths = (
|
|
||||||
"$(SRCROOT)/Dependencies/SWXMLHash/iOS/SWXMLHash.framework",
|
|
||||||
);
|
|
||||||
outputPaths = (
|
|
||||||
);
|
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
|
||||||
shellPath = /bin/sh;
|
|
||||||
shellScript = "/usr/local/bin/carthage copy-frameworks";
|
|
||||||
};
|
|
||||||
/* End PBXShellScriptBuildPhase section */
|
|
||||||
|
|
||||||
/* Begin PBXSourcesBuildPhase section */
|
/* Begin PBXSourcesBuildPhase section */
|
||||||
57FCD2671D76EA4600CC0FB6 /* Sources */ = {
|
57FCD2671D76EA4600CC0FB6 /* Sources */ = {
|
||||||
isa = PBXSourcesBuildPhase;
|
isa = PBXSourcesBuildPhase;
|
||||||
@ -795,6 +775,7 @@
|
|||||||
573525AA1E0BC8FE00EB4AAB /* OpacityGenerator.swift in Sources */,
|
573525AA1E0BC8FE00EB4AAB /* OpacityGenerator.swift in Sources */,
|
||||||
573525A11E0BC8FE00EB4AAB /* Interpolable.swift in Sources */,
|
573525A11E0BC8FE00EB4AAB /* Interpolable.swift in Sources */,
|
||||||
573525F31E0BC8FF00EB4AAB /* NodesMap.swift in Sources */,
|
573525F31E0BC8FF00EB4AAB /* NodesMap.swift in Sources */,
|
||||||
|
572CEFC81E2CED4B008C7C83 /* SWXMLHash.swift in Sources */,
|
||||||
573525F21E0BC8FF00EB4AAB /* MacawView.swift in Sources */,
|
573525F21E0BC8FF00EB4AAB /* MacawView.swift in Sources */,
|
||||||
573525C11E0BC8FE00EB4AAB /* Effect.swift in Sources */,
|
573525C11E0BC8FE00EB4AAB /* Effect.swift in Sources */,
|
||||||
573525E71E0BC8FF00EB4AAB /* RenderContext.swift in Sources */,
|
573525E71E0BC8FF00EB4AAB /* RenderContext.swift in Sources */,
|
||||||
@ -802,6 +783,7 @@
|
|||||||
573525C91E0BC8FE00EB4AAB /* RadialGradient.swift in Sources */,
|
573525C91E0BC8FE00EB4AAB /* RadialGradient.swift in Sources */,
|
||||||
573525D81E0BC8FF00EB4AAB /* Point.swift in Sources */,
|
573525D81E0BC8FF00EB4AAB /* Point.swift in Sources */,
|
||||||
573525CD1E0BC8FE00EB4AAB /* Circle.swift in Sources */,
|
573525CD1E0BC8FE00EB4AAB /* Circle.swift in Sources */,
|
||||||
|
572CEFC71E2CED4B008C7C83 /* SWXMLHash+TypeConversion.swift in Sources */,
|
||||||
573525B11E0BC8FE00EB4AAB /* TransformAnimation.swift in Sources */,
|
573525B11E0BC8FE00EB4AAB /* TransformAnimation.swift in Sources */,
|
||||||
573525BB1E0BC8FE00EB4AAB /* Align.swift in Sources */,
|
573525BB1E0BC8FE00EB4AAB /* Align.swift in Sources */,
|
||||||
573525B91E0BC8FE00EB4AAB /* TapEvent.swift in Sources */,
|
573525B91E0BC8FE00EB4AAB /* TapEvent.swift in Sources */,
|
||||||
@ -939,15 +921,11 @@
|
|||||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||||
DYLIB_CURRENT_VERSION = 1;
|
DYLIB_CURRENT_VERSION = 1;
|
||||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||||
FRAMEWORK_SEARCH_PATHS = (
|
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
|
||||||
"$(inherited)",
|
|
||||||
"$(PROJECT_DIR)/Dependencies/RxSwift/iOS",
|
|
||||||
"$(PROJECT_DIR)/Dependencies/SWXMLHash",
|
|
||||||
"$(PROJECT_DIR)/Dependencies/SWXMLHash/iOS",
|
|
||||||
);
|
|
||||||
INFOPLIST_FILE = "$(SRCROOT)/Source/Info.plist";
|
INFOPLIST_FILE = "$(SRCROOT)/Source/Info.plist";
|
||||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||||
|
OTHER_SWIFT_FLAGS = "-D CARTHAGE";
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.exyte.Macaw;
|
PRODUCT_BUNDLE_IDENTIFIER = com.exyte.Macaw;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SKIP_INSTALL = YES;
|
SKIP_INSTALL = YES;
|
||||||
@ -963,15 +941,11 @@
|
|||||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||||
DYLIB_CURRENT_VERSION = 1;
|
DYLIB_CURRENT_VERSION = 1;
|
||||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||||
FRAMEWORK_SEARCH_PATHS = (
|
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
|
||||||
"$(inherited)",
|
|
||||||
"$(PROJECT_DIR)/Dependencies/RxSwift/iOS",
|
|
||||||
"$(PROJECT_DIR)/Dependencies/SWXMLHash",
|
|
||||||
"$(PROJECT_DIR)/Dependencies/SWXMLHash/iOS",
|
|
||||||
);
|
|
||||||
INFOPLIST_FILE = "$(SRCROOT)/Source/Info.plist";
|
INFOPLIST_FILE = "$(SRCROOT)/Source/Info.plist";
|
||||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||||
|
OTHER_SWIFT_FLAGS = "-D CARTHAGE";
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.exyte.Macaw;
|
PRODUCT_BUNDLE_IDENTIFIER = com.exyte.Macaw;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SKIP_INSTALL = YES;
|
SKIP_INSTALL = YES;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<Scheme
|
<Scheme
|
||||||
LastUpgradeVersion = "0800"
|
LastUpgradeVersion = "0820"
|
||||||
version = "1.3">
|
version = "1.3">
|
||||||
<BuildAction
|
<BuildAction
|
||||||
parallelizeBuildables = "YES"
|
parallelizeBuildables = "YES"
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import SWXMLHash
|
|
||||||
import CoreGraphics
|
import CoreGraphics
|
||||||
|
|
||||||
|
#if !CARTHAGE
|
||||||
|
import SWXMLHash
|
||||||
|
#endif
|
||||||
|
|
||||||
///
|
///
|
||||||
/// This class used to parse SVG file and build corresponding Macaw scene
|
/// This class used to parse SVG file and build corresponding Macaw scene
|
||||||
///
|
///
|
||||||
|
Loading…
Reference in New Issue
Block a user