Moved BindingGenerator from gen html project. It makes more sense here.
This commit is contained in:
269
Sources/BindingGenerator/Generated/Elements/Img.swift
Normal file
269
Sources/BindingGenerator/Generated/Elements/Img.swift
Normal file
@@ -0,0 +1,269 @@
|
||||
//
|
||||
// Img.swift
|
||||
// HTMLStandard
|
||||
//
|
||||
// Generated on 09/23/2025.
|
||||
// THIS FILE IS GENERATED. DO NOT EDIT.
|
||||
//
|
||||
import Foundation
|
||||
|
||||
/// <img> Image
|
||||
public class Img : HTMLNode, IEmbedded, IFlow, IFormAssociated, IInteractive, IPalpable, IPhrasing {
|
||||
|
||||
public enum Crossorigin : String, CaseIterable {
|
||||
|
||||
case anonymous
|
||||
case useCredentials = "use-credentials"
|
||||
|
||||
public init?(rawValue: Substring) {
|
||||
guard
|
||||
let value = Self.allCases.first(where: { $0.rawValue == rawValue })
|
||||
else
|
||||
{ return nil }
|
||||
|
||||
self = value
|
||||
}
|
||||
|
||||
public init(expect: Substring) throws {
|
||||
guard
|
||||
let value = Self.allCases.first(where: { $0.rawValue == expect })
|
||||
else
|
||||
{ throw AppError("Unexpected value for Crossorigin: \(expect)") }
|
||||
|
||||
self = value
|
||||
}
|
||||
|
||||
public init(expect: String) throws {
|
||||
guard let result = Crossorigin(rawValue: expect) else {
|
||||
throw AppError("Unexpected value for Crossorigin: \(expect)")
|
||||
}
|
||||
self = result
|
||||
}
|
||||
|
||||
static func parseList(_ value:String?, _ separator:String = " ") throws -> [Crossorigin] {
|
||||
guard let value = value else { return [] }
|
||||
var iterator = value.componentsIterator(separatedBy: separator)
|
||||
let result = try iterator.map { input in
|
||||
return try expect(Crossorigin(rawValue: input), "unexpected value for Crossorigin: \(input)")
|
||||
}
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
public enum Decoding : String, CaseIterable {
|
||||
|
||||
case async
|
||||
case auto
|
||||
case sync
|
||||
|
||||
public init?(rawValue: Substring) {
|
||||
guard
|
||||
let value = Self.allCases.first(where: { $0.rawValue == rawValue })
|
||||
else
|
||||
{ return nil }
|
||||
|
||||
self = value
|
||||
}
|
||||
|
||||
public init(expect: Substring) throws {
|
||||
guard
|
||||
let value = Self.allCases.first(where: { $0.rawValue == expect })
|
||||
else
|
||||
{ throw AppError("Unexpected value for Decoding: \(expect)") }
|
||||
|
||||
self = value
|
||||
}
|
||||
|
||||
public init(expect: String) throws {
|
||||
guard let result = Decoding(rawValue: expect) else {
|
||||
throw AppError("Unexpected value for Decoding: \(expect)")
|
||||
}
|
||||
self = result
|
||||
}
|
||||
|
||||
static func parseList(_ value:String?, _ separator:String = " ") throws -> [Decoding] {
|
||||
guard let value = value else { return [] }
|
||||
var iterator = value.componentsIterator(separatedBy: separator)
|
||||
let result = try iterator.map { input in
|
||||
return try expect(Decoding(rawValue: input), "unexpected value for Decoding: \(input)")
|
||||
}
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
public enum Loading : String, CaseIterable {
|
||||
|
||||
case eager
|
||||
case lazy
|
||||
|
||||
public init?(rawValue: Substring) {
|
||||
guard
|
||||
let value = Self.allCases.first(where: { $0.rawValue == rawValue })
|
||||
else
|
||||
{ return nil }
|
||||
|
||||
self = value
|
||||
}
|
||||
|
||||
public init(expect: Substring) throws {
|
||||
guard
|
||||
let value = Self.allCases.first(where: { $0.rawValue == expect })
|
||||
else
|
||||
{ throw AppError("Unexpected value for Loading: \(expect)") }
|
||||
|
||||
self = value
|
||||
}
|
||||
|
||||
public init(expect: String) throws {
|
||||
guard let result = Loading(rawValue: expect) else {
|
||||
throw AppError("Unexpected value for Loading: \(expect)")
|
||||
}
|
||||
self = result
|
||||
}
|
||||
|
||||
static func parseList(_ value:String?, _ separator:String = " ") throws -> [Loading] {
|
||||
guard let value = value else { return [] }
|
||||
var iterator = value.componentsIterator(separatedBy: separator)
|
||||
let result = try iterator.map { input in
|
||||
return try expect(Loading(rawValue: input), "unexpected value for Loading: \(input)")
|
||||
}
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
/// Replacement text for use when images are not available. Text. The actual rules are more complicated than indicated.
|
||||
public var alt:String? = nil
|
||||
|
||||
/// How the element handles crossorigin requests.
|
||||
public var crossorigin:Crossorigin? = nil
|
||||
|
||||
/// Decoding hint to use when processing this image for presentation.
|
||||
public var decoding:Decoding? = nil
|
||||
|
||||
/// Vertical dimension. Valid non-negative integer.
|
||||
public var height:UInt? = nil
|
||||
|
||||
/// Whether the image is a server-side image map.
|
||||
public var ismap:Bool = false
|
||||
|
||||
/// Used when determining loading deferral.
|
||||
public var loading:Loading? = nil
|
||||
|
||||
/// Referrer policy for fetches initiated by the element. Referrer policy.
|
||||
public var referrerpolicy:ReferrerPolicy? = nil
|
||||
|
||||
/// Image sizes for different page layouts. Valid source size list.
|
||||
public var sizes:[String] = []
|
||||
|
||||
/// Address of the resource. Valid non-empty URL potentially surrounded by spaces.
|
||||
public var src:URL? = nil
|
||||
|
||||
/// Images to use in different situations (e.g., high-resolution displays, small monitors, etc.). Comma-separated list of image candidate strings.
|
||||
public var srcset:[String] = []
|
||||
|
||||
/// Name of image map to use. Valid hash-name reference. The actual rules are more complicated than indicated.
|
||||
public var usemap:String? = nil
|
||||
|
||||
/// Horizontal dimension. Valid non-negative integer.
|
||||
public var width:UInt? = nil
|
||||
|
||||
|
||||
public init(_ attributes:[String:String], _ parser:XMLParser? = nil) throws {
|
||||
var globalAttr = GlobalAttributesBuilder()
|
||||
for (key, attValue) in attributes {
|
||||
switch (key) {
|
||||
case "alt":
|
||||
alt = attValue
|
||||
continue
|
||||
case "crossorigin":
|
||||
crossorigin = try Crossorigin(expect: attValue)
|
||||
continue
|
||||
case "decoding":
|
||||
decoding = try Decoding(expect: attValue)
|
||||
continue
|
||||
case "height":
|
||||
height = UInt(attValue)
|
||||
continue
|
||||
case "ismap":
|
||||
ismap = true
|
||||
continue
|
||||
case "loading":
|
||||
loading = try Loading(expect: attValue)
|
||||
continue
|
||||
case "referrerpolicy":
|
||||
referrerpolicy = try ReferrerPolicy(expect: attValue)
|
||||
continue
|
||||
case "sizes":
|
||||
sizes = try String.parseList(attValue, ",")
|
||||
continue
|
||||
case "src":
|
||||
src = try URL(expect: attValue)
|
||||
continue
|
||||
case "srcset":
|
||||
srcset = try String.parseList(attValue, ",")
|
||||
continue
|
||||
case "usemap":
|
||||
usemap = attValue
|
||||
continue
|
||||
case "width":
|
||||
width = UInt(attValue)
|
||||
continue
|
||||
|
||||
default: break
|
||||
}
|
||||
if globalAttr.trySetGlobalAttribute(key, attValue) {
|
||||
continue
|
||||
}
|
||||
continue
|
||||
}
|
||||
super.init(globalAttr)
|
||||
}
|
||||
|
||||
|
||||
public override func renderAttributes() -> String {
|
||||
var result = super.renderAttributes()
|
||||
if let alt = alt {
|
||||
result += " alt='\(alt)'"
|
||||
}
|
||||
if let crossorigin = crossorigin {
|
||||
result += " crossorigin='\(crossorigin.rawValue)'"
|
||||
}
|
||||
if let decoding = decoding {
|
||||
result += " decoding='\(decoding.rawValue)'"
|
||||
}
|
||||
if let height = height {
|
||||
result += " height='\(height)'"
|
||||
}
|
||||
if ismap {
|
||||
result += " ismap"
|
||||
}
|
||||
if let loading = loading {
|
||||
result += " loading='\(loading.rawValue)'"
|
||||
}
|
||||
if let referrerpolicy = referrerpolicy {
|
||||
result += " referrerpolicy='\(referrerpolicy.rawValue)'"
|
||||
}
|
||||
result += " sizes='\(sizes.toStringList(","))'"
|
||||
if let src = src {
|
||||
result += " src='\(src.absoluteString)'"
|
||||
}
|
||||
result += " srcset='\(srcset.toStringList(","))'"
|
||||
if let usemap = usemap {
|
||||
result += " usemap='\(usemap)'"
|
||||
}
|
||||
if let width = width {
|
||||
result += " width='\(width)'"
|
||||
}
|
||||
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
override var nodeName: String {
|
||||
return "img"
|
||||
}
|
||||
|
||||
override var isVoidElement: Bool {
|
||||
return true
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user