/// <summary> /// Stream the field to a tag stream /// </summary> /// <param name="ts"></param> public override void Write(IO.ITagStream ts) { if (DefinitionState.FieldSetRequiresVersioningHeader(ts)) { kState.FieldSetWriteVersion(ts, FieldType.Struct); } }
/// <summary> /// Stream the field to a tag stream /// </summary> /// <param name="ts"></param> /// <exception cref="Exceptions.InvalidTagStruct"></exception> public override void Read(IO.ITagStream ts) { IO.EndianReader s = ts.GetInputStream(); base.relativeOffset = s.PositionUnsigned; // use relative offset since the 'fieldset header' is really...well the header NeedsUpgrading = false; try { if (DefinitionState.FieldSetRequiresVersioningHeader(ts)) { IFieldSetVersioning fs = kState.FieldSetReadVersion(ts, FieldType.Struct, base.relativeOffset, 1); if (NeedsUpgrading = fs.NeedsUpgrading) { int index, size_of; fs.GetUpgradeParameters(out index, out size_of); // It is ASSUMED that the group tag won't ever be needed for version construction if (!fs.UseImplicitUpgrading) { Value = (T)kState.NewInstance(this, index, size_of); } else { Value.VersionImplicitUpgradeBegin(size_of, ts); } } } } catch (Debug.ExceptionLog del) { throw del; } catch (Exception ex) { throw new Exceptions.InvalidTagStruct(ex, base.relativeOffset, this.owner, ts); } }
/// <summary> /// Process the block data to a tag stream /// </summary> /// <param name="ts"></param> public override void Write(IO.ITagStream ts) { if (this.elements.Count == 0) { return; // don't do anything when empty } IO.EndianWriter s = ts.GetOutputStream(); if (ts.Flags.Test(IO.ITagStreamFlags.UseStreamPositions)) { relativeOffset = s.PositionUnsigned; // store offset s.Seek(headerOffset, System.IO.SeekOrigin.Begin); // go to the reflexive header s.WritePointer(relativeOffset); // write offset s.Seek(relativeOffset, System.IO.SeekOrigin.Begin); // go back to where we were } if (DefinitionState.FieldSetRequiresVersioningHeader(ts)) { kState.FieldSetWriteVersion(ts, FieldType.Block, Count); } elements.Write(ts); }
public FieldSetVersioning(BlamVersion engine, FieldType container_type, DefinitionState state) { failureReason = VersioningFailureReason.None; relativeOffset = 0; expectedCount = 1; needsUpgrading = false; useImplicitUpgrading = false; header = new tag_fieldset_header(); this.type = container_type; this.state = state; if (container_type != FieldType.Struct) { this.headerGroupTag = Blam.MiscGroups.tbfd; } else { var groups = engine.VersionToStructCollection(); var sa = state.Attribute as StructAttribute; headerGroupTag = groups[sa.GroupIndex]; } }
/// <summary> /// Process the block data from a tag stream /// </summary> /// <param name="ts"></param> /// <exception cref="Exceptions.InvalidTagBlock"></exception> public override void Read(IO.ITagStream ts) { NeedsUpgrading = false; bool resizeImplicitUpgradeIsActive = false; if (this.elements.Count != 0) { IO.EndianReader s = ts.GetInputStream(); if (!ts.Flags.Test(IO.ITagStreamFlags.UseStreamPositions)) { relativeOffset = s.PositionUnsigned; // nifty for debugging } else { s.PositionUnsigned = relativeOffset; } try { if (DefinitionState.FieldSetRequiresVersioningHeader(ts)) { IFieldSetVersioning fs = kState.FieldSetReadVersion(ts, FieldType.Block, relativeOffset, Count); if (NeedsUpgrading = fs.NeedsUpgrading) { int index, size_of; fs.GetUpgradeParameters(out index, out size_of); if (!(resizeImplicitUpgradeIsActive = fs.UseImplicitUpgrading)) { Resize(Count, index, size_of); } else { ResizeImplicitUpgradeBegin(size_of, ts); } } } elements.Read(ts); } catch (Debug.ExceptionLog del) { throw del; } catch (Exception ex) { throw new Exceptions.InvalidTagBlock(ex, base.headerOffset, base.relativeOffset, this.owner, ts); } if (NeedsUpgrading) { if (resizeImplicitUpgradeIsActive) { ResizeImplicitUpgradeEnd(); } else { elements.Upgrade(); } } } }
public FieldSetVersioning(BlamVersion engine, FieldType container_type, DefinitionState state, TagGroup group_tag) : this(engine, container_type, state) { this.headerGroupTag = group_tag; }
public FieldSetVersioning(BlamVersion engine, FieldType container_type, DefinitionState state) { failureReason = VersioningFailureReason.None; relativeOffset = 0; expectedCount = 1; needsUpgrading = false; useImplicitUpgrading = false; header = new tag_fieldset_header(); this.type = container_type; this.state = state; if(container_type != FieldType.Struct) this.headerGroupTag = Blam.MiscGroups.tbfd; else { var groups = engine.VersionToStructCollection(); var sa = state.Attribute as StructAttribute; headerGroupTag = groups[sa.GroupIndex]; } }
public FieldSetVersioning(BlamVersion engine, FieldType container_type, DefinitionState state, TagGroup group_tag) : this(engine, container_type, state) { this.headerGroupTag = group_tag; }