diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c223ba2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.DS_Store +/.build +/Packages +*.xcodeproj \ No newline at end of file diff --git a/.swift-version b/.swift-version new file mode 100644 index 0000000..389f774 --- /dev/null +++ b/.swift-version @@ -0,0 +1 @@ +4.0 \ No newline at end of file diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..3005e47 --- /dev/null +++ b/Package.swift @@ -0,0 +1,28 @@ +// swift-tools-version:4.0 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "XMLParsing", + products: [ + // Products define the executables and libraries produced by a package, and make them visible to other packages. + .library( + name: "XMLParsing", + targets: ["XMLParsing"]), + ], + dependencies: [ + // Dependencies declare other packages that this package depends on. + // .package(url: /* package url */, from: "1.0.0"), + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages which this package depends on. + .target( + name: "XMLParsing", + dependencies: []), + .testTarget( + name: "XMLParsingTests", + dependencies: ["XMLParsing"]), + ] +) diff --git a/XMLParsing/Sample XML/Books/Books.swift b/Sample XML/Books/Books.swift similarity index 100% rename from XMLParsing/Sample XML/Books/Books.swift rename to Sample XML/Books/Books.swift diff --git a/XMLParsing/Sample XML/Books/book.xml b/Sample XML/Books/book.xml similarity index 100% rename from XMLParsing/Sample XML/Books/book.xml rename to Sample XML/Books/book.xml diff --git a/XMLParsing/Sample XML/Books/books.xml b/Sample XML/Books/books.xml similarity index 100% rename from XMLParsing/Sample XML/Books/books.xml rename to Sample XML/Books/books.xml diff --git a/XMLParsing/Sample XML/BreakfastMenu/breakfast.swift b/Sample XML/BreakfastMenu/breakfast.swift similarity index 100% rename from XMLParsing/Sample XML/BreakfastMenu/breakfast.swift rename to Sample XML/BreakfastMenu/breakfast.swift diff --git a/XMLParsing/Sample XML/BreakfastMenu/breakfast.xml b/Sample XML/BreakfastMenu/breakfast.xml similarity index 100% rename from XMLParsing/Sample XML/BreakfastMenu/breakfast.xml rename to Sample XML/BreakfastMenu/breakfast.xml diff --git a/XMLParsing/Sample XML/CDs/CDCatalog.swift b/Sample XML/CDs/CDCatalog.swift similarity index 100% rename from XMLParsing/Sample XML/CDs/CDCatalog.swift rename to Sample XML/CDs/CDCatalog.swift diff --git a/XMLParsing/Sample XML/CDs/cd_catalog.xml b/Sample XML/CDs/cd_catalog.xml similarity index 100% rename from XMLParsing/Sample XML/CDs/cd_catalog.xml rename to Sample XML/CDs/cd_catalog.xml diff --git a/XMLParsing/Sample XML/Notes/Notes.swift b/Sample XML/Notes/Notes.swift similarity index 100% rename from XMLParsing/Sample XML/Notes/Notes.swift rename to Sample XML/Notes/Notes.swift diff --git a/XMLParsing/Sample XML/Notes/note.xml b/Sample XML/Notes/note.xml similarity index 100% rename from XMLParsing/Sample XML/Notes/note.xml rename to Sample XML/Notes/note.xml diff --git a/XMLParsing/Sample XML/Notes/note_error.xml b/Sample XML/Notes/note_error.xml similarity index 100% rename from XMLParsing/Sample XML/Notes/note_error.xml rename to Sample XML/Notes/note_error.xml diff --git a/XMLParsing/Sample XML/Plants/PlantCatalog.swift b/Sample XML/Plants/PlantCatalog.swift similarity index 100% rename from XMLParsing/Sample XML/Plants/PlantCatalog.swift rename to Sample XML/Plants/PlantCatalog.swift diff --git a/XMLParsing/Sample XML/Plants/plant_catalog.xml b/Sample XML/Plants/plant_catalog.xml similarity index 100% rename from XMLParsing/Sample XML/Plants/plant_catalog.xml rename to Sample XML/Plants/plant_catalog.xml diff --git a/XMLParsing/Sample XML/RJI/RJI.swift b/Sample XML/RJI/RJI.swift similarity index 100% rename from XMLParsing/Sample XML/RJI/RJI.swift rename to Sample XML/RJI/RJI.swift diff --git a/XMLParsing/Sample XML/RJI/RJI_RSS_Sample.xml b/Sample XML/RJI/RJI_RSS_Sample.xml similarity index 100% rename from XMLParsing/Sample XML/RJI/RJI_RSS_Sample.xml rename to Sample XML/RJI/RJI_RSS_Sample.xml diff --git a/XMLParsing/XML/Decoder/DecodingErrorExtension.swift b/Sources/XMLParsing/Decoder/DecodingErrorExtension.swift similarity index 100% rename from XMLParsing/XML/Decoder/DecodingErrorExtension.swift rename to Sources/XMLParsing/Decoder/DecodingErrorExtension.swift diff --git a/XMLParsing/XML/Decoder/XMLDecoder.swift b/Sources/XMLParsing/Decoder/XMLDecoder.swift similarity index 100% rename from XMLParsing/XML/Decoder/XMLDecoder.swift rename to Sources/XMLParsing/Decoder/XMLDecoder.swift diff --git a/XMLParsing/XML/Decoder/XMLDecodingStorage.swift b/Sources/XMLParsing/Decoder/XMLDecodingStorage.swift similarity index 100% rename from XMLParsing/XML/Decoder/XMLDecodingStorage.swift rename to Sources/XMLParsing/Decoder/XMLDecodingStorage.swift diff --git a/XMLParsing/XML/Decoder/XMLKeyedDecodingContainer.swift b/Sources/XMLParsing/Decoder/XMLKeyedDecodingContainer.swift similarity index 100% rename from XMLParsing/XML/Decoder/XMLKeyedDecodingContainer.swift rename to Sources/XMLParsing/Decoder/XMLKeyedDecodingContainer.swift diff --git a/XMLParsing/XML/Decoder/XMLUnkeyedDecodingContainer.swift b/Sources/XMLParsing/Decoder/XMLUnkeyedDecodingContainer.swift similarity index 100% rename from XMLParsing/XML/Decoder/XMLUnkeyedDecodingContainer.swift rename to Sources/XMLParsing/Decoder/XMLUnkeyedDecodingContainer.swift diff --git a/XMLParsing/XML/Encoder/EncodingErrorExtension.swift b/Sources/XMLParsing/Encoder/EncodingErrorExtension.swift similarity index 100% rename from XMLParsing/XML/Encoder/EncodingErrorExtension.swift rename to Sources/XMLParsing/Encoder/EncodingErrorExtension.swift diff --git a/XMLParsing/XML/Encoder/XMLEncoder.swift b/Sources/XMLParsing/Encoder/XMLEncoder.swift similarity index 99% rename from XMLParsing/XML/Encoder/XMLEncoder.swift rename to Sources/XMLParsing/Encoder/XMLEncoder.swift index 963a9dc..e4961af 100644 --- a/XMLParsing/XML/Encoder/XMLEncoder.swift +++ b/Sources/XMLParsing/Encoder/XMLEncoder.swift @@ -896,7 +896,11 @@ extension _XMLEncoder { case .millisecondsSince1970: return NSNumber(value: value.timeIntervalSince1970 * 1000.0) case .iso8601: - return _iso8601Formatter.string(from: value) as NSObject + if #available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) { + return _iso8601Formatter.string(from: value) as NSObject + } else { + fatalError("ISO8601DateFormatter is unavailable on this platform.") + } case .formatted(let formatter): return formatter.string(from: value) as NSObject case .custom(let closure): diff --git a/XMLParsing/XML/Encoder/XMLEncodingStorage.swift b/Sources/XMLParsing/Encoder/XMLEncodingStorage.swift similarity index 100% rename from XMLParsing/XML/Encoder/XMLEncodingStorage.swift rename to Sources/XMLParsing/Encoder/XMLEncodingStorage.swift diff --git a/XMLParsing/XML/Encoder/XMLReferencingEncoder.swift b/Sources/XMLParsing/Encoder/XMLReferencingEncoder.swift similarity index 100% rename from XMLParsing/XML/Encoder/XMLReferencingEncoder.swift rename to Sources/XMLParsing/Encoder/XMLReferencingEncoder.swift diff --git a/XMLParsing/XML/ISO8601DateFormatter.swift b/Sources/XMLParsing/ISO8601DateFormatter.swift similarity index 100% rename from XMLParsing/XML/ISO8601DateFormatter.swift rename to Sources/XMLParsing/ISO8601DateFormatter.swift diff --git a/XMLParsing/XML/XMLKey.swift b/Sources/XMLParsing/XMLKey.swift similarity index 100% rename from XMLParsing/XML/XMLKey.swift rename to Sources/XMLParsing/XMLKey.swift diff --git a/XMLParsing/XML/XMLStackParser.swift b/Sources/XMLParsing/XMLStackParser.swift similarity index 100% rename from XMLParsing/XML/XMLStackParser.swift rename to Sources/XMLParsing/XMLStackParser.swift diff --git a/Tests/LinuxMain.swift b/Tests/LinuxMain.swift new file mode 100644 index 0000000..d41d8f5 --- /dev/null +++ b/Tests/LinuxMain.swift @@ -0,0 +1,6 @@ +import XCTest +@testable import XMLParsingTests + +XCTMain([ + testCase(XMLParsingTests.allTests), +]) diff --git a/Tests/XMLParsingTests/XMLParsingTests.swift b/Tests/XMLParsingTests/XMLParsingTests.swift new file mode 100644 index 0000000..1d33147 --- /dev/null +++ b/Tests/XMLParsingTests/XMLParsingTests.swift @@ -0,0 +1,16 @@ +import XCTest +@testable import XMLParsing + +class XMLParsingTests: XCTestCase { + func testExample() { + // This is an example of a functional test case. + // Use XCTAssert and related functions to verify your tests produce the correct + // results. + XCTAssertEqual(XMLParsing().text, "Hello, World!") + } + + + static var allTests = [ + ("testExample", testExample), + ] +} diff --git a/XMLParsing.podspec b/XMLParsing.podspec new file mode 100644 index 0000000..df2147e --- /dev/null +++ b/XMLParsing.podspec @@ -0,0 +1,14 @@ +Pod::Spec.new do |s| + s.name = "XMLParsing" + s.version = "0.0.1" + s.summary = "XMLEncoder & XMLDecoder using the Codable protocol in Swift 4" + s.description = "XMLParsing allows Swift 4 Codable-conforming objects to be translated to and from XML" + s.homepage = "https://github.com/ShawnMoore/XMLParsing" + s.license = { :type => "MIT", :file => "LICENSE" } + s.author = { "Shawn Moore" => "sm5@me.com" } + s.ios.deployment_target = "10.0" + s.osx.deployment_target = "10.12" + s.source = { :git => "https://github.com/ShawnMoore/XMLParsing.git", :tag => s.version.to_s } + s.source_files = "Sources/XMLParsing/**/*.swift" + s.requires_arc = true +end \ No newline at end of file diff --git a/XMLParsing.xcodeproj/project.pbxproj b/XMLParsing.xcodeproj/project.pbxproj deleted file mode 100644 index df34369..0000000 --- a/XMLParsing.xcodeproj/project.pbxproj +++ /dev/null @@ -1,535 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 48; - objects = { - -/* Begin PBXBuildFile section */ - 585926461FCA638100D72B34 /* XMLReferencingEncoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 585926451FCA638100D72B34 /* XMLReferencingEncoder.swift */; }; - 5882B9D61FCBCEFE0045F93B /* DataExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5882B9D51FCBCEFE0045F93B /* DataExtension.swift */; }; - 5898816B1FBCB5C8003154DE /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5898816A1FBCB5C8003154DE /* AppDelegate.swift */; }; - 5898816D1FBCB5C8003154DE /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5898816C1FBCB5C8003154DE /* ViewController.swift */; }; - 589881701FBCB5C8003154DE /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5898816E1FBCB5C8003154DE /* Main.storyboard */; }; - 589881721FBCB5C8003154DE /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 589881711FBCB5C8003154DE /* Assets.xcassets */; }; - 589881751FBCB5C8003154DE /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 589881731FBCB5C8003154DE /* LaunchScreen.storyboard */; }; - 5898817D1FBCB60E003154DE /* RJI_RSS_Sample.xml in Resources */ = {isa = PBXBuildFile; fileRef = 5898817C1FBCB60D003154DE /* RJI_RSS_Sample.xml */; }; - 589881801FBCB690003154DE /* books.xml in Resources */ = {isa = PBXBuildFile; fileRef = 5898817F1FBCB690003154DE /* books.xml */; }; - 589881821FBCB6E7003154DE /* note.xml in Resources */ = {isa = PBXBuildFile; fileRef = 589881811FBCB6E7003154DE /* note.xml */; }; - 589881841FBCD0F2003154DE /* note_error.xml in Resources */ = {isa = PBXBuildFile; fileRef = 589881831FBCD0F2003154DE /* note_error.xml */; }; - 589881881FBCD142003154DE /* cd_catalog.xml in Resources */ = {isa = PBXBuildFile; fileRef = 589881851FBCD142003154DE /* cd_catalog.xml */; }; - 589881891FBCD142003154DE /* plant_catalog.xml in Resources */ = {isa = PBXBuildFile; fileRef = 589881861FBCD142003154DE /* plant_catalog.xml */; }; - 5898818A1FBCD142003154DE /* breakfast.xml in Resources */ = {isa = PBXBuildFile; fileRef = 589881871FBCD142003154DE /* breakfast.xml */; }; - 5898818C1FBCD514003154DE /* XMLStackParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5898818B1FBCD514003154DE /* XMLStackParser.swift */; }; - 589881971FBCDC23003154DE /* Books.swift in Sources */ = {isa = PBXBuildFile; fileRef = 589881961FBCDC23003154DE /* Books.swift */; }; - 589D29FC1FBCF7240050E664 /* Notes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 589D29FB1FBCF7240050E664 /* Notes.swift */; }; - 589D29FE1FBCF8160050E664 /* CDCatalog.swift in Sources */ = {isa = PBXBuildFile; fileRef = 589D29FD1FBCF8160050E664 /* CDCatalog.swift */; }; - 589D2A001FBCF93E0050E664 /* PlantCatalog.swift in Sources */ = {isa = PBXBuildFile; fileRef = 589D29FF1FBCF93E0050E664 /* PlantCatalog.swift */; }; - 589D2A021FBCF9D50050E664 /* breakfast.swift in Sources */ = {isa = PBXBuildFile; fileRef = 589D2A011FBCF9D50050E664 /* breakfast.swift */; }; - 58AD27291FC394C70072AD90 /* XMLDecodingStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58AD27281FC394C70072AD90 /* XMLDecodingStorage.swift */; }; - 58AD272B1FC46B190072AD90 /* DecodingErrorExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58AD272A1FC46B190072AD90 /* DecodingErrorExtension.swift */; }; - 58AD272D1FC46B8A0072AD90 /* ISO8601DateFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58AD272C1FC46B8A0072AD90 /* ISO8601DateFormatter.swift */; }; - 58AD272F1FC46BCD0072AD90 /* XMLKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58AD272E1FC46BCD0072AD90 /* XMLKey.swift */; }; - 58AD27311FC46D9A0072AD90 /* XMLUnkeyedDecodingContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58AD27301FC46D9A0072AD90 /* XMLUnkeyedDecodingContainer.swift */; }; - 58AD27331FC4728F0072AD90 /* XMLKeyedDecodingContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58AD27321FC4728F0072AD90 /* XMLKeyedDecodingContainer.swift */; }; - 58AD27361FC63DAB0072AD90 /* EncodingErrorExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58AD27351FC63DAB0072AD90 /* EncodingErrorExtension.swift */; }; - 58AD27391FC6416E0072AD90 /* XMLEncoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58AD27381FC6416E0072AD90 /* XMLEncoder.swift */; }; - 58AD273B1FC67DBA0072AD90 /* XMLEncodingStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58AD273A1FC67DBA0072AD90 /* XMLEncodingStorage.swift */; }; - 58D005851FC08DDA0048711F /* XMLDecoderV1.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58D005841FC08DD90048711F /* XMLDecoderV1.swift */; }; - 58D005871FC37AE10048711F /* book.xml in Resources */ = {isa = PBXBuildFile; fileRef = 58D005861FC37AE10048711F /* book.xml */; }; - 58D005891FC3839D0048711F /* RJI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58D005881FC3839D0048711F /* RJI.swift */; }; - 58D0058D1FC390200048711F /* XMLDecoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58D0058C1FC390200048711F /* XMLDecoder.swift */; }; -/* End PBXBuildFile section */ - -/* Begin PBXFileReference section */ - 585926451FCA638100D72B34 /* XMLReferencingEncoder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XMLReferencingEncoder.swift; sourceTree = ""; }; - 5882B9D51FCBCEFE0045F93B /* DataExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataExtension.swift; sourceTree = ""; }; - 589881671FBCB5C8003154DE /* XMLParsing.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = XMLParsing.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 5898816A1FBCB5C8003154DE /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; - 5898816C1FBCB5C8003154DE /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; - 5898816F1FBCB5C8003154DE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; - 589881711FBCB5C8003154DE /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; - 589881741FBCB5C8003154DE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; - 589881761FBCB5C8003154DE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 5898817C1FBCB60D003154DE /* RJI_RSS_Sample.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = RJI_RSS_Sample.xml; sourceTree = ""; }; - 5898817F1FBCB690003154DE /* books.xml */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = books.xml; sourceTree = ""; }; - 589881811FBCB6E7003154DE /* note.xml */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = note.xml; sourceTree = ""; }; - 589881831FBCD0F2003154DE /* note_error.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = note_error.xml; sourceTree = ""; }; - 589881851FBCD142003154DE /* cd_catalog.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = cd_catalog.xml; sourceTree = ""; }; - 589881861FBCD142003154DE /* plant_catalog.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = plant_catalog.xml; sourceTree = ""; }; - 589881871FBCD142003154DE /* breakfast.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = breakfast.xml; sourceTree = ""; }; - 5898818B1FBCD514003154DE /* XMLStackParser.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = XMLStackParser.swift; sourceTree = ""; }; - 589881961FBCDC23003154DE /* Books.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Books.swift; sourceTree = ""; }; - 589D29FB1FBCF7240050E664 /* Notes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Notes.swift; sourceTree = ""; }; - 589D29FD1FBCF8160050E664 /* CDCatalog.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CDCatalog.swift; sourceTree = ""; }; - 589D29FF1FBCF93E0050E664 /* PlantCatalog.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlantCatalog.swift; sourceTree = ""; }; - 589D2A011FBCF9D50050E664 /* breakfast.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = breakfast.swift; sourceTree = ""; }; - 58AD27281FC394C70072AD90 /* XMLDecodingStorage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XMLDecodingStorage.swift; sourceTree = ""; }; - 58AD272A1FC46B190072AD90 /* DecodingErrorExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DecodingErrorExtension.swift; sourceTree = ""; }; - 58AD272C1FC46B8A0072AD90 /* ISO8601DateFormatter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ISO8601DateFormatter.swift; sourceTree = ""; }; - 58AD272E1FC46BCD0072AD90 /* XMLKey.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XMLKey.swift; sourceTree = ""; }; - 58AD27301FC46D9A0072AD90 /* XMLUnkeyedDecodingContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XMLUnkeyedDecodingContainer.swift; sourceTree = ""; }; - 58AD27321FC4728F0072AD90 /* XMLKeyedDecodingContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XMLKeyedDecodingContainer.swift; sourceTree = ""; }; - 58AD27351FC63DAB0072AD90 /* EncodingErrorExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EncodingErrorExtension.swift; sourceTree = ""; }; - 58AD27381FC6416E0072AD90 /* XMLEncoder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XMLEncoder.swift; sourceTree = ""; }; - 58AD273A1FC67DBA0072AD90 /* XMLEncodingStorage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XMLEncodingStorage.swift; sourceTree = ""; }; - 58D005841FC08DD90048711F /* XMLDecoderV1.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = XMLDecoderV1.swift; sourceTree = ""; }; - 58D005861FC37AE10048711F /* book.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = book.xml; sourceTree = ""; }; - 58D005881FC3839D0048711F /* RJI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RJI.swift; sourceTree = ""; }; - 58D0058C1FC390200048711F /* XMLDecoder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XMLDecoder.swift; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 589881641FBCB5C8003154DE /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 5898815E1FBCB5C8003154DE = { - isa = PBXGroup; - children = ( - 589881691FBCB5C8003154DE /* XMLParsing */, - 589881681FBCB5C8003154DE /* Products */, - ); - sourceTree = ""; - }; - 589881681FBCB5C8003154DE /* Products */ = { - isa = PBXGroup; - children = ( - 589881671FBCB5C8003154DE /* XMLParsing.app */, - ); - name = Products; - sourceTree = ""; - }; - 589881691FBCB5C8003154DE /* XMLParsing */ = { - isa = PBXGroup; - children = ( - 5898816C1FBCB5C8003154DE /* ViewController.swift */, - 5898817E1FBCB611003154DE /* Sample XML */, - 58AD27371FC63DFF0072AD90 /* XML */, - 58D0058A1FC38FF30048711F /* Previous XML Attempts */, - 5898818D1FBCD518003154DE /* Support */, - ); - path = XMLParsing; - sourceTree = ""; - }; - 5898817E1FBCB611003154DE /* Sample XML */ = { - isa = PBXGroup; - children = ( - 5898818F1FBCDBC6003154DE /* RJI */, - 589881901FBCDBCD003154DE /* Books */, - 589881911FBCDBD9003154DE /* Notes */, - 589881921FBCDBE0003154DE /* CDs */, - 589881941FBCDBF6003154DE /* Plants */, - 589881951FBCDBFC003154DE /* BreakfastMenu */, - ); - path = "Sample XML"; - sourceTree = ""; - }; - 5898818D1FBCD518003154DE /* Support */ = { - isa = PBXGroup; - children = ( - 5898816A1FBCB5C8003154DE /* AppDelegate.swift */, - 5898816E1FBCB5C8003154DE /* Main.storyboard */, - 589881711FBCB5C8003154DE /* Assets.xcassets */, - 589881731FBCB5C8003154DE /* LaunchScreen.storyboard */, - 589881761FBCB5C8003154DE /* Info.plist */, - 5882B9D51FCBCEFE0045F93B /* DataExtension.swift */, - ); - name = Support; - sourceTree = ""; - }; - 5898818F1FBCDBC6003154DE /* RJI */ = { - isa = PBXGroup; - children = ( - 5898817C1FBCB60D003154DE /* RJI_RSS_Sample.xml */, - 58D005881FC3839D0048711F /* RJI.swift */, - ); - path = RJI; - sourceTree = ""; - }; - 589881901FBCDBCD003154DE /* Books */ = { - isa = PBXGroup; - children = ( - 58D005861FC37AE10048711F /* book.xml */, - 5898817F1FBCB690003154DE /* books.xml */, - 589881961FBCDC23003154DE /* Books.swift */, - ); - path = Books; - sourceTree = ""; - }; - 589881911FBCDBD9003154DE /* Notes */ = { - isa = PBXGroup; - children = ( - 589881811FBCB6E7003154DE /* note.xml */, - 589881831FBCD0F2003154DE /* note_error.xml */, - 589D29FB1FBCF7240050E664 /* Notes.swift */, - ); - path = Notes; - sourceTree = ""; - }; - 589881921FBCDBE0003154DE /* CDs */ = { - isa = PBXGroup; - children = ( - 589881851FBCD142003154DE /* cd_catalog.xml */, - 589D29FD1FBCF8160050E664 /* CDCatalog.swift */, - ); - path = CDs; - sourceTree = ""; - }; - 589881941FBCDBF6003154DE /* Plants */ = { - isa = PBXGroup; - children = ( - 589881861FBCD142003154DE /* plant_catalog.xml */, - 589D29FF1FBCF93E0050E664 /* PlantCatalog.swift */, - ); - path = Plants; - sourceTree = ""; - }; - 589881951FBCDBFC003154DE /* BreakfastMenu */ = { - isa = PBXGroup; - children = ( - 589881871FBCD142003154DE /* breakfast.xml */, - 589D2A011FBCF9D50050E664 /* breakfast.swift */, - ); - path = BreakfastMenu; - sourceTree = ""; - }; - 58AD27341FC637CC0072AD90 /* Encoder */ = { - isa = PBXGroup; - children = ( - 58AD27351FC63DAB0072AD90 /* EncodingErrorExtension.swift */, - 58AD27381FC6416E0072AD90 /* XMLEncoder.swift */, - 585926451FCA638100D72B34 /* XMLReferencingEncoder.swift */, - 58AD273A1FC67DBA0072AD90 /* XMLEncodingStorage.swift */, - ); - path = Encoder; - sourceTree = ""; - }; - 58AD27371FC63DFF0072AD90 /* XML */ = { - isa = PBXGroup; - children = ( - 58AD272C1FC46B8A0072AD90 /* ISO8601DateFormatter.swift */, - 5898818B1FBCD514003154DE /* XMLStackParser.swift */, - 58AD272E1FC46BCD0072AD90 /* XMLKey.swift */, - 58AD27341FC637CC0072AD90 /* Encoder */, - 58D0058B1FC3900F0048711F /* Decoder */, - ); - path = XML; - sourceTree = ""; - }; - 58D0058A1FC38FF30048711F /* Previous XML Attempts */ = { - isa = PBXGroup; - children = ( - 58D005841FC08DD90048711F /* XMLDecoderV1.swift */, - ); - path = "Previous XML Attempts"; - sourceTree = ""; - }; - 58D0058B1FC3900F0048711F /* Decoder */ = { - isa = PBXGroup; - children = ( - 58D0058C1FC390200048711F /* XMLDecoder.swift */, - 58AD27281FC394C70072AD90 /* XMLDecodingStorage.swift */, - 58AD27321FC4728F0072AD90 /* XMLKeyedDecodingContainer.swift */, - 58AD27301FC46D9A0072AD90 /* XMLUnkeyedDecodingContainer.swift */, - 58AD272A1FC46B190072AD90 /* DecodingErrorExtension.swift */, - ); - path = Decoder; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 589881661FBCB5C8003154DE /* XMLParsing */ = { - isa = PBXNativeTarget; - buildConfigurationList = 589881791FBCB5C8003154DE /* Build configuration list for PBXNativeTarget "XMLParsing" */; - buildPhases = ( - 589881631FBCB5C8003154DE /* Sources */, - 589881641FBCB5C8003154DE /* Frameworks */, - 589881651FBCB5C8003154DE /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = XMLParsing; - productName = XMLParsing; - productReference = 589881671FBCB5C8003154DE /* XMLParsing.app */; - productType = "com.apple.product-type.application"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 5898815F1FBCB5C8003154DE /* Project object */ = { - isa = PBXProject; - attributes = { - LastSwiftUpdateCheck = 0910; - LastUpgradeCheck = 0910; - ORGANIZATIONNAME = "Shawn Moore"; - TargetAttributes = { - 589881661FBCB5C8003154DE = { - CreatedOnToolsVersion = 9.1; - ProvisioningStyle = Automatic; - }; - }; - }; - buildConfigurationList = 589881621FBCB5C8003154DE /* Build configuration list for PBXProject "XMLParsing" */; - compatibilityVersion = "Xcode 8.0"; - developmentRegion = en; - hasScannedForEncodings = 0; - knownRegions = ( - en, - Base, - ); - mainGroup = 5898815E1FBCB5C8003154DE; - productRefGroup = 589881681FBCB5C8003154DE /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 589881661FBCB5C8003154DE /* XMLParsing */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - 589881651FBCB5C8003154DE /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 589881751FBCB5C8003154DE /* LaunchScreen.storyboard in Resources */, - 589881721FBCB5C8003154DE /* Assets.xcassets in Resources */, - 5898817D1FBCB60E003154DE /* RJI_RSS_Sample.xml in Resources */, - 5898818A1FBCD142003154DE /* breakfast.xml in Resources */, - 589881891FBCD142003154DE /* plant_catalog.xml in Resources */, - 589881821FBCB6E7003154DE /* note.xml in Resources */, - 589881841FBCD0F2003154DE /* note_error.xml in Resources */, - 58D005871FC37AE10048711F /* book.xml in Resources */, - 589881801FBCB690003154DE /* books.xml in Resources */, - 589881881FBCD142003154DE /* cd_catalog.xml in Resources */, - 589881701FBCB5C8003154DE /* Main.storyboard in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - 589881631FBCB5C8003154DE /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 589D29FE1FBCF8160050E664 /* CDCatalog.swift in Sources */, - 58D005851FC08DDA0048711F /* XMLDecoderV1.swift in Sources */, - 58AD272B1FC46B190072AD90 /* DecodingErrorExtension.swift in Sources */, - 5882B9D61FCBCEFE0045F93B /* DataExtension.swift in Sources */, - 589881971FBCDC23003154DE /* Books.swift in Sources */, - 58AD273B1FC67DBA0072AD90 /* XMLEncodingStorage.swift in Sources */, - 589D29FC1FBCF7240050E664 /* Notes.swift in Sources */, - 585926461FCA638100D72B34 /* XMLReferencingEncoder.swift in Sources */, - 5898816D1FBCB5C8003154DE /* ViewController.swift in Sources */, - 58AD27311FC46D9A0072AD90 /* XMLUnkeyedDecodingContainer.swift in Sources */, - 589D2A001FBCF93E0050E664 /* PlantCatalog.swift in Sources */, - 58AD27331FC4728F0072AD90 /* XMLKeyedDecodingContainer.swift in Sources */, - 589D2A021FBCF9D50050E664 /* breakfast.swift in Sources */, - 5898818C1FBCD514003154DE /* XMLStackParser.swift in Sources */, - 58AD27391FC6416E0072AD90 /* XMLEncoder.swift in Sources */, - 58AD272D1FC46B8A0072AD90 /* ISO8601DateFormatter.swift in Sources */, - 5898816B1FBCB5C8003154DE /* AppDelegate.swift in Sources */, - 58D005891FC3839D0048711F /* RJI.swift in Sources */, - 58AD272F1FC46BCD0072AD90 /* XMLKey.swift in Sources */, - 58AD27291FC394C70072AD90 /* XMLDecodingStorage.swift in Sources */, - 58D0058D1FC390200048711F /* XMLDecoder.swift in Sources */, - 58AD27361FC63DAB0072AD90 /* EncodingErrorExtension.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXVariantGroup section */ - 5898816E1FBCB5C8003154DE /* Main.storyboard */ = { - isa = PBXVariantGroup; - children = ( - 5898816F1FBCB5C8003154DE /* Base */, - ); - name = Main.storyboard; - sourceTree = ""; - }; - 589881731FBCB5C8003154DE /* LaunchScreen.storyboard */ = { - isa = PBXVariantGroup; - children = ( - 589881741FBCB5C8003154DE /* Base */, - ); - name = LaunchScreen.storyboard; - sourceTree = ""; - }; -/* End PBXVariantGroup section */ - -/* Begin XCBuildConfiguration section */ - 589881771FBCB5C8003154DE /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CODE_SIGN_IDENTITY = "iPhone Developer"; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.1; - MTL_ENABLE_DEBUG_INFO = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - }; - name = Debug; - }; - 589881781FBCB5C8003154DE /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CODE_SIGN_IDENTITY = "iPhone Developer"; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.1; - MTL_ENABLE_DEBUG_INFO = NO; - SDKROOT = iphoneos; - SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - VALIDATE_PRODUCT = YES; - }; - name = Release; - }; - 5898817A1FBCB5C8003154DE /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = 59B8VY99KD; - INFOPLIST_FILE = XMLParsing/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = edu.missouri.XMLParsing; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Debug; - }; - 5898817B1FBCB5C8003154DE /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = 59B8VY99KD; - INFOPLIST_FILE = XMLParsing/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = edu.missouri.XMLParsing; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 589881621FBCB5C8003154DE /* Build configuration list for PBXProject "XMLParsing" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 589881771FBCB5C8003154DE /* Debug */, - 589881781FBCB5C8003154DE /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 589881791FBCB5C8003154DE /* Build configuration list for PBXNativeTarget "XMLParsing" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 5898817A1FBCB5C8003154DE /* Debug */, - 5898817B1FBCB5C8003154DE /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 5898815F1FBCB5C8003154DE /* Project object */; -} diff --git a/XMLParsing.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/XMLParsing.xcodeproj/project.xcworkspace/contents.xcworkspacedata deleted file mode 100644 index 94072b0..0000000 --- a/XMLParsing.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/XMLParsing.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/XMLParsing.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings deleted file mode 100644 index 0c67376..0000000 --- a/XMLParsing.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/XMLParsing/AppDelegate.swift b/XMLParsing/AppDelegate.swift deleted file mode 100644 index 373d59f..0000000 --- a/XMLParsing/AppDelegate.swift +++ /dev/null @@ -1,46 +0,0 @@ -// -// AppDelegate.swift -// XMLParsing -// -// Created by Shawn Moore on 11/15/17. -// Copyright © 2017 Shawn Moore. All rights reserved. -// - -import UIKit - -@UIApplicationMain -class AppDelegate: UIResponder, UIApplicationDelegate { - - var window: UIWindow? - - - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { - // Override point for customization after application launch. - return true - } - - func applicationWillResignActive(_ application: UIApplication) { - // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. - // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. - } - - func applicationDidEnterBackground(_ application: UIApplication) { - // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. - // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. - } - - func applicationWillEnterForeground(_ application: UIApplication) { - // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. - } - - func applicationDidBecomeActive(_ application: UIApplication) { - // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. - } - - func applicationWillTerminate(_ application: UIApplication) { - // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. - } - - -} - diff --git a/XMLParsing/Assets.xcassets/AppIcon.appiconset/Contents.json b/XMLParsing/Assets.xcassets/AppIcon.appiconset/Contents.json deleted file mode 100644 index 1d060ed..0000000 --- a/XMLParsing/Assets.xcassets/AppIcon.appiconset/Contents.json +++ /dev/null @@ -1,93 +0,0 @@ -{ - "images" : [ - { - "idiom" : "iphone", - "size" : "20x20", - "scale" : "2x" - }, - { - "idiom" : "iphone", - "size" : "20x20", - "scale" : "3x" - }, - { - "idiom" : "iphone", - "size" : "29x29", - "scale" : "2x" - }, - { - "idiom" : "iphone", - "size" : "29x29", - "scale" : "3x" - }, - { - "idiom" : "iphone", - "size" : "40x40", - "scale" : "2x" - }, - { - "idiom" : "iphone", - "size" : "40x40", - "scale" : "3x" - }, - { - "idiom" : "iphone", - "size" : "60x60", - "scale" : "2x" - }, - { - "idiom" : "iphone", - "size" : "60x60", - "scale" : "3x" - }, - { - "idiom" : "ipad", - "size" : "20x20", - "scale" : "1x" - }, - { - "idiom" : "ipad", - "size" : "20x20", - "scale" : "2x" - }, - { - "idiom" : "ipad", - "size" : "29x29", - "scale" : "1x" - }, - { - "idiom" : "ipad", - "size" : "29x29", - "scale" : "2x" - }, - { - "idiom" : "ipad", - "size" : "40x40", - "scale" : "1x" - }, - { - "idiom" : "ipad", - "size" : "40x40", - "scale" : "2x" - }, - { - "idiom" : "ipad", - "size" : "76x76", - "scale" : "1x" - }, - { - "idiom" : "ipad", - "size" : "76x76", - "scale" : "2x" - }, - { - "idiom" : "ipad", - "size" : "83.5x83.5", - "scale" : "2x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/XMLParsing/Base.lproj/LaunchScreen.storyboard b/XMLParsing/Base.lproj/LaunchScreen.storyboard deleted file mode 100644 index f83f6fd..0000000 --- a/XMLParsing/Base.lproj/LaunchScreen.storyboard +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/XMLParsing/Base.lproj/Main.storyboard b/XMLParsing/Base.lproj/Main.storyboard deleted file mode 100644 index 03c13c2..0000000 --- a/XMLParsing/Base.lproj/Main.storyboard +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/XMLParsing/DataExtension.swift b/XMLParsing/DataExtension.swift deleted file mode 100644 index a986742..0000000 --- a/XMLParsing/DataExtension.swift +++ /dev/null @@ -1,21 +0,0 @@ -// -// DataExtension.swift -// XMLParsing -// -// Created by Shawn Moore on 11/26/17. -// Copyright © 2017 Shawn Moore. All rights reserved. -// - -import Foundation - -extension Data { - init?(forResource name: String?, withExtension ext: String?) { - guard let fileURL = Bundle.main.url(forResource: name, withExtension: ext) else { return nil } - - do { - try self.init(contentsOf: fileURL) - } catch { - return nil - } - } -} diff --git a/XMLParsing/Info.plist b/XMLParsing/Info.plist deleted file mode 100644 index 16be3b6..0000000 --- a/XMLParsing/Info.plist +++ /dev/null @@ -1,45 +0,0 @@ - - - - - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - APPL - CFBundleShortVersionString - 1.0 - CFBundleVersion - 1 - LSRequiresIPhoneOS - - UILaunchStoryboardName - LaunchScreen - UIMainStoryboardFile - Main - UIRequiredDeviceCapabilities - - armv7 - - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - UISupportedInterfaceOrientations~ipad - - UIInterfaceOrientationPortrait - UIInterfaceOrientationPortraitUpsideDown - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - - diff --git a/XMLParsing/Previous XML Attempts/XMLDecoderV1.swift b/XMLParsing/Previous XML Attempts/XMLDecoderV1.swift deleted file mode 100644 index bd11f9d..0000000 --- a/XMLParsing/Previous XML Attempts/XMLDecoderV1.swift +++ /dev/null @@ -1,1519 +0,0 @@ -//// -//// XMLDecoder.swift -//// CustomEncoder -//// -//// Created by Shawn Moore on 11/14/17. -//// Copyright © 2017 Shawn Moore. All rights reserved. -//// -// -//import Foundation -// -///// `XMLDecoder` facilitates the decoding of XML into semantic `Decodable` types. -//open class XMLDecoder { -// // MARK: Options -// /// The strategy to use for decoding `Date` values. -// public enum DateDecodingStrategy { -// /// Defer to `Date` for decoding. This is the default strategy. -// case deferredToDate -// -// /// Decode the `Date` as a UNIX timestamp from a XML number. This is the default strategy. -// case secondsSince1970 -// -// /// Decode the `Date` as UNIX millisecond timestamp from a XML number. -// case millisecondsSince1970 -// -// /// Decode the `Date` as an ISO-8601-formatted string (in RFC 3339 format). -// @available(OSX 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) -// case iso8601 -// -// /// Decode the `Date` as a string parsed by the given formatter. -// case formatted(DateFormatter) -//// -//// /// Decode the `Date` as a string parsed by the given formatter for the give key. -//// case keyFormatted((_ key: CodingKey) throws -> DateFormatter) -// -// /// Decode the `Date` as a custom value decoded by the given closure. -// case custom((_ decoder: Decoder) throws -> Date) -// } -// -// /// The strategy to use for decoding `Data` values. -// public enum DataDecodingStrategy { -// /// Defer to `Data` for decoding. -// case deferredToData -// -// /// Decode the `Data` from a Base64-encoded string. This is the default strategy. -// case base64 -// -// /// Decode the `Data` as a custom value decoded by the given closure. -// case custom((_ decoder: Decoder) throws -> Data) -// } -// -// /// The strategy to use for non-XML-conforming floating-point values (IEEE 754 infinity and NaN). -// public enum NonConformingFloatDecodingStrategy { -// /// Throw upon encountering non-conforming values. This is the default strategy. -// case `throw` -// -// /// Decode the values from the given representation strings. -// case convertFromString(positiveInfinity: String, negativeInfinity: String, nan: String) -// } -// -// /// The strategy to use in decoding dates. Defaults to `.secondsSince1970`. -// open var dateDecodingStrategy: DateDecodingStrategy = .secondsSince1970 -// -// /// The strategy to use in decoding binary data. Defaults to `.base64`. -// open var dataDecodingStrategy: DataDecodingStrategy = .base64 -// -// /// The strategy to use in decoding non-conforming numbers. Defaults to `.throw`. -// open var nonConformingFloatDecodingStrategy: NonConformingFloatDecodingStrategy = .throw -// -// /// Contextual user-provided information for use during decoding. -// open var userInfo: [CodingUserInfoKey : Any] = [:] -// -// /// Options set on the top-level encoder to pass down the decoding hierarchy. -// fileprivate struct _Options { -// let dateDecodingStrategy: DateDecodingStrategy -// let dataDecodingStrategy: DataDecodingStrategy -// let nonConformingFloatDecodingStrategy: NonConformingFloatDecodingStrategy -// let userInfo: [CodingUserInfoKey : Any] -// } -// -// /// The options set on the top-level decoder. -// fileprivate var options: _Options { -// return _Options(dateDecodingStrategy: dateDecodingStrategy, -// dataDecodingStrategy: dataDecodingStrategy, -// nonConformingFloatDecodingStrategy: nonConformingFloatDecodingStrategy, -// userInfo: userInfo) -// } -// -// // MARK: - Constructing a XML Decoder -// /// Initializes `self` with default strategies. -// public init() {} -// -// // MARK: - Decoding Values -// /// Decodes a top-level value of the given type from the given XML representation. -// /// -// /// - parameter type: The type of the value to decode. -// /// - parameter data: The data to decode from. -// /// - returns: A value of the requested type. -// /// - throws: `DecodingError.dataCorrupted` if values requested from the payload are corrupted, or if the given data is not valid XML. -// /// - throws: An error if any value throws an error during decoding. -// open func decode(_ type: T.Type, from data: Data) throws /*-> T*/ { -// -//// let topLevel: Any -//// do { -//// topLevel = try JSONSerialization.jsonObject(with: data) -//// } catch { -//// throw DecodingError.dataCorrupted(DecodingError.Context(codingPath: [], debugDescription: "The given data was not valid JSON.", underlyingError: error)) -//// } -//// -//// let decoder = _JSONDecoder(referencing: topLevel, options: self.options) -//// guard let value = try decoder.unbox(topLevel, as: type) else { -//// throw DecodingError.valueNotFound(type, DecodingError.Context(codingPath: [], debugDescription: "The given data did not contain a top-level value.")) -//// } -//// -//// return value -// } -//} -// -//// MARK: - _XMLDecoder -// -//fileprivate class _XMLDecoder : Decoder { -// // MARK: Properties -// -// /// The decoder's storage. -// fileprivate var storage: _XMLDecodingStorage -// -// /// Options set on the top-level decoder. -// fileprivate let options: XMLDecoder._Options -// -// /// The path to the current point in encoding. -// fileprivate(set) public var codingPath: [CodingKey] -// -// /// Contextual user-provided information for use during encoding. -// public var userInfo: [CodingUserInfoKey : Any] { -// return self.options.userInfo -// } -// -// // MARK: - Initialization -// -// /// Initializes `self` with the given top-level container and options. -// fileprivate init(referencing container: _XMLNode, at codingPath: [CodingKey] = [], options: XMLDecoder._Options) { -// self.storage = _XMLDecodingStorage() -// self.storage.push(container: container) -// self.codingPath = codingPath -// self.options = options -// } -// -// // MARK: - Decoder Methods -// -// public func container(keyedBy type: Key.Type) throws -> KeyedDecodingContainer { -// guard !(self.storage.topContainer is NSNull) else { -// throw DecodingError.valueNotFound(KeyedDecodingContainer.self, -// DecodingError.Context(codingPath: self.codingPath, -// debugDescription: "Cannot get keyed decoding container -- found null value instead.")) -// } -// -// guard let topContainer = self.storage.topContainer as? [String : Any] else { -// throw DecodingError._typeMismatch(at: self.codingPath, expectation: [String : Any].self, reality: self.storage.topContainer) -// } -// -// let container = _XMLKeyedDecodingContainer(referencing: self, wrapping: topContainer) -// return KeyedDecodingContainer(container) -// } -// -// public func unkeyedContainer() throws -> UnkeyedDecodingContainer { -// guard !(self.storage.topContainer is NSNull) else { -// throw DecodingError.valueNotFound(UnkeyedDecodingContainer.self, -// DecodingError.Context(codingPath: self.codingPath, -// debugDescription: "Cannot get unkeyed decoding container -- found null value instead.")) -// } -// -// guard let topContainer = self.storage.topContainer as? [Any] else { -// throw DecodingError._typeMismatch(at: self.codingPath, expectation: [Any].self, reality: self.storage.topContainer) -// } -// -// return _XMLUnkeyedDecodingContainer(referencing: self, wrapping: topContainer) -// } -// -// public func singleValueContainer() throws -> SingleValueDecodingContainer { -// return self -// } -//} -// -//// MARK: - Decoding Storage -// -//fileprivate struct _XMLDecodingStorage { -// // MARK: Properties -// -// /// The container stack. -// /// Elements may be any one of the XML types (String, [String : String]). -// private(set) fileprivate var containers: [_XMLNode] = [] -// -// /// The container temporary value. -// /// Elements can be of type Any. -// fileprivate var temporaryValue: Any? -// -// // MARK: - Initialization -// -// /// Initializes `self` with no containers. -// fileprivate init() {} -// -// // MARK: - Modifying the Stack -// -// fileprivate var count: Int { -// return self.containers.count -// } -// -// fileprivate var topContainer: Any { -// precondition(self.containers.count > 0, "Empty container stack.") -// return self.containers.last! -// } -// -// fileprivate mutating func push(container: _XMLNode) { -// self.containers.append(container) -// } -// -// fileprivate mutating func popContainer() { -// precondition(self.containers.count > 0, "Empty container stack.") -// self.containers.removeLast() -// } -//} -// -//// MARK: Decoding Containers -// -//fileprivate struct _XMLKeyedDecodingContainer : KeyedDecodingContainerProtocol { -// typealias Key = K -// -// // MARK: Properties -// -// /// A reference to the decoder we're reading from. -// private let decoder: _XMLDecoder -// -// /// A reference to the container we're reading from. -// private let container: _XMLNode -// -// /// The path of coding keys taken to get to this point in decoding. -// private(set) public var codingPath: [CodingKey] -// -// // MARK: - Initialization -// -// /// Initializes `self` by referencing the given decoder and container. -// fileprivate init(referencing decoder: _XMLDecoder, wrapping container: _XMLNode) { -// self.decoder = decoder -// self.container = container -// self.codingPath = decoder.codingPath -// } -// -// // MARK: - KeyedDecodingContainerProtocol Methods -// -// public var allKeys: [Key] { -// return self.container.allKeys.flatMap { Key(stringValue: $0) } -// } -// -// public func contains(_ key: Key) -> Bool { -// return self.container.attributes[key.stringValue] != nil || self.container.properties[key.stringValue] != nil -// } -// -// public func decodeNil(forKey key: Key) throws -> Bool { -// return self.container.attributes[key.stringValue] == nil && self.container.properties[key.stringValue] == nil -// } -// -// public func decode(_ type: Bool.Type, forKey key: Key) throws -> Bool { -// guard let entry = self.container[key.stringValue] else { -// throw DecodingError.keyNotFound(key, DecodingError.Context(codingPath: self.decoder.codingPath, debugDescription: "No value associated with key \(key) (\"\(key.stringValue)\").")) -// } -// -// self.decoder.codingPath.append(key) -// defer { self.decoder.codingPath.removeLast() } -// -// guard let value = try self.decoder.unbox(entry, as: Bool.self) else { -// throw DecodingError.valueNotFound(type, DecodingError.Context(codingPath: self.decoder.codingPath, debugDescription: "Expected \(type) value but found null instead.")) -// } -// -// return value -// } -// -// public func decode(_ type: Int.Type, forKey key: Key) throws -> Int { -// guard let entry = self.container[key.stringValue] else { -// throw DecodingError.keyNotFound(key, DecodingError.Context(codingPath: self.decoder.codingPath, debugDescription: "No value associated with key \(key) (\"\(key.stringValue)\").")) -// } -// -// self.decoder.codingPath.append(key) -// defer { self.decoder.codingPath.removeLast() } -// -// guard let value = try self.decoder.unbox(entry, as: Int.self) else { -// throw DecodingError.valueNotFound(type, DecodingError.Context(codingPath: self.decoder.codingPath, debugDescription: "Expected \(type) value but found null instead.")) -// } -// -// return value -// } -// -// public func decode(_ type: Int8.Type, forKey key: Key) throws -> Int8 { -// guard let entry = self.container[key.stringValue] else { -// throw DecodingError.keyNotFound(key, DecodingError.Context(codingPath: self.decoder.codingPath, debugDescription: "No value associated with key \(key) (\"\(key.stringValue)\").")) -// } -// -// self.decoder.codingPath.append(key) -// defer { self.decoder.codingPath.removeLast() } -// -// guard let value = try self.decoder.unbox(entry, as: Int8.self) else { -// throw DecodingError.valueNotFound(type, DecodingError.Context(codingPath: self.decoder.codingPath, debugDescription: "Expected \(type) value but found null instead.")) -// } -// -// return value -// } -// -// public func decode(_ type: Int16.Type, forKey key: Key) throws -> Int16 { -// guard let entry = self.container[key.stringValue] else { -// throw DecodingError.keyNotFound(key, DecodingError.Context(codingPath: self.decoder.codingPath, debugDescription: "No value associated with key \(key) (\"\(key.stringValue)\").")) -// } -// -// self.decoder.codingPath.append(key) -// defer { self.decoder.codingPath.removeLast() } -// -// guard let value = try self.decoder.unbox(entry, as: Int16.self) else { -// throw DecodingError.valueNotFound(type, DecodingError.Context(codingPath: self.decoder.codingPath, debugDescription: "Expected \(type) value but found null instead.")) -// } -// -// return value -// } -// -// public func decode(_ type: Int32.Type, forKey key: Key) throws -> Int32 { -// guard let entry = self.container[key.stringValue] else { -// throw DecodingError.keyNotFound(key, DecodingError.Context(codingPath: self.decoder.codingPath, debugDescription: "No value associated with key \(key) (\"\(key.stringValue)\").")) -// } -// -// self.decoder.codingPath.append(key) -// defer { self.decoder.codingPath.removeLast() } -// -// guard let value = try self.decoder.unbox(entry, as: Int32.self) else { -// throw DecodingError.valueNotFound(type, DecodingError.Context(codingPath: self.decoder.codingPath, debugDescription: "Expected \(type) value but found null instead.")) -// } -// -// return value -// } -// -// public func decode(_ type: Int64.Type, forKey key: Key) throws -> Int64 { -// guard let entry = self.container[key.stringValue] else { -// throw DecodingError.keyNotFound(key, DecodingError.Context(codingPath: self.decoder.codingPath, debugDescription: "No value associated with key \(key) (\"\(key.stringValue)\").")) -// } -// -// self.decoder.codingPath.append(key) -// defer { self.decoder.codingPath.removeLast() } -// -// guard let value = try self.decoder.unbox(entry, as: Int64.self) else { -// throw DecodingError.valueNotFound(type, DecodingError.Context(codingPath: self.decoder.codingPath, debugDescription: "Expected \(type) value but found null instead.")) -// } -// -// return value -// } -// -// public func decode(_ type: UInt.Type, forKey key: Key) throws -> UInt { -// guard let entry = self.container[key.stringValue] else { -// throw DecodingError.keyNotFound(key, DecodingError.Context(codingPath: self.decoder.codingPath, debugDescription: "No value associated with key \(key) (\"\(key.stringValue)\").")) -// } -// -// self.decoder.codingPath.append(key) -// defer { self.decoder.codingPath.removeLast() } -// -// guard let value = try self.decoder.unbox(entry, as: UInt.self) else { -// throw DecodingError.valueNotFound(type, DecodingError.Context(codingPath: self.decoder.codingPath, debugDescription: "Expected \(type) value but found null instead.")) -// } -// -// return value -// } -// -// public func decode(_ type: UInt8.Type, forKey key: Key) throws -> UInt8 { -// guard let entry = self.container[key.stringValue] else { -// throw DecodingError.keyNotFound(key, DecodingError.Context(codingPath: self.decoder.codingPath, debugDescription: "No value associated with key \(key) (\"\(key.stringValue)\").")) -// } -// -// self.decoder.codingPath.append(key) -// defer { self.decoder.codingPath.removeLast() } -// -// guard let value = try self.decoder.unbox(entry, as: UInt8.self) else { -// throw DecodingError.valueNotFound(type, DecodingError.Context(codingPath: self.decoder.codingPath, debugDescription: "Expected \(type) value but found null instead.")) -// } -// -// return value -// } -// -// public func decode(_ type: UInt16.Type, forKey key: Key) throws -> UInt16 { -// guard let entry = self.container[key.stringValue] else { -// throw DecodingError.keyNotFound(key, DecodingError.Context(codingPath: self.decoder.codingPath, debugDescription: "No value associated with key \(key) (\"\(key.stringValue)\").")) -// } -// -// self.decoder.codingPath.append(key) -// defer { self.decoder.codingPath.removeLast() } -// -// guard let value = try self.decoder.unbox(entry, as: UInt16.self) else { -// throw DecodingError.valueNotFound(type, DecodingError.Context(codingPath: self.decoder.codingPath, debugDescription: "Expected \(type) value but found null instead.")) -// } -// -// return value -// } -// -// public func decode(_ type: UInt32.Type, forKey key: Key) throws -> UInt32 { -// guard let entry = self.container[key.stringValue] else { -// throw DecodingError.keyNotFound(key, DecodingError.Context(codingPath: self.decoder.codingPath, debugDescription: "No value associated with key \(key) (\"\(key.stringValue)\").")) -// } -// -// self.decoder.codingPath.append(key) -// defer { self.decoder.codingPath.removeLast() } -// -// guard let value = try self.decoder.unbox(entry, as: UInt32.self) else { -// throw DecodingError.valueNotFound(type, DecodingError.Context(codingPath: self.decoder.codingPath, debugDescription: "Expected \(type) value but found null instead.")) -// } -// -// return value -// } -// -// public func decode(_ type: UInt64.Type, forKey key: Key) throws -> UInt64 { -// guard let entry = self.container[key.stringValue] else { -// throw DecodingError.keyNotFound(key, DecodingError.Context(codingPath: self.decoder.codingPath, debugDescription: "No value associated with key \(key) (\"\(key.stringValue)\").")) -// } -// -// self.decoder.codingPath.append(key) -// defer { self.decoder.codingPath.removeLast() } -// -// guard let value = try self.decoder.unbox(entry, as: UInt64.self) else { -// throw DecodingError.valueNotFound(type, DecodingError.Context(codingPath: self.decoder.codingPath, debugDescription: "Expected \(type) value but found null instead.")) -// } -// -// return value -// } -// -// public func decode(_ type: Float.Type, forKey key: Key) throws -> Float { -// guard let entry = self.container[key.stringValue] else { -// throw DecodingError.keyNotFound(key, DecodingError.Context(codingPath: self.decoder.codingPath, debugDescription: "No value associated with key \(key) (\"\(key.stringValue)\").")) -// } -// -// self.decoder.codingPath.append(key) -// defer { self.decoder.codingPath.removeLast() } -// -// guard let value = try self.decoder.unbox(entry, as: Float.self) else { -// throw DecodingError.valueNotFound(type, DecodingError.Context(codingPath: self.decoder.codingPath, debugDescription: "Expected \(type) value but found null instead.")) -// } -// -// return value -// } -// -// public func decode(_ type: Double.Type, forKey key: Key) throws -> Double { -// guard let entry = self.container[key.stringValue] else { -// throw DecodingError.keyNotFound(key, DecodingError.Context(codingPath: self.decoder.codingPath, debugDescription: "No value associated with key \(key) (\"\(key.stringValue)\").")) -// } -// -// self.decoder.codingPath.append(key) -// defer { self.decoder.codingPath.removeLast() } -// -// guard let value = try self.decoder.unbox(entry, as: Double.self) else { -// throw DecodingError.valueNotFound(type, DecodingError.Context(codingPath: self.decoder.codingPath, debugDescription: "Expected \(type) value but found null instead.")) -// } -// -// return value -// } -// -// public func decode(_ type: String.Type, forKey key: Key) throws -> String { -// guard let entry = self.container[key.stringValue] else { -// throw DecodingError.keyNotFound(key, DecodingError.Context(codingPath: self.decoder.codingPath, debugDescription: "No value associated with key \(key) (\"\(key.stringValue)\").")) -// } -// -// self.decoder.codingPath.append(key) -// defer { self.decoder.codingPath.removeLast() } -// -// guard let value = try self.decoder.unbox(entry, as: String.self) else { -// throw DecodingError.valueNotFound(type, DecodingError.Context(codingPath: self.decoder.codingPath, debugDescription: "Expected \(type) value but found null instead.")) -// } -// -// return value -// } -// -// public func decode(_ type: T.Type, forKey key: Key) throws -> T { -// guard let entry = self.container[key.stringValue] else { -// throw DecodingError.keyNotFound(key, DecodingError.Context(codingPath: self.decoder.codingPath, debugDescription: "No value associated with key \(key) (\"\(key.stringValue)\").")) -// } -// -// self.decoder.codingPath.append(key) -// defer { self.decoder.codingPath.removeLast() } -// -// guard let value = try self.decoder.unbox(entry, as: type) else { -// throw DecodingError.valueNotFound(type, DecodingError.Context(codingPath: self.decoder.codingPath, debugDescription: "Expected \(type) value but found null instead.")) -// } -// -// return value -// } -// -// public func nestedContainer(keyedBy type: NestedKey.Type, forKey key: Key) throws -> KeyedDecodingContainer { -// self.decoder.codingPath.append(key) -// defer { self.decoder.codingPath.removeLast() } -// -// guard let value = self.container[key.stringValue] else { -// throw DecodingError.keyNotFound(key, -// DecodingError.Context(codingPath: self.codingPath, -// debugDescription: "Cannot get \(KeyedDecodingContainer.self) -- no value found for key \"\(key.stringValue)\"")) -// } -// -// guard let dictionary = value as? [String : Any] else { -// throw DecodingError._typeMismatch(at: self.codingPath, expectation: [String : Any].self, reality: value) -// } -// -// let container = _XMLKeyedDecodingContainer(referencing: self.decoder, wrapping: dictionary) -// return KeyedDecodingContainer(container) -// } -// -// public func nestedUnkeyedContainer(forKey key: Key) throws -> UnkeyedDecodingContainer { -// self.decoder.codingPath.append(key) -// defer { self.decoder.codingPath.removeLast() } -// -// guard let value = self.container[key.stringValue] else { -// throw DecodingError.keyNotFound(key, -// DecodingError.Context(codingPath: self.codingPath, -// debugDescription: "Cannot get UnkeyedDecodingContainer -- no value found for key \"\(key.stringValue)\"")) -// } -// -// guard let array = value as? [Any] else { -// throw DecodingError._typeMismatch(at: self.codingPath, expectation: [Any].self, reality: value) -// } -// -// return _XMLUnkeyedDecodingContainer(referencing: self.decoder, wrapping: array) -// } -// -// private func _superDecoder(forKey key: CodingKey) throws -> Decoder { -// self.decoder.codingPath.append(key) -// defer { self.decoder.codingPath.removeLast() } -// -// let value: Any = self.container[key.stringValue] ?? NSNull() -// return _XMLDecoder(referencing: value, at: self.decoder.codingPath, options: self.decoder.options) -// } -// -// public func superDecoder() throws -> Decoder { -// return try _superDecoder(forKey: _XMLKey.super) -// } -// -// public func superDecoder(forKey key: Key) throws -> Decoder { -// return try _superDecoder(forKey: key) -// } -//} -// -//fileprivate struct _XMLUnkeyedDecodingContainer : UnkeyedDecodingContainer { -// // MARK: Properties -// -// /// A reference to the decoder we're reading from. -// private let decoder: _XMLDecoder -// -// /// A reference to the container we're reading from. -// private let container: [Any] -// -// /// The path of coding keys taken to get to this point in decoding. -// private(set) public var codingPath: [CodingKey] -// -// /// The index of the element we're about to decode. -// private(set) public var currentIndex: Int -// -// // MARK: - Initialization -// -// /// Initializes `self` by referencing the given decoder and container. -// fileprivate init(referencing decoder: _XMLDecoder, wrapping container: [Any]) { -// self.decoder = decoder -// self.container = container -// self.codingPath = decoder.codingPath -// self.currentIndex = 0 -// } -// -// // MARK: - UnkeyedDecodingContainer Methods -// -// public var count: Int? { -// return self.container.count -// } -// -// public var isAtEnd: Bool { -// return self.currentIndex >= self.count! -// } -// -// public mutating func decodeNil() throws -> Bool { -// guard !self.isAtEnd else { -// throw DecodingError.valueNotFound(Any?.self, DecodingError.Context(codingPath: self.decoder.codingPath + [_XMLKey(index: self.currentIndex)], debugDescription: "Unkeyed container is at end.")) -// } -// -// if self.container[self.currentIndex] is NSNull { -// self.currentIndex += 1 -// return true -// } else { -// return false -// } -// } -// -// public mutating func decode(_ type: Bool.Type) throws -> Bool { -// guard !self.isAtEnd else { -// throw DecodingError.valueNotFound(type, DecodingError.Context(codingPath: self.decoder.codingPath + [_XMLKey(index: self.currentIndex)], debugDescription: "Unkeyed container is at end.")) -// } -// -// self.decoder.codingPath.append(_XMLKey(index: self.currentIndex)) -// defer { self.decoder.codingPath.removeLast() } -// -// guard let decoded = try self.decoder.unbox(self.container[self.currentIndex], as: Bool.self) else { -// throw DecodingError.valueNotFound(type, DecodingError.Context(codingPath: self.decoder.codingPath + [_XMLKey(index: self.currentIndex)], debugDescription: "Expected \(type) but found null instead.")) -// } -// -// self.currentIndex += 1 -// return decoded -// } -// -// public mutating func decode(_ type: Int.Type) throws -> Int { -// guard !self.isAtEnd else { -// throw DecodingError.valueNotFound(type, DecodingError.Context(codingPath: self.decoder.codingPath + [_XMLKey(index: self.currentIndex)], debugDescription: "Unkeyed container is at end.")) -// } -// -// self.decoder.codingPath.append(_XMLKey(index: self.currentIndex)) -// defer { self.decoder.codingPath.removeLast() } -// -// guard let decoded = try self.decoder.unbox(self.container[self.currentIndex], as: Int.self) else { -// throw DecodingError.valueNotFound(type, DecodingError.Context(codingPath: self.decoder.codingPath + [_XMLKey(index: self.currentIndex)], debugDescription: "Expected \(type) but found null instead.")) -// } -// -// self.currentIndex += 1 -// return decoded -// } -// -// public mutating func decode(_ type: Int8.Type) throws -> Int8 { -// guard !self.isAtEnd else { -// throw DecodingError.valueNotFound(type, DecodingError.Context(codingPath: self.decoder.codingPath + [_XMLKey(index: self.currentIndex)], debugDescription: "Unkeyed container is at end.")) -// } -// -// self.decoder.codingPath.append(_XMLKey(index: self.currentIndex)) -// defer { self.decoder.codingPath.removeLast() } -// -// guard let decoded = try self.decoder.unbox(self.container[self.currentIndex], as: Int8.self) else { -// throw DecodingError.valueNotFound(type, DecodingError.Context(codingPath: self.decoder.codingPath + [_XMLKey(index: self.currentIndex)], debugDescription: "Expected \(type) but found null instead.")) -// } -// -// self.currentIndex += 1 -// return decoded -// } -// -// public mutating func decode(_ type: Int16.Type) throws -> Int16 { -// guard !self.isAtEnd else { -// throw DecodingError.valueNotFound(type, DecodingError.Context(codingPath: self.decoder.codingPath + [_XMLKey(index: self.currentIndex)], debugDescription: "Unkeyed container is at end.")) -// } -// -// self.decoder.codingPath.append(_XMLKey(index: self.currentIndex)) -// defer { self.decoder.codingPath.removeLast() } -// -// guard let decoded = try self.decoder.unbox(self.container[self.currentIndex], as: Int16.self) else { -// throw DecodingError.valueNotFound(type, DecodingError.Context(codingPath: self.decoder.codingPath + [_XMLKey(index: self.currentIndex)], debugDescription: "Expected \(type) but found null instead.")) -// } -// -// self.currentIndex += 1 -// return decoded -// } -// -// public mutating func decode(_ type: Int32.Type) throws -> Int32 { -// guard !self.isAtEnd else { -// throw DecodingError.valueNotFound(type, DecodingError.Context(codingPath: self.decoder.codingPath + [_XMLKey(index: self.currentIndex)], debugDescription: "Unkeyed container is at end.")) -// } -// -// self.decoder.codingPath.append(_XMLKey(index: self.currentIndex)) -// defer { self.decoder.codingPath.removeLast() } -// -// guard let decoded = try self.decoder.unbox(self.container[self.currentIndex], as: Int32.self) else { -// throw DecodingError.valueNotFound(type, DecodingError.Context(codingPath: self.decoder.codingPath + [_XMLKey(index: self.currentIndex)], debugDescription: "Expected \(type) but found null instead.")) -// } -// -// self.currentIndex += 1 -// return decoded -// } -// -// public mutating func decode(_ type: Int64.Type) throws -> Int64 { -// guard !self.isAtEnd else { -// throw DecodingError.valueNotFound(type, DecodingError.Context(codingPath: self.decoder.codingPath + [_XMLKey(index: self.currentIndex)], debugDescription: "Unkeyed container is at end.")) -// } -// -// self.decoder.codingPath.append(_XMLKey(index: self.currentIndex)) -// defer { self.decoder.codingPath.removeLast() } -// -// guard let decoded = try self.decoder.unbox(self.container[self.currentIndex], as: Int64.self) else { -// throw DecodingError.valueNotFound(type, DecodingError.Context(codingPath: self.decoder.codingPath + [_XMLKey(index: self.currentIndex)], debugDescription: "Expected \(type) but found null instead.")) -// } -// -// self.currentIndex += 1 -// return decoded -// } -// -// public mutating func decode(_ type: UInt.Type) throws -> UInt { -// guard !self.isAtEnd else { -// throw DecodingError.valueNotFound(type, DecodingError.Context(codingPath: self.decoder.codingPath + [_XMLKey(index: self.currentIndex)], debugDescription: "Unkeyed container is at end.")) -// } -// -// self.decoder.codingPath.append(_XMLKey(index: self.currentIndex)) -// defer { self.decoder.codingPath.removeLast() } -// -// guard let decoded = try self.decoder.unbox(self.container[self.currentIndex], as: UInt.self) else { -// throw DecodingError.valueNotFound(type, DecodingError.Context(codingPath: self.decoder.codingPath + [_XMLKey(index: self.currentIndex)], debugDescription: "Expected \(type) but found null instead.")) -// } -// -// self.currentIndex += 1 -// return decoded -// } -// -// public mutating func decode(_ type: UInt8.Type) throws -> UInt8 { -// guard !self.isAtEnd else { -// throw DecodingError.valueNotFound(type, DecodingError.Context(codingPath: self.decoder.codingPath + [_XMLKey(index: self.currentIndex)], debugDescription: "Unkeyed container is at end.")) -// } -// -// self.decoder.codingPath.append(_XMLKey(index: self.currentIndex)) -// defer { self.decoder.codingPath.removeLast() } -// -// guard let decoded = try self.decoder.unbox(self.container[self.currentIndex], as: UInt8.self) else { -// throw DecodingError.valueNotFound(type, DecodingError.Context(codingPath: self.decoder.codingPath + [_XMLKey(index: self.currentIndex)], debugDescription: "Expected \(type) but found null instead.")) -// } -// -// self.currentIndex += 1 -// return decoded -// } -// -// public mutating func decode(_ type: UInt16.Type) throws -> UInt16 { -// guard !self.isAtEnd else { -// throw DecodingError.valueNotFound(type, DecodingError.Context(codingPath: self.decoder.codingPath + [_XMLKey(index: self.currentIndex)], debugDescription: "Unkeyed container is at end.")) -// } -// -// self.decoder.codingPath.append(_XMLKey(index: self.currentIndex)) -// defer { self.decoder.codingPath.removeLast() } -// -// guard let decoded = try self.decoder.unbox(self.container[self.currentIndex], as: UInt16.self) else { -// throw DecodingError.valueNotFound(type, DecodingError.Context(codingPath: self.decoder.codingPath + [_XMLKey(index: self.currentIndex)], debugDescription: "Expected \(type) but found null instead.")) -// } -// -// self.currentIndex += 1 -// return decoded -// } -// -// public mutating func decode(_ type: UInt32.Type) throws -> UInt32 { -// guard !self.isAtEnd else { -// throw DecodingError.valueNotFound(type, DecodingError.Context(codingPath: self.decoder.codingPath + [_XMLKey(index: self.currentIndex)], debugDescription: "Unkeyed container is at end.")) -// } -// -// self.decoder.codingPath.append(_XMLKey(index: self.currentIndex)) -// defer { self.decoder.codingPath.removeLast() } -// -// guard let decoded = try self.decoder.unbox(self.container[self.currentIndex], as: UInt32.self) else { -// throw DecodingError.valueNotFound(type, DecodingError.Context(codingPath: self.decoder.codingPath + [_XMLKey(index: self.currentIndex)], debugDescription: "Expected \(type) but found null instead.")) -// } -// -// self.currentIndex += 1 -// return decoded -// } -// -// public mutating func decode(_ type: UInt64.Type) throws -> UInt64 { -// guard !self.isAtEnd else { -// throw DecodingError.valueNotFound(type, DecodingError.Context(codingPath: self.decoder.codingPath + [_XMLKey(index: self.currentIndex)], debugDescription: "Unkeyed container is at end.")) -// } -// -// self.decoder.codingPath.append(_XMLKey(index: self.currentIndex)) -// defer { self.decoder.codingPath.removeLast() } -// -// guard let decoded = try self.decoder.unbox(self.container[self.currentIndex], as: UInt64.self) else { -// throw DecodingError.valueNotFound(type, DecodingError.Context(codingPath: self.decoder.codingPath + [_XMLKey(index: self.currentIndex)], debugDescription: "Expected \(type) but found null instead.")) -// } -// -// self.currentIndex += 1 -// return decoded -// } -// -// public mutating func decode(_ type: Float.Type) throws -> Float { -// guard !self.isAtEnd else { -// throw DecodingError.valueNotFound(type, DecodingError.Context(codingPath: self.decoder.codingPath + [_XMLKey(index: self.currentIndex)], debugDescription: "Unkeyed container is at end.")) -// } -// -// self.decoder.codingPath.append(_XMLKey(index: self.currentIndex)) -// defer { self.decoder.codingPath.removeLast() } -// -// guard let decoded = try self.decoder.unbox(self.container[self.currentIndex], as: Float.self) else { -// throw DecodingError.valueNotFound(type, DecodingError.Context(codingPath: self.decoder.codingPath + [_XMLKey(index: self.currentIndex)], debugDescription: "Expected \(type) but found null instead.")) -// } -// -// self.currentIndex += 1 -// return decoded -// } -// -// public mutating func decode(_ type: Double.Type) throws -> Double { -// guard !self.isAtEnd else { -// throw DecodingError.valueNotFound(type, DecodingError.Context(codingPath: self.decoder.codingPath + [_XMLKey(index: self.currentIndex)], debugDescription: "Unkeyed container is at end.")) -// } -// -// self.decoder.codingPath.append(_XMLKey(index: self.currentIndex)) -// defer { self.decoder.codingPath.removeLast() } -// -// guard let decoded = try self.decoder.unbox(self.container[self.currentIndex], as: Double.self) else { -// throw DecodingError.valueNotFound(type, DecodingError.Context(codingPath: self.decoder.codingPath + [_XMLKey(index: self.currentIndex)], debugDescription: "Expected \(type) but found null instead.")) -// } -// -// self.currentIndex += 1 -// return decoded -// } -// -// public mutating func decode(_ type: String.Type) throws -> String { -// guard !self.isAtEnd else { -// throw DecodingError.valueNotFound(type, DecodingError.Context(codingPath: self.decoder.codingPath + [_XMLKey(index: self.currentIndex)], debugDescription: "Unkeyed container is at end.")) -// } -// -// self.decoder.codingPath.append(_XMLKey(index: self.currentIndex)) -// defer { self.decoder.codingPath.removeLast() } -// -// guard let decoded = try self.decoder.unbox(self.container[self.currentIndex], as: String.self) else { -// throw DecodingError.valueNotFound(type, DecodingError.Context(codingPath: self.decoder.codingPath + [_XMLKey(index: self.currentIndex)], debugDescription: "Expected \(type) but found null instead.")) -// } -// -// self.currentIndex += 1 -// return decoded -// } -// -// public mutating func decode(_ type: T.Type) throws -> T { -// guard !self.isAtEnd else { -// throw DecodingError.valueNotFound(type, DecodingError.Context(codingPath: self.decoder.codingPath + [_XMLKey(index: self.currentIndex)], debugDescription: "Unkeyed container is at end.")) -// } -// -// self.decoder.codingPath.append(_XMLKey(index: self.currentIndex)) -// defer { self.decoder.codingPath.removeLast() } -// -// guard let decoded = try self.decoder.unbox(self.container[self.currentIndex], as: type) else { -// throw DecodingError.valueNotFound(type, DecodingError.Context(codingPath: self.decoder.codingPath + [_XMLKey(index: self.currentIndex)], debugDescription: "Expected \(type) but found null instead.")) -// } -// -// self.currentIndex += 1 -// return decoded -// } -// -// public mutating func nestedContainer(keyedBy type: NestedKey.Type) throws -> KeyedDecodingContainer { -// self.decoder.codingPath.append(_XMLKey(index: self.currentIndex)) -// defer { self.decoder.codingPath.removeLast() } -// -// guard !self.isAtEnd else { -// throw DecodingError.valueNotFound(KeyedDecodingContainer.self, -// DecodingError.Context(codingPath: self.codingPath, -// debugDescription: "Cannot get nested keyed container -- unkeyed container is at end.")) -// } -// -// let value = self.container[self.currentIndex] -// guard !(value is NSNull) else { -// throw DecodingError.valueNotFound(KeyedDecodingContainer.self, -// DecodingError.Context(codingPath: self.codingPath, -// debugDescription: "Cannot get keyed decoding container -- found null value instead.")) -// } -// -// guard let dictionary = value as? [String : Any] else { -// throw DecodingError._typeMismatch(at: self.codingPath, expectation: [String : Any].self, reality: value) -// } -// -// self.currentIndex += 1 -// let container = _XMLKeyedDecodingContainer(referencing: self.decoder, wrapping: dictionary) -// return KeyedDecodingContainer(container) -// } -// -// public mutating func nestedUnkeyedContainer() throws -> UnkeyedDecodingContainer { -// self.decoder.codingPath.append(_XMLKey(index: self.currentIndex)) -// defer { self.decoder.codingPath.removeLast() } -// -// guard !self.isAtEnd else { -// throw DecodingError.valueNotFound(UnkeyedDecodingContainer.self, -// DecodingError.Context(codingPath: self.codingPath, -// debugDescription: "Cannot get nested keyed container -- unkeyed container is at end.")) -// } -// -// let value = self.container[self.currentIndex] -// guard !(value is NSNull) else { -// throw DecodingError.valueNotFound(UnkeyedDecodingContainer.self, -// DecodingError.Context(codingPath: self.codingPath, -// debugDescription: "Cannot get keyed decoding container -- found null value instead.")) -// } -// -// guard let array = value as? [Any] else { -// throw DecodingError._typeMismatch(at: self.codingPath, expectation: [Any].self, reality: value) -// } -// -// self.currentIndex += 1 -// return _XMLUnkeyedDecodingContainer(referencing: self.decoder, wrapping: array) -// } -// -// public mutating func superDecoder() throws -> Decoder { -// self.decoder.codingPath.append(_XMLKey(index: self.currentIndex)) -// defer { self.decoder.codingPath.removeLast() } -// -// guard !self.isAtEnd else { -// throw DecodingError.valueNotFound(Decoder.self, -// DecodingError.Context(codingPath: self.codingPath, -// debugDescription: "Cannot get superDecoder() -- unkeyed container is at end.")) -// } -// -// let value = self.container[self.currentIndex] -// self.currentIndex += 1 -// return _XMLDecoder(referencing: value, at: self.decoder.codingPath, options: self.decoder.options) -// } -//} -// -//extension _XMLDecoder : SingleValueDecodingContainer { -// // MARK: SingleValueDecodingContainer Methods -// -// private func expectNonNull(_ type: T.Type) throws { -// guard !self.decodeNil() else { -// throw DecodingError.valueNotFound(type, DecodingError.Context(codingPath: self.codingPath, debugDescription: "Expected \(type) but found null value instead.")) -// } -// } -// -// public func decodeNil() -> Bool { -// return self.storage.topContainer is NSNull -// } -// -// public func decode(_ type: Bool.Type) throws -> Bool { -// try expectNonNull(Bool.self) -// return try self.unbox(self.storage.topContainer, as: Bool.self)! -// } -// -// public func decode(_ type: Int.Type) throws -> Int { -// try expectNonNull(Int.self) -// return try self.unbox(self.storage.topContainer, as: Int.self)! -// } -// -// public func decode(_ type: Int8.Type) throws -> Int8 { -// try expectNonNull(Int8.self) -// return try self.unbox(self.storage.topContainer, as: Int8.self)! -// } -// -// public func decode(_ type: Int16.Type) throws -> Int16 { -// try expectNonNull(Int16.self) -// return try self.unbox(self.storage.topContainer, as: Int16.self)! -// } -// -// public func decode(_ type: Int32.Type) throws -> Int32 { -// try expectNonNull(Int32.self) -// return try self.unbox(self.storage.topContainer, as: Int32.self)! -// } -// -// public func decode(_ type: Int64.Type) throws -> Int64 { -// try expectNonNull(Int64.self) -// return try self.unbox(self.storage.topContainer, as: Int64.self)! -// } -// -// public func decode(_ type: UInt.Type) throws -> UInt { -// try expectNonNull(UInt.self) -// return try self.unbox(self.storage.topContainer, as: UInt.self)! -// } -// -// public func decode(_ type: UInt8.Type) throws -> UInt8 { -// try expectNonNull(UInt8.self) -// return try self.unbox(self.storage.topContainer, as: UInt8.self)! -// } -// -// public func decode(_ type: UInt16.Type) throws -> UInt16 { -// try expectNonNull(UInt16.self) -// return try self.unbox(self.storage.topContainer, as: UInt16.self)! -// } -// -// public func decode(_ type: UInt32.Type) throws -> UInt32 { -// try expectNonNull(UInt32.self) -// return try self.unbox(self.storage.topContainer, as: UInt32.self)! -// } -// -// public func decode(_ type: UInt64.Type) throws -> UInt64 { -// try expectNonNull(UInt64.self) -// return try self.unbox(self.storage.topContainer, as: UInt64.self)! -// } -// -// public func decode(_ type: Float.Type) throws -> Float { -// try expectNonNull(Float.self) -// return try self.unbox(self.storage.topContainer, as: Float.self)! -// } -// -// public func decode(_ type: Double.Type) throws -> Double { -// try expectNonNull(Double.self) -// return try self.unbox(self.storage.topContainer, as: Double.self)! -// } -// -// public func decode(_ type: String.Type) throws -> String { -// try expectNonNull(String.self) -// return try self.unbox(self.storage.topContainer, as: String.self)! -// } -// -// public func decode(_ type: T.Type) throws -> T { -// try expectNonNull(type) -// return try self.unbox(self.storage.topContainer, as: type)! -// } -//} -// -//// MARK: - Concrete Value Representations -// -//extension _XMLDecoder { -// /// Returns the given value unboxed from a container. -// fileprivate func unbox(_ value: String?, as type: Bool.Type) throws -> Bool? { -// guard let value = value else { return nil } -// -// if value == "true" || value == "1" { -// return true -// } else if value == "false" || value == "0" { -// return false -// } -// -// throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: value) -// } -// -// fileprivate func unbox(_ value: String?, as type: Int.Type) throws -> Int? { -// guard let string = value else { return nil } -// -// guard let value = Float(string) else { -// throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: string) -// } -// -// let number = NSNumber(value: value) -// -// guard number !== kCFBooleanTrue, number !== kCFBooleanFalse else { -// throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: string) -// } -// -// let int = number.intValue -// guard NSNumber(value: int) == number else { -// throw DecodingError.dataCorrupted(DecodingError.Context(codingPath: self.codingPath, debugDescription: "Parsed JSON number <\(number)> does not fit in \(type).")) -// } -// -// return int -// } -// -// fileprivate func unbox(_ value: String?, as type: Int16.Type) throws -> Int16? { -// guard let string = value else { return nil } -// -// guard let value = Float(string) else { -// throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: string) -// } -// -// let number = NSNumber(value: value) -// -// guard number !== kCFBooleanTrue, number !== kCFBooleanFalse else { -// throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: string) -// } -// -// let int16 = number.int16Value -// guard NSNumber(value: int16) == number else { -// throw DecodingError.dataCorrupted(DecodingError.Context(codingPath: self.codingPath, debugDescription: "Parsed JSON number <\(number)> does not fit in \(type).")) -// } -// -// return int16 -// } -// -// fileprivate func unbox(_ value: String?, as type: Int32.Type) throws -> Int32? { -// guard let string = value else { return nil } -// -// guard let value = Float(string) else { -// throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: string) -// } -// -// let number = NSNumber(value: value) -// -// guard number !== kCFBooleanTrue, number !== kCFBooleanFalse else { -// throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: string) -// } -// -// let int32 = number.int32Value -// guard NSNumber(value: int32) == number else { -// throw DecodingError.dataCorrupted(DecodingError.Context(codingPath: self.codingPath, debugDescription: "Parsed JSON number <\(number)> does not fit in \(type).")) -// } -// -// return int32 -// } -// -// fileprivate func unbox(_ value: String?, as type: Int64.Type) throws -> Int64? { -// guard let string = value else { return nil } -// -// guard let value = Float(string) else { -// throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: string) -// } -// -// let number = NSNumber(value: value) -// -// guard number !== kCFBooleanTrue, number !== kCFBooleanFalse else { -// throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: string) -// } -// -// let int64 = number.int64Value -// guard NSNumber(value: int64) == number else { -// throw DecodingError.dataCorrupted(DecodingError.Context(codingPath: self.codingPath, debugDescription: "Parsed JSON number <\(number)> does not fit in \(type).")) -// } -// -// return int64 -// } -// -// fileprivate func unbox(_ value: String?, as type: UInt.Type) throws -> UInt? { -// guard let string = value else { return nil } -// -// guard let value = Float(string) else { -// throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: string) -// } -// -// let number = NSNumber(value: value) -// -// guard number !== kCFBooleanTrue, number !== kCFBooleanFalse else { -// throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: string) -// } -// -// let uint = number.uintValue -// guard NSNumber(value: uint) == number else { -// throw DecodingError.dataCorrupted(DecodingError.Context(codingPath: self.codingPath, debugDescription: "Parsed JSON number <\(number)> does not fit in \(type).")) -// } -// -// return uint -// } -// -// fileprivate func unbox(_ value: String?, as type: UInt8.Type) throws -> UInt8? { -// guard let string = value else { return nil } -// -// guard let value = Float(string) else { -// throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: string) -// } -// -// let number = NSNumber(value: value) -// -// guard number !== kCFBooleanTrue, number !== kCFBooleanFalse else { -// throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: string) -// } -// -// let uint8 = number.uint8Value -// guard NSNumber(value: uint8) == number else { -// throw DecodingError.dataCorrupted(DecodingError.Context(codingPath: self.codingPath, debugDescription: "Parsed JSON number <\(number)> does not fit in \(type).")) -// } -// -// return uint8 -// } -// -// fileprivate func unbox(_ value: String?, as type: UInt16.Type) throws -> UInt16? { -// guard let string = value else { return nil } -// -// guard let value = Float(string) else { -// throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: string) -// } -// -// let number = NSNumber(value: value) -// -// guard number !== kCFBooleanTrue, number !== kCFBooleanFalse else { -// throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: string) -// } -// -// let uint16 = number.uint16Value -// guard NSNumber(value: uint16) == number else { -// throw DecodingError.dataCorrupted(DecodingError.Context(codingPath: self.codingPath, debugDescription: "Parsed JSON number <\(number)> does not fit in \(type).")) -// } -// -// return uint16 -// } -// -// fileprivate func unbox(_ value: String?, as type: UInt32.Type) throws -> UInt32? { -// guard let string = value else { return nil } -// -// guard let value = Float(string) else { -// throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: string) -// } -// -// let number = NSNumber(value: value) -// -// guard number !== kCFBooleanTrue, number !== kCFBooleanFalse else { -// throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: string) -// } -// -// let uint32 = number.uint32Value -// guard NSNumber(value: uint32) == number else { -// throw DecodingError.dataCorrupted(DecodingError.Context(codingPath: self.codingPath, debugDescription: "Parsed JSON number <\(number)> does not fit in \(type).")) -// } -// -// return uint32 -// } -// -// fileprivate func unbox(_ value: String?, as type: UInt64.Type) throws -> UInt64? { -// guard let string = value else { return nil } -// -// guard let value = Float(string) else { -// throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: string) -// } -// -// let number = NSNumber(value: value) -// -// guard number !== kCFBooleanTrue, number !== kCFBooleanFalse else { -// throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: string) -// } -// -// let uint64 = number.uint64Value -// guard NSNumber(value: uint64) == number else { -// throw DecodingError.dataCorrupted(DecodingError.Context(codingPath: self.codingPath, debugDescription: "Parsed JSON number <\(number)> does not fit in \(type).")) -// } -// -// return uint64 -// } -// -// fileprivate func unbox(_ value: String?, as type: Float.Type) throws -> Float? { -// guard let string = value else { return nil } -// -// if let value = Double(string) { -// let number = NSNumber(value: value) -// -// guard number !== kCFBooleanTrue, number !== kCFBooleanFalse else { -// throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: string) -// } -// -// let double = number.doubleValue -// guard abs(double) <= Double(Float.greatestFiniteMagnitude) else { -// throw DecodingError.dataCorrupted(DecodingError.Context(codingPath: self.codingPath, debugDescription: "Parsed JSON number \(number) does not fit in \(type).")) -// } -// -// return Float(double) -// } else if case let .convertFromString(posInfString, negInfString, nanString) = self.options.nonConformingFloatDecodingStrategy { -// if string == posInfString { -// return Float.infinity -// } else if string == negInfString { -// return -Float.infinity -// } else if string == nanString { -// return Float.nan -// } -// } -// -// throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: string) -// } -// -// fileprivate func unbox(_ value: String?, as type: Double.Type) throws -> Double? { -// guard let string = value else { return nil } -// -// if let number = Decimal(string: string) as NSDecimalNumber? { -// -// guard number !== kCFBooleanTrue, number !== kCFBooleanFalse else { -// throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: string) -// } -// -// let double = number.doubleValue -// -// guard NSNumber(value: double) == number else { -// throw DecodingError.dataCorrupted(DecodingError.Context(codingPath: self.codingPath, debugDescription: "Parsed JSON number <\(number)> does not fit in \(type).")) -// } -// -// return double -// } else if case let .convertFromString(posInfString, negInfString, nanString) = self.options.nonConformingFloatDecodingStrategy { -// if string == posInfString { -// return Double.infinity -// } else if string == negInfString { -// return -Double.infinity -// } else if string == nanString { -// return Double.nan -// } -// } -// -// throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: string) -// } -// -// fileprivate func unbox(_ value: String?, as type: Date.Type) throws -> Date? { -// guard let string = value else { return nil } -// -// switch self.options.dateDecodingStrategy { -// case .deferredToDate: -// self.storage.temporaryValue = value -// let date = try Date(from: self) -// self.storage.temporaryValue = nil -// return date -// -// case .secondsSince1970: -// let double = try self.unbox(value, as: Double.self)! -// return Date(timeIntervalSince1970: double) -// -// case .millisecondsSince1970: -// let double = try self.unbox(value, as: Double.self)! -// return Date(timeIntervalSince1970: double / 1000.0) -// -// case .iso8601: -// guard let date = _iso8601Formatter.date(from: string) else { -// throw DecodingError.dataCorrupted(DecodingError.Context(codingPath: self.codingPath, debugDescription: "Expected date string to be ISO8601-formatted.")) -// } -// -// return date -// -// case .formatted(let formatter): -// guard let date = formatter.date(from: string) else { -// throw DecodingError.dataCorrupted(DecodingError.Context(codingPath: self.codingPath, debugDescription: "Date string does not match format expected by formatter.")) -// } -// -// return date -// -// case .custom(let closure): -// self.storage.temporaryValue = value -// let date = try closure(self) -// self.storage.temporaryValue = nil -// return date -// } -// } -// -// fileprivate func unbox(_ value: String?, as type: Data.Type) throws -> Data? { -// guard let string = value else { return nil } -// -// switch self.options.dataDecodingStrategy { -// case .deferredToData: -// self.storage.temporaryValue = value -// let data = try Data(from: self) -// self.storage.temporaryValue = nil -// return data -// -// case .base64: -// guard let data = Data(base64Encoded: string) else { -// throw DecodingError.dataCorrupted(DecodingError.Context(codingPath: self.codingPath, debugDescription: "Encountered Data is not valid Base64.")) -// } -// -// return data -// case .custom(let closure): -// self.storage.temporaryValue = value -// let data = try closure(self) -// self.storage.temporaryValue = nil -// return data -// } -// } -// -// fileprivate func unbox(_ value: String?, as type: Decimal.Type) throws -> Decimal? { -// guard let string = value else { return nil } -// -// return Decimal(string: string) -// } -// -// fileprivate func unbox(_ value: Any, as type: T.Type) throws -> T? { -// let decoded: T? -// -// if type == Date.self || type == NSDate.self { -// guard let date = try self.unbox(value, as: Date.self) else { return nil } -// decoded = date as? T -// } else if type == Data.self || type == NSData.self { -// guard let data = try self.unbox(value, as: Data.self) else { return nil } -// decoded = data as? T -// } else if type == URL.self || type == NSURL.self { -// guard let urlString = try self.unbox(value, as: String.self) else { -// return nil -// } -// -// guard let url = URL(string: urlString) else { -// throw DecodingError.dataCorrupted(DecodingError.Context(codingPath: self.codingPath, -// debugDescription: "Invalid URL string.")) -// } -// -// decoded = (url as! T) -// } else if type == Decimal.self || type == NSDecimalNumber.self { -// guard let decimal = try self.unbox(value, as: Decimal.self) else { return nil } -// decoded = decimal as? T -// } else { -// self.storage.temporaryValue = value -// decoded = try type.init(from: self) -// self.storage.temporaryValue = nil -// } -// -// return decoded -// } -//} -// -////===----------------------------------------------------------------------===// -//// Shared Key Types -////===----------------------------------------------------------------------===// -// -//fileprivate struct _XMLKey : CodingKey { -// public var stringValue: String -// public var intValue: Int? -// -// public init?(stringValue: String) { -// self.stringValue = stringValue -// self.intValue = nil -// } -// -// public init?(intValue: Int) { -// self.stringValue = "\(intValue)" -// self.intValue = intValue -// } -// -// fileprivate init(index: Int) { -// self.stringValue = "Index \(index)" -// self.intValue = index -// } -// -// fileprivate static let `super` = _XMLKey(stringValue: "super")! -//} -// -////===----------------------------------------------------------------------===// -//// Shared ISO8601 Date Formatter -////===----------------------------------------------------------------------===// -// -//// NOTE: This value is implicitly lazy and _must_ be lazy. We're compiled against the latest SDK (w/ ISO8601DateFormatter), but linked against whichever Foundation the user has. ISO8601DateFormatter might not exist, so we better not hit this code path on an older OS. -//@available(OSX 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) -//fileprivate var _iso8601Formatter: ISO8601DateFormatter = { -// let formatter = ISO8601DateFormatter() -// formatter.formatOptions = .withInternetDateTime -// return formatter -//}() -// -////===----------------------------------------------------------------------===// -//// Error Utilities -////===----------------------------------------------------------------------===// -// -//fileprivate extension DecodingError { -// /// Returns a `.typeMismatch` error describing the expected type. -// /// -// /// - parameter path: The path of `CodingKey`s taken to decode a value of this type. -// /// - parameter expectation: The type expected to be encountered. -// /// - parameter reality: The value that was encountered instead of the expected type. -// /// - returns: A `DecodingError` with the appropriate path and debug description. -// fileprivate static func _typeMismatch(at path: [CodingKey], expectation: Any.Type, reality: Any) -> DecodingError { -// let description = "Expected to decode \(expectation) but found \(_typeDescription(of: reality)) instead." -// return .typeMismatch(expectation, Context(codingPath: path, debugDescription: description)) -// } -// -// /// Returns a description of the type of `value` appropriate for an error message. -// /// -// /// - parameter value: The value whose type to describe. -// /// - returns: A string describing `value`. -// /// - precondition: `value` is one of the types below. -// fileprivate static func _typeDescription(of value: Any) -> String { -// if value is NSNull { -// return "a null value" -// } else if value is NSNumber /* FIXME: If swift-corelibs-foundation isn't updated to use NSNumber, this check will be necessary: || value is Int || value is Double */ { -// return "a number" -// } else if value is String { -// return "a string/data" -// } else if value is [Any] { -// return "an array" -// } else if value is [String : Any] { -// return "a dictionary" -// } else { -// return "\(type(of: value))" -// } -// } -//} -// -////===----------------------------------------------------------------------===// -//// Data Representation -////===----------------------------------------------------------------------===// -// -//fileprivate class _XMLNode { -// var name = "" -// var content: String? -// var properties = [String:[_XMLNode]]() -// var attributes = [String:String]() -// -// var propertyKeys: [String] { -// return Array(properties.keys) -// } -// -// var attributeKeys: [String] { -// return Array(attributes.keys) -// } -// -// var allKeys: [String] { -// return propertyKeys + attributeKeys -// } -//} -// -//fileprivate class _XMLStackParser: NSObject, XMLParserDelegate { -// var root: _XMLNode? -// var stack = [_XMLNode]() -// var currentNode: _XMLNode? -// -// var currentElementName: String? -// var currentElementData = "" -// -// func parse(with data: Data) throws -> _XMLNode? { -// let xmlParser = XMLParser(data: data) -// xmlParser.delegate = self -// -// if xmlParser.parse() { -// return root -// } else if let error = xmlParser.parserError { -// throw error -// } else { -// return nil -// } -// } -// -// func parserDidStartDocument(_ parser: XMLParser) { -// root = nil -// stack = [_XMLNode]() -// } -// -// func parser(_ parser: XMLParser, didStartElement elementName: String, namespaceURI: String?, qualifiedName qName: String?, attributes attributeDict: [String : String] = [:]) { -// let node = _XMLNode() -// node.name = elementName -// node.attributes = attributeDict -// stack.append(node) -// -// if let currentNode = currentNode { -// if currentNode.properties[elementName] != nil { -// currentNode.properties[elementName]?.append(node) -// } else { -// currentNode.properties[elementName] = [node] -// } -// } -// currentNode = node -// } -// -// func parser(_ parser: XMLParser, didEndElement elementName: String, namespaceURI: String?, qualifiedName qName: String?) { -// if let poppedNode = stack.popLast(){ -// if let content = poppedNode.content?.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) { -// poppedNode.content = content -// } -// -// if (stack.isEmpty) { -// root = poppedNode -// currentNode = nil -// } else { -// currentNode = stack.last -// } -// } -// } -// -// func parser(_ parser: XMLParser, foundCharacters string: String) { -// currentNode?.content = (currentNode?.content ?? "") + string -// } -// -// func parser(_ parser: XMLParser, foundCDATA CDATABlock: Data) { -// if let string = String(data: CDATABlock, encoding: .utf8) { -// currentNode?.content = (currentNode?.content ?? "") + string -// } -// } -// -// func parser(_ parser: XMLParser, parseErrorOccurred parseError: Error) { -// print(parseError) -// } -//} -// -// diff --git a/XMLParsing/ViewController.swift b/XMLParsing/ViewController.swift deleted file mode 100644 index f4929b9..0000000 --- a/XMLParsing/ViewController.swift +++ /dev/null @@ -1,63 +0,0 @@ -// -// ViewController.swift -// XMLParsing -// -// Created by Shawn Moore on 11/15/17. -// Copyright © 2017 Shawn Moore. All rights reserved. -// - -import UIKit - -class ViewController: UIViewController { - - override func viewDidLoad() { - super.viewDidLoad() - // Do any additional setup after loading the view, typically from a nib. - - let person = Person(Name: "Shawn Moore", social: []) - - let encoder = XMLEncoder() - - var result: Data? - - do { - result = try encoder.encode(person, withRootKey: "person") - - print("XML: \(String(data: result!, encoding: .utf8))") - } catch { - print(error) - } - - guard let data = result else { return } - - var newPerson: Person? - - let decoder = XMLDecoder() - - do { - newPerson = try decoder.decode(Person.self, from: data) - - print("Success") - } catch { - print(error) - } - } - - override func didReceiveMemoryWarning() { - super.didReceiveMemoryWarning() - // Dispose of any resources that can be recreated. - } - -} - -struct Person: Codable { - var Name: String - var social: [SocialSecurity]? -} - -struct SocialSecurity: Codable { - var number: String -} - - -