parseNode method
Map<String, dynamic>?
parseNode(
- dynamic reader,
- dynamic version
)
Implementation
Map<String, dynamic>? parseNode( reader, version ) {
Map<String, dynamic> node = {};
// The first three data sizes depends on version.
var endOffset = ( version >= 7500 ) ? reader.getUint64() : reader.getUint32();
var numProperties = ( version >= 7500 ) ? reader.getUint64() : reader.getUint32();
( version >= 7500 ) ? reader.getUint64() : reader.getUint32(); // the returned propertyListLen is not used
var nameLen = reader.getUint8();
var name = reader.getString( nameLen );
// Regards this node as NULL-record if endOffset is zero
if ( endOffset == 0 ) return null;
var propertyList = [];
for ( var i = 0; i < numProperties; i ++ ) {
propertyList.add( this.parseProperty( reader ) );
}
// Regards the first three elements in propertyList as id, attrName, and attrType
var id = propertyList.length > 0 ? propertyList[ 0 ] : '';
var attrName = propertyList.length > 1 ? propertyList[ 1 ] : '';
var attrType = propertyList.length > 2 ? propertyList[ 2 ] : '';
// check if this node represents just a single property
// like (name, 0) set or (name2, [0, 1, 2]) set of {name: 0, name2: [0, 1, 2]}
node["singleProperty"] = ( numProperties == 1 && reader.getOffset() == endOffset ) ? true : false;
while ( endOffset > reader.getOffset() ) {
var subNode = this.parseNode( reader, version );
if ( subNode != null ) this.parseSubNode( name, node, subNode );
}
node["propertyList"] = propertyList; // raw property list used by parent
if ( id is num ) node["id"] = id;
if ( attrName != '' ) node["attrName"] = attrName;
if ( attrType != '' ) node["attrType"] = attrType;
if ( name != '' ) node["name"] = name;
return node;
}