-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: simple and attributegroup parsing
- Loading branch information
Showing
11 changed files
with
465 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// | ||
// Annotation.swift | ||
// PugiSwift | ||
// | ||
// Created by Amy on 01/11/2024. | ||
// | ||
import Foundation | ||
import PugiSwift | ||
|
||
@Node public struct Annotation { | ||
|
||
@Element(codingKey: "xs:documentation") public let documentation: String? | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// Attribute.swift | ||
// PugiSwift | ||
// | ||
// Created by Amy on 01/11/2024. | ||
// | ||
|
||
import Foundation | ||
import PugiSwift | ||
|
||
@Node public struct Attribute { | ||
|
||
@Attribute public let name: String | ||
|
||
@Attribute public let type: String | ||
|
||
@Attribute public let use: String? | ||
|
||
@Element(codingKey: "xs:annotation") public let annotation: Annotation? | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// | ||
// AttributeGroup.swift | ||
// PugiSwift | ||
// | ||
// Created by Amy on 01/11/2024. | ||
// | ||
|
||
import Foundation | ||
import PugiSwift | ||
|
||
@Node public struct AttributeGroup { | ||
|
||
@Attribute public let name: String | ||
|
||
@Element(childrenCodingKey: "xs:attribute") public let attributes: [Attribute]? | ||
|
||
@Element(codingKey: "xs:annotation") public let annotation: Annotation? | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// | ||
// BaseTypes.swift | ||
// PugiSwift | ||
// | ||
// Created by Amy on 01/11/2024. | ||
// | ||
|
||
import Foundation | ||
import PugiSwift | ||
|
||
@Node public enum BaseType: String { | ||
|
||
case string = "xs:string" | ||
|
||
case integer = "xs:integer" | ||
|
||
case unsignedInt = "xs:unsignedInt" | ||
|
||
case unsignedShort = "xs:unsignedShort" | ||
|
||
case short = "xs:short" | ||
|
||
case decimal = "xs:decimal" | ||
|
||
case boolean = "xs:boolean" | ||
|
||
case date = "xs:date" | ||
|
||
case time = "xs:time" | ||
|
||
case dateTime = "xs:dateTime" | ||
|
||
case anyURI = "xs:anyURI" | ||
|
||
public var rawType: XMLDecodable.Type { | ||
switch self { | ||
case .string: | ||
return String.self | ||
case .integer: | ||
return Int.self | ||
case .unsignedInt: | ||
return UInt32.self | ||
case .unsignedShort: | ||
return UInt16.self | ||
case .short: | ||
return Int16.self | ||
case .decimal: | ||
return Double.self | ||
case .boolean: | ||
return Bool.self | ||
case .date: | ||
return String.self | ||
case .time: | ||
return String.self | ||
case .dateTime: | ||
return String.self | ||
case .anyURI: | ||
return URL.self | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// Enumeration.swift | ||
// PugiSwift | ||
// | ||
// Created by Amy on 01/11/2024. | ||
// | ||
|
||
import Foundation | ||
import PugiSwift | ||
|
||
@Node public struct BasicType { | ||
|
||
@Attribute public let value: String | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// Restriction.swift | ||
// PugiSwift | ||
// | ||
// Created by Amy on 01/11/2024. | ||
// | ||
|
||
import Foundation | ||
import PugiSwift | ||
|
||
@Node public struct Restriction { | ||
|
||
@Attribute public var base: BaseType | ||
|
||
@Element(childrenCodingKey: "xs:enumeration") public let enumeration: [BasicType]? | ||
|
||
@Element(codingKey: "xs:length") public let length: BasicType? | ||
|
||
@Element(codingKey: "xs:maxExclusive") public let maxExclusive: BasicType? | ||
|
||
@Element(codingKey: "xs:maxInclusive") public let maxInclusive: BasicType? | ||
|
||
@Element(codingKey: "xs:maxLength") public let maxLength: BasicType? | ||
|
||
@Element(codingKey: "xs:minExclusive") public let minExclusive: BasicType? | ||
|
||
@Element(codingKey: "xs:minInclusive") public let minInclusive: BasicType? | ||
|
||
@Element(codingKey: "xs:minLength") public let minLength: BasicType? | ||
|
||
@Element(codingKey: "xs:pattern") public let pattern: BasicType? | ||
|
||
@Element(codingKey: "xs:totalDigits") public let totalDigits: BasicType? | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// Schema.swift | ||
// PugiSwift | ||
// | ||
// Created by Amy on 01/11/2024. | ||
// | ||
|
||
import Foundation | ||
import PugiSwift | ||
|
||
@Node public struct Schema { | ||
|
||
@Element(childrenCodingKey: "xs:simpleType") public let simpleTypes: [SimpleType] | ||
|
||
@Element(childrenCodingKey: "xs:attributeGroup") public let attributeGroups: [AttributeGroup] | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// SimpleType.swift | ||
// PugiSwift | ||
// | ||
// Created by Amy on 01/11/2024. | ||
// | ||
|
||
import Foundation | ||
import PugiSwift | ||
|
||
@Node public struct SimpleType { | ||
|
||
@Attribute public let name: String | ||
|
||
@Element(codingKey: "xs:annotation") public let annotation: Annotation? | ||
|
||
@Element(codingKey: "xs:restriction") public let restriction: Restriction | ||
|
||
} |
Oops, something went wrong.