Skip to content

Commit

Permalink
refactor: break out into even more files
Browse files Browse the repository at this point in the history
  • Loading branch information
drmohundro committed May 3, 2022
1 parent 9ee0729 commit 41df641
Show file tree
Hide file tree
Showing 8 changed files with 757 additions and 551 deletions.
60 changes: 60 additions & 0 deletions SWXMLHash.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,30 @@
54B83CC61C849D9B00D588B5 /* XMLIndexer+XMLIndexerDeserializable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 54B83CC41C849D9B00D588B5 /* XMLIndexer+XMLIndexerDeserializable.swift */; };
54B83CC71C849D9B00D588B5 /* XMLIndexer+XMLIndexerDeserializable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 54B83CC41C849D9B00D588B5 /* XMLIndexer+XMLIndexerDeserializable.swift */; };
54B83CC81C849D9B00D588B5 /* XMLIndexer+XMLIndexerDeserializable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 54B83CC41C849D9B00D588B5 /* XMLIndexer+XMLIndexerDeserializable.swift */; };
5AF0E03C7AC0B144A711143C /* XMLElement.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5AF0E09CA8C0AAEABBD56BB4 /* XMLElement.swift */; };
5AF0E228F0D4FD1B85A66B5E /* XMLContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5AF0EADFD21AC848F6BECA1D /* XMLContent.swift */; };
5AF0E2C961494B70E578CFF2 /* XMLContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5AF0EADFD21AC848F6BECA1D /* XMLContent.swift */; };
5AF0E2DFC1636E975797A394 /* XMLAttribute.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5AF0EF51D084FE1024D1CE0D /* XMLAttribute.swift */; };
5AF0E2F3CA5A347BBE64EDC5 /* TextElement.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5AF0E710E1B7BA748FBC986B /* TextElement.swift */; };
5AF0E3BD03782E18AA13F24A /* TextElement.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5AF0E710E1B7BA748FBC986B /* TextElement.swift */; };
5AF0E4FBCBF97B710D484E96 /* String+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5AF0ECA326E0FDA144CE093F /* String+Extensions.swift */; };
5AF0E509C3E12F83B1E8D2B3 /* XMLContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5AF0EADFD21AC848F6BECA1D /* XMLContent.swift */; };
5AF0E51E7FB4BC99D267F72F /* String+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5AF0ECA326E0FDA144CE093F /* String+Extensions.swift */; };
5AF0E5270F4914C039407BD0 /* XMLElement.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5AF0E09CA8C0AAEABBD56BB4 /* XMLElement.swift */; };
5AF0E586635337278611A179 /* XMLIndexer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5AF0ECC2B709D6BF9A68F3D1 /* XMLIndexer.swift */; };
5AF0E6E95E6DE770F0383CF4 /* XMLIndexer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5AF0ECC2B709D6BF9A68F3D1 /* XMLIndexer.swift */; };
5AF0E72422B26DCA16716C20 /* XMLAttribute.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5AF0EF51D084FE1024D1CE0D /* XMLAttribute.swift */; };
5AF0E83E20CB0E145957F255 /* String+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5AF0ECA326E0FDA144CE093F /* String+Extensions.swift */; };
5AF0E848394370F0E94BF9A0 /* XMLContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5AF0EADFD21AC848F6BECA1D /* XMLContent.swift */; };
5AF0E9F306850236785A4512 /* XMLIndexer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5AF0ECC2B709D6BF9A68F3D1 /* XMLIndexer.swift */; };
5AF0EA10D807D39E5A877DCA /* TextElement.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5AF0E710E1B7BA748FBC986B /* TextElement.swift */; };
5AF0EA56B730695C216E4571 /* XMLIndexer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5AF0ECC2B709D6BF9A68F3D1 /* XMLIndexer.swift */; };
5AF0EAD8FF3226490385B398 /* XMLAttribute.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5AF0EF51D084FE1024D1CE0D /* XMLAttribute.swift */; };
5AF0EBE38E3E25CE4A5276E7 /* XMLElement.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5AF0E09CA8C0AAEABBD56BB4 /* XMLElement.swift */; };
5AF0ED095AF755874AD7EBFF /* XMLAttribute.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5AF0EF51D084FE1024D1CE0D /* XMLAttribute.swift */; };
5AF0ED9738E0194A03FE6D4C /* TextElement.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5AF0E710E1B7BA748FBC986B /* TextElement.swift */; };
5AF0EE0166578A68DEB25C84 /* XMLElement.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5AF0E09CA8C0AAEABBD56BB4 /* XMLElement.swift */; };
5AF0EEA3155F6F08B3F3DB71 /* String+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5AF0ECA326E0FDA144CE093F /* String+Extensions.swift */; };
6317F1A6282179E200F6C364 /* Float+XMLDeserialization.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6317F1A5282179E200F6C364 /* Float+XMLDeserialization.swift */; };
6317F1A7282179E200F6C364 /* Float+XMLDeserialization.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6317F1A5282179E200F6C364 /* Float+XMLDeserialization.swift */; };
6317F1A8282179E200F6C364 /* Float+XMLDeserialization.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6317F1A5282179E200F6C364 /* Float+XMLDeserialization.swift */; };
Expand Down Expand Up @@ -194,6 +218,12 @@

/* Begin PBXFileReference section */
54B83CC41C849D9B00D588B5 /* XMLIndexer+XMLIndexerDeserializable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "XMLIndexer+XMLIndexerDeserializable.swift"; sourceTree = "<group>"; };
5AF0E09CA8C0AAEABBD56BB4 /* XMLElement.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = XMLElement.swift; sourceTree = "<group>"; };
5AF0E710E1B7BA748FBC986B /* TextElement.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextElement.swift; sourceTree = "<group>"; };
5AF0EADFD21AC848F6BECA1D /* XMLContent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = XMLContent.swift; sourceTree = "<group>"; };
5AF0ECA326E0FDA144CE093F /* String+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "String+Extensions.swift"; sourceTree = "<group>"; };
5AF0ECC2B709D6BF9A68F3D1 /* XMLIndexer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = XMLIndexer.swift; sourceTree = "<group>"; };
5AF0EF51D084FE1024D1CE0D /* XMLAttribute.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = XMLAttribute.swift; sourceTree = "<group>"; };
6317F1A5282179E200F6C364 /* Float+XMLDeserialization.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Float+XMLDeserialization.swift"; sourceTree = "<group>"; };
63ED3C002821A723006A8A08 /* String+XMLDeserialization.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "String+XMLDeserialization.swift"; sourceTree = "<group>"; };
63ED3C012821A723006A8A08 /* XMLDeserialization.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = XMLDeserialization.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -376,6 +406,12 @@
CD6083F4196CA106000B4F8D /* SWXMLHash.h */,
CD60840B196CA11D000B4F8D /* XMLHash.swift */,
63ED3C282821AF4D006A8A08 /* XMLHashOptions.swift */,
5AF0EADFD21AC848F6BECA1D /* XMLContent.swift */,
5AF0E710E1B7BA748FBC986B /* TextElement.swift */,
5AF0EF51D084FE1024D1CE0D /* XMLAttribute.swift */,
5AF0E09CA8C0AAEABBD56BB4 /* XMLElement.swift */,
5AF0ECA326E0FDA144CE093F /* String+Extensions.swift */,
5AF0ECC2B709D6BF9A68F3D1 /* XMLIndexer.swift */,
);
path = Source;
sourceTree = "<group>";
Expand Down Expand Up @@ -749,6 +785,12 @@
63ED3C6A2821D247006A8A08 /* Stack.swift in Sources */,
63ED3C5E2821D247006A8A08 /* IndexOp.swift in Sources */,
63ED3C6F2821D311006A8A08 /* ParsingError.swift in Sources */,
5AF0E848394370F0E94BF9A0 /* XMLContent.swift in Sources */,
5AF0E2F3CA5A347BBE64EDC5 /* TextElement.swift in Sources */,
5AF0E2DFC1636E975797A394 /* XMLAttribute.swift in Sources */,
5AF0EBE38E3E25CE4A5276E7 /* XMLElement.swift in Sources */,
5AF0E83E20CB0E145957F255 /* String+Extensions.swift in Sources */,
5AF0E9F306850236785A4512 /* XMLIndexer.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -796,6 +838,12 @@
63ED3C6B2821D247006A8A08 /* Stack.swift in Sources */,
63ED3C5F2821D247006A8A08 /* IndexOp.swift in Sources */,
63ED3C702821D311006A8A08 /* ParsingError.swift in Sources */,
5AF0E228F0D4FD1B85A66B5E /* XMLContent.swift in Sources */,
5AF0E3BD03782E18AA13F24A /* TextElement.swift in Sources */,
5AF0E72422B26DCA16716C20 /* XMLAttribute.swift in Sources */,
5AF0EE0166578A68DEB25C84 /* XMLElement.swift in Sources */,
5AF0EEA3155F6F08B3F3DB71 /* String+Extensions.swift in Sources */,
5AF0EA56B730695C216E4571 /* XMLIndexer.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -843,6 +891,12 @@
63ED3C6C2821D247006A8A08 /* Stack.swift in Sources */,
63ED3C602821D247006A8A08 /* IndexOp.swift in Sources */,
63ED3C712821D311006A8A08 /* ParsingError.swift in Sources */,
5AF0E2C961494B70E578CFF2 /* XMLContent.swift in Sources */,
5AF0ED9738E0194A03FE6D4C /* TextElement.swift in Sources */,
5AF0EAD8FF3226490385B398 /* XMLAttribute.swift in Sources */,
5AF0E03C7AC0B144A711143C /* XMLElement.swift in Sources */,
5AF0E51E7FB4BC99D267F72F /* String+Extensions.swift in Sources */,
5AF0E6E95E6DE770F0383CF4 /* XMLIndexer.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -890,6 +944,12 @@
63ED3C6D2821D247006A8A08 /* Stack.swift in Sources */,
63ED3C612821D247006A8A08 /* IndexOp.swift in Sources */,
63ED3C722821D311006A8A08 /* ParsingError.swift in Sources */,
5AF0E509C3E12F83B1E8D2B3 /* XMLContent.swift in Sources */,
5AF0EA10D807D39E5A877DCA /* TextElement.swift in Sources */,
5AF0ED095AF755874AD7EBFF /* XMLAttribute.swift in Sources */,
5AF0E5270F4914C039407BD0 /* XMLElement.swift in Sources */,
5AF0E4FBCBF97B710D484E96 /* String+Extensions.swift in Sources */,
5AF0E586635337278611A179 /* XMLIndexer.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
39 changes: 39 additions & 0 deletions Source/String+Extensions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// String+Extensions.swift
// SWXMLHash
//
// Copyright (c) 2022 David Mohundro
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

import Foundation

internal extension String {
func compare(_ str2: String?, _ insensitive: Bool) -> Bool {
guard let str2 = str2 else {
return false
}
let str1 = self
if insensitive {
return str1.caseInsensitiveCompare(str2) == .orderedSame
}
return str1 == str2
}
}
43 changes: 43 additions & 0 deletions Source/TextElement.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//
// TextElement.swift
// SWXMLHash
//
// Copyright (c) 2022 David Mohundro
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

import Foundation

/// Models a text element
public class TextElement: XMLContent {
/// The underlying text value
public let text: String

init(text: String) {
self.text = text
}
}

extension TextElement: CustomStringConvertible {
/// The text value for a `TextElement` instance.
public var description: String {
text
}
}
43 changes: 43 additions & 0 deletions Source/XMLAttribute.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//
// XMLAttribute.swift
// SWXMLHash
//
// Copyright (c) 2022 David Mohundro
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

import Foundation

public struct XMLAttribute {
public let name: String
public let text: String

init(name: String, text: String) {
self.name = name
self.text = text
}
}

extension XMLAttribute: CustomStringConvertible {
/// The textual representation of an `XMLAttribute` instance.
public var description: String {
"\(name)=\"\(text)\""
}
}
29 changes: 29 additions & 0 deletions Source/XMLContent.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// XMLContent.swift
// SWXMLHash
//
// Copyright (c) 2014 David Mohundro
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

import Foundation

/// Models content for an XML doc, whether it is text or XML
public protocol XMLContent: CustomStringConvertible { }
Loading

0 comments on commit 41df641

Please sign in to comment.