Files
AndroidXML/Sources/AndroidXML/XmlNode.swift
2025-11-25 22:46:14 +01:00

25 lines
748 B
Swift

/**
* Basic XML tree node. A single item in the XML document.
* Extended info about the node can be found after `header.headerSize`.
*/
/// Header size: `ChunkHeader` (8B) + `8 Bytes`
protocol XmlNode {
var header: ChunkHeader { get }
}
extension XmlNode {
/// Line number in original source file at which this element appeared.
public var lineNumber: UInt32 {
header._bytes.int32(header.index(.startOfHeader) + 0)
}
/// Optional XML comment that was associated with this element
public var comment: StringPoolRef? {
let val = header._bytes.int32(header.index(.startOfHeader) + 4)
return val == 0xFFFFFFFF ? nil : val // `-1` if none.
}
/// Absolute offset in data
public var offset: Index { header.index(.startOfChunk) }
}