KdbxMeta.read constructor
KdbxMeta.read(
- XmlElement node,
- KdbxReadWriteContext ctx
Implementation
KdbxMeta.read(super.node, this.ctx)
: customData = node
.singleElement(KdbxXml.NODE_CUSTOM_DATA)
?.let((e) => KdbxCustomData.read(e)) ??
KdbxCustomData.create(),
binaries = node
.singleElement(KdbxXml.NODE_BINARIES)
?.let((el) sync* {
for (final binaryNode in el.findElements(KdbxXml.NODE_BINARY)) {
final id = int.parse(binaryNode.getAttribute(KdbxXml.ATTR_ID)!);
yield MapEntry(
id,
KdbxBinary.readBinaryXml(binaryNode, isInline: false),
);
}
})
.toList()
.let((binaries) {
binaries.sort((a, b) => a.key.compareTo(b.key));
for (var i = 0; i < binaries.length; i++) {
if (i != binaries[i].key) {
throw KdbxCorruptedFileException(
'Invalid ID for binary. expected $i,'
' but was ${binaries[i].key}');
}
}
return binaries.map((e) => e.value).toList();
}),
_customIcons = node
.singleElement(KdbxXml.NODE_CUSTOM_ICONS)
?.let((el) sync* {
for (final iconNode in el.findElements(KdbxXml.NODE_ICON)) {
yield KdbxCustomIcon(
uuid: KdbxUuid(
iconNode.singleTextNode(KdbxXml.NODE_UUID)),
data: base64.decode(
iconNode.singleTextNode(KdbxXml.NODE_DATA)));
}
})
.map((e) => MapEntry(e.uuid, e))
.let((that) => Map.fromEntries(that)) ??
{},
super.read();