This commit is contained in:
relikd
2025-11-25 22:46:14 +01:00
commit a28636a7ca
28 changed files with 2380 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
/**
* 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) }
}