Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e9543c0

Browse files
committedMay 4, 2022
refactor: rename deserialization protocols
1 parent 62774b3 commit e9543c0

File tree

13 files changed

+52
-52
lines changed

13 files changed

+52
-52
lines changed
 

‎README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,20 +325,20 @@ Given:
325325
```xml
326326
<root>
327327
<catalog>
328-
<book id=\"bk101\">
328+
<book id="bk101">
329329
<author>Gambardella, Matthew</author>
330330
<title>XML Developer's Guide</title>
331331
<genre>Computer</genre><price>44.95</price>
332332
<publish_date>2000-10-01</publish_date>
333333
</book>
334-
<book id=\"bk102\">
334+
<book id="bk102">
335335
<author>Ralls, Kim</author>
336336
<title>Midnight Rain</title>
337337
<genre>Fantasy</genre>
338338
<price>5.95</price>
339339
<publish_date>2000-12-16</publish_date>
340340
</book>
341-
<book id=\"bk103\">
341+
<book id="bk103">
342342
<author>Corets, Eva</author>
343343
<title>Maeve Ascendant</title>
344344
<genre>Fantasy</genre>
@@ -402,7 +402,7 @@ With the following implementation for `Date` element and attribute
402402
deserialization:
403403

404404
```swift
405-
extension Date: XMLElementDeserializable, XMLAttributeDeserializable {
405+
extension Date: XMLDeserialization {
406406
public static func deserialize(_ element: XMLElement) throws -> Date {
407407
let date = stringToDate(element.text)
408408

‎SWXMLHash.xcodeproj/project.pbxproj

Lines changed: 30 additions & 30 deletions
Large diffs are not rendered by default.

‎SWXMLHashPlayground.playground/Pages/Introduction.xcplaygroundpage/Contents.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ let booksXML = """
8383
</root>
8484
"""
8585

86-
struct Book: XMLIndexerDeserializable {
86+
struct Book: XMLObjectDeserialization {
8787
let title: String
8888
let price: Double
8989
let year: Int

‎Source/Deserialization/XMLIndexer+XMLIndexerDeserializable.swift renamed to ‎Source/Deserialization/XMLIndexer+XMLDeserialization.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// XMLIndexer.XMLIndexerDeserializable.swift
2+
// XMLIndexer+XMLObjectDeserialization.swift
33
// SWXMLHash
44
//
55
// Copyright (c) 2016 Maciek Grzybowskio
@@ -274,7 +274,7 @@ public extension XMLIndexer {
274274
- returns: the deserialized `T` value
275275
- throws: an XMLDeserializationError is there is a problem with deserialization
276276
*/
277-
func value<T: XMLIndexerDeserializable>() throws -> T {
277+
func value<T: XMLObjectDeserialization>() throws -> T {
278278
switch self {
279279
case .element:
280280
let deserialized = try T.deserialize(self)
@@ -295,7 +295,7 @@ public extension XMLIndexer {
295295
- returns: the deserialized `T?` value
296296
- throws: an XMLDeserializationError is there is a problem with deserialization
297297
*/
298-
func value<T: XMLIndexerDeserializable>() throws -> T? {
298+
func value<T: XMLObjectDeserialization>() throws -> T? {
299299
switch self {
300300
case .element:
301301
let deserialized = try T.deserialize(self)
@@ -314,7 +314,7 @@ public extension XMLIndexer {
314314
- returns: the deserialized `[T]` value
315315
- throws: an XMLDeserializationError is there is a problem with deserialization
316316
*/
317-
func value<T>() throws -> [T] where T: XMLIndexerDeserializable {
317+
func value<T>() throws -> [T] where T: XMLObjectDeserialization {
318318
switch self {
319319
case .list(let elements):
320320
return try elements.map {
@@ -343,7 +343,7 @@ public extension XMLIndexer {
343343
- returns: the deserialized `[T]?` value
344344
- throws: an XMLDeserializationError is there is a problem with deserialization
345345
*/
346-
func value<T: XMLIndexerDeserializable>() throws -> [T]? {
346+
func value<T: XMLObjectDeserialization>() throws -> [T]? {
347347
switch self {
348348
case .list(let elements):
349349
return try elements.map {
@@ -370,7 +370,7 @@ public extension XMLIndexer {
370370
- returns: the deserialized `[T?]` value
371371
- throws: an XMLDeserializationError is there is a problem with deserialization
372372
*/
373-
func value<T: XMLIndexerDeserializable>() throws -> [T?] {
373+
func value<T: XMLObjectDeserialization>() throws -> [T?] {
374374
switch self {
375375
case .list(let elements):
376376
return try elements.map {

‎Source/Deserialization/XMLIndexerDeserializable.swift renamed to ‎Source/Deserialization/XMLObjectDeserialization.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@
2626
import Foundation
2727

2828
/// Provides XMLIndexer deserialization / type transformation support
29-
public protocol XMLIndexerDeserializable {
29+
public protocol XMLObjectDeserialization {
3030
/// Method for deserializing elements from XMLIndexer
3131
static func deserialize(_ element: XMLIndexer) throws -> Self
3232
/// Method for validating elements post deserialization
3333
func validate() throws
3434
}
3535

3636
/// Provides XMLIndexer deserialization / type transformation support
37-
public extension XMLIndexerDeserializable {
37+
public extension XMLObjectDeserialization {
3838
/**
3939
A default implementation that will throw an error if it is called
4040

‎Source/Deserialization/XMLDeserialization.swift renamed to ‎Source/Deserialization/XMLValueDeserialization.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import Foundation
2727

2828
/// This protocol implements both XMLAttributeDeserializable and XMLElementDeserializable meaning
2929
/// that it can be used to easily provide custom deserialization for your types.
30-
public protocol XMLDeserialization: XMLAttributeDeserializable, XMLElementDeserializable {
30+
public protocol XMLValueDeserialization: XMLAttributeDeserializable, XMLElementDeserializable {
3131
/// Method for deserializing elements from XMLElement
3232
static func deserialize(_ element: XMLElement) throws -> Self
3333

@@ -39,7 +39,7 @@ public protocol XMLDeserialization: XMLAttributeDeserializable, XMLElementDeseri
3939
}
4040

4141
/// Provides XMLAttribute deserialization / type transformation support
42-
public extension XMLDeserialization {
42+
public extension XMLValueDeserialization {
4343
/**
4444
A default implementation that will throw an error if it is called
4545

‎Source/DeserializationTypes/Bool+XMLDeserialization.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
import Foundation
2727

28-
extension Bool: XMLDeserialization, XMLElementDeserializable {
28+
extension Bool: XMLValueDeserialization {
2929
// swiftlint:disable line_length
3030
/**
3131
Attempts to deserialize XML element content to a Bool. This uses NSString's 'boolValue'

‎Source/DeserializationTypes/Double+XMLDeserialization.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
import Foundation
2727

28-
extension Double: XMLDeserialization, XMLElementDeserializable {
28+
extension Double: XMLValueDeserialization {
2929
/**
3030
Attempts to deserialize XML element content to a Double
3131

‎Source/DeserializationTypes/Float+XMLDeserialization.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
import Foundation
2727

28-
extension Float: XMLDeserialization {
28+
extension Float: XMLValueDeserialization {
2929
/**
3030
Attempts to deserialize XML element content to a Float
3131

‎Source/DeserializationTypes/Int+XMLDeserialization.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
import Foundation
2727

28-
extension Int: XMLDeserialization {
28+
extension Int: XMLValueDeserialization {
2929
/**
3030
Attempts to deserialize XML element content to a Int
3131

‎Source/DeserializationTypes/String+XMLDeserialization.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
import Foundation
2727

28-
extension String: XMLDeserialization {
28+
extension String: XMLValueDeserialization {
2929
/**
3030
Attempts to deserialize XML element content to a String
3131

‎Tests/SWXMLHashTests/TypeConversionBasicTypesTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ class TypeConversionBasicTypesTests: XCTestCase {
637637

638638
enum BasicItemValidation: Error { case priceOutOfBounds(Double) }
639639

640-
struct BasicItem: XMLIndexerDeserializable {
640+
struct BasicItem: XMLObjectDeserialization {
641641
let name: String
642642
let price: Double
643643
let id: String

‎Tests/SWXMLHashTests/TypeConversionComplexTypesTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ class TypeConversionComplexTypesTests: XCTestCase {
134134
}
135135
}
136136

137-
struct ComplexItem: XMLIndexerDeserializable {
137+
struct ComplexItem: XMLObjectDeserialization {
138138
let name: String
139139
let priceOptional: Double?
140140
let basics: [BasicItem]

0 commit comments

Comments
 (0)
Please sign in to comment.