Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.0] Lower case enums and better Swift 4 compatibility #134

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 39 additions & 39 deletions Source/SWXMLHash+TypeConversion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ public extension XMLIndexer {
*/
func value<T: XMLAttributeDeserializable>(ofAttribute attr: String) throws -> T {
switch self {
case .Element(let element):
case .element(let element):
return try element.value(ofAttribute: attr)
case .Stream(let opStream):
case .stream(let opStream):
return try opStream.findElements().value(ofAttribute: attr)
default:
throw XMLDeserializationError.NodeIsInvalid(node: self)
Expand All @@ -116,9 +116,9 @@ public extension XMLIndexer {
*/
func value<T: XMLAttributeDeserializable>(ofAttribute attr: String) -> T? {
switch self {
case .Element(let element):
case .element(let element):
return element.value(ofAttribute: attr)
case .Stream(let opStream):
case .stream(let opStream):
return opStream.findElements().value(ofAttribute: attr)
default:
return nil
Expand All @@ -135,11 +135,11 @@ public extension XMLIndexer {
*/
func value<T: XMLAttributeDeserializable>(ofAttribute attr: String) throws -> [T] {
switch self {
case .List(let elements):
case .list(let elements):
return try elements.map { try $0.value(ofAttribute: attr) }
case .Element(let element):
case .element(let element):
return try [element].map { try $0.value(ofAttribute: attr) }
case .Stream(let opStream):
case .stream(let opStream):
return try opStream.findElements().value(ofAttribute: attr)
default:
throw XMLDeserializationError.NodeIsInvalid(node: self)
Expand All @@ -156,11 +156,11 @@ public extension XMLIndexer {
*/
func value<T: XMLAttributeDeserializable>(ofAttribute attr: String) throws -> [T]? {
switch self {
case .List(let elements):
case .list(let elements):
return try elements.map { try $0.value(ofAttribute: attr) }
case .Element(let element):
case .element(let element):
return try [element].map { try $0.value(ofAttribute: attr) }
case .Stream(let opStream):
case .stream(let opStream):
return try opStream.findElements().value(ofAttribute: attr)
default:
return nil
Expand All @@ -177,11 +177,11 @@ public extension XMLIndexer {
*/
func value<T: XMLAttributeDeserializable>(ofAttribute attr: String) throws -> [T?] {
switch self {
case .List(let elements):
case .list(let elements):
return elements.map { $0.value(ofAttribute: attr) }
case .Element(let element):
case .element(let element):
return [element].map { $0.value(ofAttribute: attr) }
case .Stream(let opStream):
case .stream(let opStream):
return try opStream.findElements().value(ofAttribute: attr)
default:
throw XMLDeserializationError.NodeIsInvalid(node: self)
Expand All @@ -198,9 +198,9 @@ public extension XMLIndexer {
*/
func value<T: XMLElementDeserializable>() throws -> T {
switch self {
case .Element(let element):
case .element(let element):
return try T.deserialize(element)
case .Stream(let opStream):
case .stream(let opStream):
return try opStream.findElements().value()
default:
throw XMLDeserializationError.NodeIsInvalid(node: self)
Expand All @@ -215,9 +215,9 @@ public extension XMLIndexer {
*/
func value<T: XMLElementDeserializable>() throws -> T? {
switch self {
case .Element(let element):
case .element(let element):
return try T.deserialize(element)
case .Stream(let opStream):
case .stream(let opStream):
return try opStream.findElements().value()
default:
return nil
Expand All @@ -232,11 +232,11 @@ public extension XMLIndexer {
*/
func value<T: XMLElementDeserializable>() throws -> [T] {
switch self {
case .List(let elements):
case .list(let elements):
return try elements.map { try T.deserialize($0) }
case .Element(let element):
case .element(let element):
return try [element].map { try T.deserialize($0) }
case .Stream(let opStream):
case .stream(let opStream):
return try opStream.findElements().value()
default:
return []
Expand All @@ -251,11 +251,11 @@ public extension XMLIndexer {
*/
func value<T: XMLElementDeserializable>() throws -> [T]? {
switch self {
case .List(let elements):
case .list(let elements):
return try elements.map { try T.deserialize($0) }
case .Element(let element):
case .element(let element):
return try [element].map { try T.deserialize($0) }
case .Stream(let opStream):
case .stream(let opStream):
return try opStream.findElements().value()
default:
return nil
Expand All @@ -270,11 +270,11 @@ public extension XMLIndexer {
*/
func value<T: XMLElementDeserializable>() throws -> [T?] {
switch self {
case .List(let elements):
case .list(let elements):
return try elements.map { try T.deserialize($0) }
case .Element(let element):
case .element(let element):
return try [element].map { try T.deserialize($0) }
case .Stream(let opStream):
case .stream(let opStream):
return try opStream.findElements().value()
default:
return []
Expand All @@ -291,9 +291,9 @@ public extension XMLIndexer {
*/
func value<T: XMLIndexerDeserializable>() throws -> T {
switch self {
case .Element:
case .element:
return try T.deserialize(self)
case .Stream(let opStream):
case .stream(let opStream):
return try opStream.findElements().value()
default:
throw XMLDeserializationError.NodeIsInvalid(node: self)
Expand All @@ -308,9 +308,9 @@ public extension XMLIndexer {
*/
func value<T: XMLIndexerDeserializable>() throws -> T? {
switch self {
case .Element:
case .element:
return try T.deserialize(self)
case .Stream(let opStream):
case .stream(let opStream):
return try opStream.findElements().value()
default:
return nil
Expand All @@ -325,11 +325,11 @@ public extension XMLIndexer {
*/
func value<T>() throws -> [T] where T: XMLIndexerDeserializable {
switch self {
case .List(let elements):
case .list(let elements):
return try elements.map { try T.deserialize( XMLIndexer($0) ) }
case .Element(let element):
case .element(let element):
return try [element].map { try T.deserialize( XMLIndexer($0) ) }
case .Stream(let opStream):
case .stream(let opStream):
return try opStream.findElements().value()
default:
throw XMLDeserializationError.NodeIsInvalid(node: self)
Expand All @@ -344,11 +344,11 @@ public extension XMLIndexer {
*/
func value<T: XMLIndexerDeserializable>() throws -> [T]? {
switch self {
case .List(let elements):
case .list(let elements):
return try elements.map { try T.deserialize( XMLIndexer($0) ) }
case .Element(let element):
case .element(let element):
return try [element].map { try T.deserialize( XMLIndexer($0) ) }
case .Stream(let opStream):
case .stream(let opStream):
return try opStream.findElements().value()
default:
return nil
Expand All @@ -363,11 +363,11 @@ public extension XMLIndexer {
*/
func value<T: XMLIndexerDeserializable>() throws -> [T?] {
switch self {
case .List(let elements):
case .list(let elements):
return try elements.map { try T.deserialize( XMLIndexer($0) ) }
case .Element(let element):
case .element(let element):
return try [element].map { try T.deserialize( XMLIndexer($0) ) }
case .Stream(let opStream):
case .stream(let opStream):
return try opStream.findElements().value()
default:
throw XMLDeserializationError.NodeIsInvalid(node: self)
Expand Down
Loading