Initial
This commit is contained in:
24
Sources/AndroidXML/XmlNode.swift
Normal file
24
Sources/AndroidXML/XmlNode.swift
Normal 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) }
|
||||
}
|
||||
Reference in New Issue
Block a user