Example #1
0
        private HeaderEditor(Record r)
        {
            this.InitializeComponent();
            Icon = Resources.fosnip;
            this.R = r;
            this.tbName.Text = r.Name;
            this.Flags1 = r.Flags1;
            this.Flags2 = r.Flags2;
            this.Flags3 = r.Flags3;
            this.FormID = r.FormID;
            this.tbFormID.Text = this.FormID.ToString("x8").ToUpperInvariant();
            this.tbFlags2.Text = this.Flags2.ToString("x8").ToUpperInvariant();
            this.tbFlags3.Text = this.Flags3.ToString("x8").ToUpperInvariant();
            foreach (Control c in Controls)
            {
                if (c is CheckBox)
                {
                    c.Tag = int.Parse((string)c.Tag);
                    if ((this.Flags1 & GetInt(c.Tag)) > 0)
                    {
                        ((CheckBox)c).Checked = true;
                    }
                }
            }

            // cb18.Checked=false; // Allow compression
        }
 /// <summary>
 /// Clear any state.
 /// </summary>
 public void ClearControl()
 {
     this.r = null;
     this.sr = null;
     this.ss = null;
     this.controlMap.Clear();
     this.fpanel1.Controls.Clear();
     Enabled = false;
 }
Example #3
0
        public override bool Match(Record r)
        {
            bool any = false;
            foreach (bool value in r.SubRecords.Where(x => x.Name == this.Parent.Record.name).Select(x => this.Match(r, x)))
            {
                if (!value)
                {
                    return false;
                }

                any = true;
            }

            return any;
        }
Example #4
0
        public override bool Evaluate(Record r, SubRecord sr)
        {
            if (this.Type == BatchCondRecordType.Create)
            {
                if (sr == null)
                {
                    // guess the best insert location
                    int idx = -1;
                    var records = r.GetStructures();
                    RecordStructure rs;
                    if (records.TryGetValue(r.Name, out rs))
                    {
                        for (int i = Array.FindIndex(rs.subrecords, structure => structure.name == this.Record.name) - 1; i >= 0; --i)
                        {
                            var srsname = rs.subrecords[i].name;
                            idx = r.SubRecords.IndexOf(r.SubRecords.FirstOrDefault(x => x.Name == srsname));
                        }
                    }

                    sr = new SubRecord(this.Record);
                    if (idx < 0)
                    {
                        r.SubRecords.Add(sr);
                    }
                    else
                    {
                        r.SubRecords.Insert(idx + 1, sr);
                    }
                }
            }
            else if (this.Type == BatchCondRecordType.Delete)
            {
                while (sr != null)
                {
                    r.SubRecords.Remove(sr);
                    sr = r.SubRecords.FirstOrDefault(x => x.Name == this.Record.name);
                }
            }

            return true;
        }
Example #5
0
        public static void ReorderSubrecords(Record rec)
        {
            var records = rec.GetStructures();
            if (rec == null || records == null)
                return;

            RecordStructure recStruct;
            if (!records.TryGetValue(rec.Name, out recStruct))
                return;

            SubrecordStructure[] sss = recStruct.subrecords;
            var subs = new List<SubRecord>(rec.SubRecords);
            foreach (var sub in subs)
            {
                sub.DetachStructure();
            }

            var newsubs = new List<SubRecord>();
            for (int ssidx = 0, sslen = 0; ssidx < sss.Length; ssidx += sslen)
            {
                SubrecordStructure ss = sss[ssidx];
                bool repeat = ss.repeat > 0;
                sslen = Math.Max(1, ss.repeat);

                bool found = false;
                do
                {
                    found = false;
                    for (int ssoff = 0; ssoff < sslen; ++ssoff)
                    {
                        ss = sss[ssidx + ssoff];
                        for (int i = 0; i < subs.Count; ++i)
                        {
                            var sr = subs[i];
                            if (sr.Name == ss.name)
                            {
                                newsubs.Add(sr);
                                subs.RemoveAt(i);
                                found = true;
                                break;
                            }
                        }
                    }
                } while (found && repeat);
            }

            newsubs.AddRange(subs);
            rec.SubRecords.Clear();
            rec.SubRecords.AddRange(newsubs);
        }
Example #6
0
        public static void giveRecordNewFormID(Record rec, bool updateReference, ref uint formCount, ref uint refCount)
        {
            var plugin = GetPluginFromNode(rec);
            if (plugin == null)
            {
                throw new ApplicationException("Cannot select plugin");
            }

            uint newFormID = getNextFormID(plugin);
            uint oldFormID = rec.FormID;
            rec.FormID = newFormID;
            formCount++;
            if (oldFormID != 0 && updateReference)
            {
                updateFormIDReference(plugin, oldFormID, newFormID, ref refCount);
            }

            plugin.InvalidateCache();
        }
Example #7
0
 public static void giveRecordNewFormID(Record rec, bool updateReference)
 {
     uint formCount = 0, refCount = 0;
     giveRecordNewFormID(rec, updateReference, ref formCount, ref refCount);
 }
Example #8
0
 public FalloutSnip.Data.RecordsRecord ProcessBase(Record r)
 {
     FalloutSnip.Data.RecordsRecord rr;
     if (!rdict.TryGetValue(r.Name, out rr))
     {
         rr = new FalloutSnip.Data.RecordsRecord();
         rr.name = r.Name;
         rr.desc = r.Name;
         rdict.Add(r.Name, rr);
     }
     return rr;
 }
Example #9
0
        public bool Process(Record p)
        {
            FalloutSnip.Data.RecordsRecord rr = ProcessBase(p);

            // int srIdx = 0;
            var groups = from psr in p.SubRecords
                         group psr by psr.Name into g
                         select new { Name = g.Key, Records = g.ToArray() };

            int lastIndex = 0;
            Dictionary<string, FalloutSnip.Data.Subrecord> dict = new Dictionary<string, FalloutSnip.Data.Subrecord>();
            foreach (var kvp in groups)
            {
                if (IsCanceled) return false;

                FalloutSnip.Data.Subrecord sr = rr.Subrecords.FirstOrDefault(x => x.name == kvp.Name);
                if (sr == null)
                {
                    sr = new FalloutSnip.Data.Subrecord();
                    sr.name = sr.desc = kvp.Name;
                    sr.optional = 1;
                    if (lastIndex + 1 <= rr.Items.Count)
                    {
                        rr.Items.Insert(++lastIndex, sr);
                    }
                    else
                    {
                        rr.Items.Add(sr);
                    }
                }
                else
                {
                    lastIndex = rr.Items.IndexOf(sr, lastIndex);
                    if (lastIndex < 0)  // out of order
                        lastIndex = rr.Items.IndexOf(sr);
                }
                int n = kvp.Records.Length;
                if (n > 0)
                {
                    if (sr.repeat == 0 && n > 1)
                        sr.optional = sr.repeat = 1;
                    int idx1 = p.SubRecords.IndexOf(kvp.Records[0]);
                    int idx2 = idx1;
                    for (int i = 1; i < n; ++i, idx1 = idx2)
                    {
                        idx2 = p.SubRecords.IndexOf(kvp.Records[i]);
                        int diff = (idx2 - idx1);
                        if (diff > sr.repeat)
                        {
                            if (diff < 10)
                            {
                                sr.optional = sr.repeat = diff;
                            }
                            else
                            {
                                sr.optional = sr.repeat;
                            }
                        }
                    }
                }
                foreach (var subrec in kvp.Records)
                {
                    if (IsCanceled) break;
                    Process(sr, subrec);
                }
            }
            return true;
        }
Example #10
0
        private bool CreateSubrecords(RecordsRecord rr, Record r)
        {
            // int srIdx = 0;
            var groups = from psr in r.SubRecords
                         group psr by psr.Name
                         into g select new {Name = g.Key, Records = g.ToArray()};

            int lastIndex = 0;
            var dict = new Dictionary<string, Subrecord>();
            foreach (var kvp in groups)
            {
                if (IsCanceled)
                {
                    return false;
                }

                // if (kvp.Name.Count(a => !Char.IsLetterOrDigit(a)) > 0) continue;
                int n = kvp.Records.Length;

                var sr = rr.Subrecords.FirstOrDefault(x => x.name == kvp.Name);
                if (sr == null)
                {
                    sr = new Subrecord();
                    sr.name = sr.desc = kvp.Name;
                    sr.optional = 1;
                    if (lastIndex + 1 <= rr.Items.Count)
                    {
                        rr.Items.Insert(++lastIndex, sr);
                    }
                    else
                    {
                        rr.Items.Add(sr);
                    }
                }
                else
                {
                    lastIndex = rr.Items.IndexOf(sr, (lastIndex < 0) ? lastIndex : 0);
                    if (lastIndex < 0)
                    {
                        // out of order
                        lastIndex = rr.Items.IndexOf(sr);
                    }
                }

                // Group Detection
                if (n > 0)
                {
                    int idx1 = r.SubRecords.IndexOf(kvp.Records[0]);
                    int idx2 = idx1;
                    for (int i = 1; i < n; ++i, idx1 = idx2)
                    {
                        idx2 = r.SubRecords.IndexOf(kvp.Records[i]);
                        int diff = r.SubRecords.Skip(idx1).Take(idx2 - idx1).Select((a) => a.Name).Distinct().Count();
                        if (diff > sr.repeat)
                        {
                            sr.optional = sr.repeat = diff;
                        }
                    }

                    if (sr.repeat == 0 && n > 1)
                    {
                        sr.optional = sr.repeat = 1;
                    }
                }
            }

            return true;
        }
Example #11
0
        public bool Evaluate(Record r, SubRecord sr, Element se)
        {
            if (se == null)
            {
                return false;
            }

            var value = sr.GetCompareValue(se);
            int diff = ValueComparer.Compare(value, this.Value);
            switch (this.Type)
            {
                case BatchCondElementType.Set:
                    break;
                case BatchCondElementType.Add:
                    break;
                case BatchCondElementType.Subtract:
                    break;
                case BatchCondElementType.Multiply:
                    break;
                case BatchCondElementType.Divide:
                    break;
                case BatchCondElementType.Clear:
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }

            return false;
        }
Example #12
0
        public override bool Match(Record r, SubRecord sr)
        {
            bool any = false;
            foreach (bool value in sr.EnumerateElements().Where(x => x.Structure.name == this.Record.name).Select(x => this.Match(r, sr, x)))
            {
                if (!value)
                {
                    return false;
                }

                any = true;
            }

            return any;
        }
Example #13
0
 public override bool Evaluate(Record r)
 {
     var sr = r.SubRecords.FirstOrDefault(x => x.Name == this.Record.name);
     return this.Evaluate(r, sr);
 }
Example #14
0
        private Record(Record r)
        {
            this.SubRecords = new AdvancedList<SubRecord>(r.SubRecords.Count);
            this.SubRecords.AllowSorting = false;
            foreach (var sr in r.SubRecords.OfType<SubRecord>())
            {
                this.SubRecords.Add((SubRecord)sr.Clone());
            }

            this.Flags1 = r.Flags1;
            this.Flags2 = r.Flags2;
            this.Flags3 = r.Flags3;
            this.FormID = r.FormID;
            Name = r.Name;
            this.descNameOverride = this.DefaultDescriptiveName;
            this.UpdateShortDescription();
            this.FixSubrecordOwner();
        }
Example #15
0
        internal GroupRecord(uint Size, BinaryReader br, FalloutSnip.Domain.Data.DomainDefinition define, Func<string, bool> recFilter, bool filterAll)
        {
            Name = "GRUP";
            this.data = br.ReadBytes(4);
            this.groupType = br.ReadUInt32();
            this.dateStamp = br.ReadUInt32();
            string contentType = this.groupType == 0 ? Encoding.Instance.GetString(this.data) : string.Empty;
            if (define.RecSize >= 16)
            {
                this.flags = br.ReadUInt32();
            }

            uint amountRead = 0;
            while (amountRead < Size - (define.RecSize+8))
            {
                string s = ReadRecName(br);
                uint recsize = br.ReadUInt32();
                if (s == "GRUP")
                {
                    try
                    {
                        bool skip = filterAll || (recFilter != null && !recFilter(contentType));
                        var gr = new GroupRecord(recsize, br, define, recFilter, skip);
                        if (!filterAll)
                        {
                            this.AddRecord(gr);
                        }
                    }
                    catch (Exception e)
                    {
                        Alerts.Show(e.Message);
                    }
                    finally
                    {
                        amountRead += recsize;
                    }
                }
                else
                {
                    bool skip = filterAll || (recFilter != null && !recFilter(contentType));
                    if (skip)
                    {
                        long size = recsize + define.RecSize;

                        // if ((br.ReadUInt32() & 0x00040000) > 0) size += 4;
                        br.BaseStream.Position += size; // just read past the data
                        amountRead += (uint)(recsize + (define.RecSize+8));
                    }
                    else
                    {
                        try
                        {
                            var r = new Record(s, recsize, br, define);
                            this.AddRecord(r);
                        }
                        catch (Exception e)
                        {
                            Alerts.Show(e.Message);
                        }
                        finally
                        {
                            amountRead += (uint)(recsize + (define.RecSize+8));
                        }
                    }
                }
            }

            this.UpdateShortDescription();
            if (amountRead != (Size - (define.RecSize+8)))
            {
                throw new TESParserException(
                    string.Format("Record block did not match the size specified in the group header! Header Size={0:D} Group Size={1:D}", Size - (define.RecSize+8), amountRead));
            }
        }
Example #16
0
 public RecordEditor(Record rec)
     : this()
 {
     this.Record = rec;
 }
Example #17
0
        public void SetContext(Record r, SubRecord sr, bool hexView)
        {
            if (this.r == r && this.sr == sr && this.hexView == hexView)
            {
                return;
            }

            if (r == null || sr == null)
            {
                this.ClearControl();
                return;
            }

            // walk each element in standard fashion
            int panelOffset = 0;
            try
            {
                this.BeginUpdate();

                this.ClearControl();
                SuspendLayout();
                this.fpanel1.SuspendLayout();
                this.fpanel1.Width = Parent.Width;
                this.controlMap.Clear();

                this.hexView = hexView;
                this.r = r;
                this.sr = sr;
                var p = this.GetPluginFromNode(r);
                this.ss = sr.Structure;

                // default to blob if no elements
                if (this.ss == null || this.ss.elements == null || hexView)
                {
                    var c = new HexElement();
                    c.Left = 8;
                    c.Width = this.fpanel1.Width - 16;
                    c.Top = panelOffset;
                    c.Anchor = c.Anchor | AnchorStyles.Left | AnchorStyles.Right;

                    var elem = r.EnumerateElements(sr, true).FirstOrDefault();
                    if (elem != null)
                    {
                        this.controlMap.Add(elem.Structure, c);
                        this.fpanel1.Controls.Add(c);
                        c.Data = elem.Data;
                    }
                }
                else
                {
                    foreach (var elem in this.ss.elements)
                    {
                        Control c = null;
                        if (elem.options != null && elem.options.Length > 1)
                        {
                            c = new OptionsElement();
                        }
                        else if (elem.flags != null && elem.flags.Length > 1)
                        {
                            c = new FlagsElement();
                        }
                        else
                        {
                            switch (elem.type)
                            {
                                case ElementValueType.LString:
                                    c = new LStringElement();
                                    break;
                                case ElementValueType.FormID:
                                    c = new FormIDElement();
                                    break;
                                case ElementValueType.Blob:
                                    c = new HexElement();
                                    break;
                                default:
                                    c = new TextElement();
                                    break;
                            }
                        }

                        if (c is IElementControl)
                        {
                            var ec = c as IElementControl;
                            ec.formIDLookup = p.GetRecordByID;
                            ec.formIDScan = p.EnumerateRecords;
                            ec.strIDLookup = p.LookupFormStrings;
                            ec.Element = elem;

                            if (elem.repeat > 0)
                            {
                                var ge = new RepeatingElement();
                                c = ge;
                                c.Left = 8;
                                c.Width = this.fpanel1.Width - 16;
                                c.Top = panelOffset;
                                c.Anchor = c.Anchor | AnchorStyles.Left | AnchorStyles.Right;

                                ge.InnerControl = ec;
                                ge.Element = elem;
                                ec = ge;
                            }
                            else if (elem.optional > 0)
                            {
                                var re = new OptionalElement();
                                c = re;
                                c.Left = 8;
                                c.Width = this.fpanel1.Width - 16;
                                c.Top = panelOffset;
                                c.Anchor = c.Anchor | AnchorStyles.Left | AnchorStyles.Right;

                                re.InnerControl = ec;
                                re.Element = elem;
                                ec = re;
                                c = re;
                            }
                            else
                            {
                                c.Left = 8;
                                c.Width = this.fpanel1.Width - 16;
                                c.Top = panelOffset;
                                c.Anchor = c.Anchor | AnchorStyles.Left | AnchorStyles.Right;
                            }

                            c.MinimumSize = c.Size;

                            this.controlMap.Add(elem, ec);
                            this.fpanel1.Controls.Add(c);
                            panelOffset = c.Bottom;
                        }
                    }

                    foreach (Element elem in r.EnumerateElements(sr, true))
                    {
                        var es = elem.Structure;

                        IElementControl c;
                        if (this.controlMap.TryGetValue(es, out c))
                        {
                            if (c is IGroupedElementControl)
                            {
                                var gc = c as IGroupedElementControl;
                                gc.Elements.Add(elem.Data);
                            }
                            else
                            {
                                c.Data = elem.Data;
                            }
                        }
                    }
                }

                Enabled = true;
            }
            catch
            {
                this.strWarnOnSave = "The subrecord doesn't appear to conform to the expected structure.\nThe formatted information may be incorrect.";
            }
            finally
            {
                this.fpanel1.ResumeLayout();
                ResumeLayout();
                this.EndUpdate();
                Refresh();
            }
        }
Example #18
0
        public override bool Match(Record r, SubRecord sr, Element se)
        {
            if (this.Type == SearchCondElementType.Exists && se != null)
            {
                return true;
            }

            if (this.Type == SearchCondElementType.Missing && se == null)
            {
                return true;
            }

            if (se == null)
            {
                return false;
            }

            var value = sr.GetCompareValue(se);
            int diff = ValueComparer.Compare(value, this.Value);
            switch (this.Type)
            {
                case SearchCondElementType.Equal:
                    return diff == 0;
                case SearchCondElementType.Not:
                    return diff != 0;
                case SearchCondElementType.Greater:
                    return diff > 0;
                case SearchCondElementType.Less:
                    return diff < 0;
                case SearchCondElementType.GreaterEqual:
                    return diff >= 0;
                case SearchCondElementType.LessEqual:
                    return diff <= 0;
                case SearchCondElementType.StartsWith:
                    if (diff == 0)
                    {
                        return true;
                    }

                    if (value != null && this.Value != null)
                    {
                        return value.ToString().StartsWith(this.Value.ToString(), StringComparison.CurrentCultureIgnoreCase);
                    }

                    break;
                case SearchCondElementType.EndsWith:
                    if (diff == 0)
                    {
                        return true;
                    }

                    if (value != null && this.Value != null)
                    {
                        return value.ToString().EndsWith(this.Value.ToString(), StringComparison.CurrentCultureIgnoreCase);
                    }

                    break;
                case SearchCondElementType.Contains:
                    if (diff == 0)
                    {
                        return true;
                    }

                    if (value != null && this.Value != null)
                    {
                        return value.ToString().IndexOf(this.Value.ToString(), StringComparison.CurrentCultureIgnoreCase) >= 0;
                    }

                    break;
            }

            return false;
        }
Example #19
0
 public static DialogResult Display(Record r)
 {
     var hr = new HeaderEditor(r);
     return hr.ShowDialog();
 }
Example #20
0
 public bool TryGetRecordByID(uint key, out Record value)
 {
     this.RebuildCache();
     return this.FormIDLookup.TryGetValue(key, out value);
 }
        public NewMediumLevelRecordEditor(Plugin p, Record r, SubRecord sr, SubrecordStructure ss)
        {
            this.InitializeComponent();
            Icon = Resources.fosnip;
            SuspendLayout();
            this.sr = sr;
            this.ss = ss;
            this.p = p;
            this.r = r;

            // walk each element in standard fashion
            int panelOffset = 0;
            try
            {
                this.fpanel1.ColumnStyles[0] = new ColumnStyle(SizeType.Percent, 100.0f);
                int maxWidth = this.fpanel1.Width - SystemInformation.VerticalScrollBarWidth - 8;
                int leftOffset = 0; // 8;
                foreach (var elem in ss.elements)
                {
                    Control c = null;
                    if (elem.options != null && elem.options.Length > 1)
                    {
                        c = new OptionsElement();
                    }
                    else if (elem.flags != null && elem.flags.Length > 1)
                    {
                        c = new FlagsElement();
                    }
                    else
                    {
                        switch (elem.type)
                        {
                            case ElementValueType.LString:
                                c = new LStringElement();
                                break;
                            case ElementValueType.FormID:
                                c = new FormIDElement();
                                break;
                            case ElementValueType.Blob:
                                c = new HexElement();
                                break;
                            default:
                                c = new TextElement();
                                break;
                        }
                    }

                    if (c is IElementControl)
                    {
                        var ec = c as IElementControl;
                        ec.formIDLookup = p.GetRecordByID;
                        ec.formIDScan = p.EnumerateRecords;
                        ec.strIDLookup = p.LookupFormStrings;
                        ec.Element = elem;

                        if (elem.repeat > 0)
                        {
                            var ge = new RepeatingElement();
                            c = ge;
                            c.Left = leftOffset;
                            c.Width = maxWidth;
                            c.Top = panelOffset;
                            c.Anchor = c.Anchor | AnchorStyles.Left | AnchorStyles.Right;

                            ge.InnerControl = ec;
                            ge.Element = elem;
                            ec = ge;
                        }
                        else if (elem.optional > 0)
                        {
                            var re = new OptionalElement();
                            c = re;
                            c.Left = leftOffset;
                            c.Width = maxWidth;
                            c.Top = panelOffset;
                            c.Anchor = c.Anchor | AnchorStyles.Left | AnchorStyles.Right;

                            re.InnerControl = ec;
                            re.Element = elem;
                            ec = re;
                            c = re;
                        }
                        else
                        {
                            c.Left = leftOffset;
                            c.Width = maxWidth;
                            c.Top = panelOffset;
                            c.Anchor = c.Anchor | AnchorStyles.Left | AnchorStyles.Right;
                        }

                        this.controlMap.Add(elem, ec);
                        int idx = this.fpanel1.RowCount - 1;
                        this.fpanel1.Controls.Add(c, 0, idx);
                        var info = new RowStyle(SizeType.Absolute, c.Size.Height+2);
                        if (idx == 0)
                            this.fpanel1.RowStyles[0] = info;
                        else
                            this.fpanel1.RowStyles.Add(info);
                        panelOffset = 0;
                        ++this.fpanel1.RowCount;
                    }
                }

                foreach (Element elem in r.EnumerateElements(sr, true))
                {
                    var es = elem.Structure;

                    IElementControl c;
                    if (this.controlMap.TryGetValue(es, out c))
                    {
                        if (c is IGroupedElementControl)
                        {
                            var gc = c as IGroupedElementControl;
                            gc.Elements.Add(elem.Data);
                        }
                        else
                        {
                            c.Data = elem.Data;
                        }
                    }
                }
            }
            catch
            {
                this.strWarnOnSave = "The subrecord doesn't appear to conform to the expected structure.\nThe formatted information may be incorrect.";
                this.Error.SetError(this.bSave, this.strWarnOnSave);
                this.Error.SetIconAlignment(this.bSave, ErrorIconAlignment.MiddleLeft);
                AcceptButton = this.bCancel; // remove save as default button when exception occurs
                CancelButton = this.bCancel;
                UpdateDefaultButton();
            }

            ResumeLayout();
        }
Example #22
0
        public bool Process(string name, Record[] records)
        {
            RecordsRecord rr;
            if (!rdict.TryGetValue(name, out rr))
            {
                rr = new RecordsRecord {name = name, desc = name};
                rdict.Add(name, rr);
            }

            foreach (var r in records)
            {
                UpdateProgress();
                if (!CreateSubrecords(rr, r))
                {
                    return false;
                }
            }

            // now that we have subrecords, go back through all records
            foreach (var sr in rr.Items.OfType<Subrecord>())
            {
                // list of all subrecords matching the given name
                var ss = (from r in records from s in r.SubRecords where s.Name == sr.name select s).ToArray();

                ProcessSubRecord(sr, ss);
            }

            // Post Process
            var srs = rr.Subrecords;
            var itr = srs.GetEnumerator();
            for (bool atEnd = itr.MoveNext(); !atEnd;)
            {
                var sr = itr.Current;
                if (sr.repeat > 1)
                {
                    if (sr.size < 0)
                    {
                        sr.size = 0;
                        continue;
                    }

                    int count = sr.repeat;
                    for (int j = 1; j < count; ++j)
                    {
                        atEnd = itr.MoveNext();
                        if (atEnd)
                        {
                            sr = itr.Current;
                            if (sr.repeat == count)
                            {
                                sr.repeat = sr.optional = 0;
                            }
                            else
                            {
                                // Should be a group??
                            }
                        }
                        else
                        {
                            sr.repeat = sr.optional = 1;
                        }
                    }
                }
                else
                {
                    atEnd = itr.MoveNext();
                }
            }

            // sub records have been updated
            long minSize = records.Min(a => a.Size);
            long maxSize = records.Max(a => a.Size);
            if (maxSize == minSize)
            {
                // Uniform record size
            }
            else
            {
            }

            return true;
        }