Ejemplo n.º 1
0
 public bool TryReadGroup(IBinaryReadStream stream, out GroupHeader header, bool checkIsGroup = true)
 {
     if (stream.Remaining < GroupConstants.HeaderLength)
     {
         header = default;
         return(false);
     }
     header = ReadGroup(stream);
     return(!checkIsGroup || header.IsGroup);
 }
Ejemplo n.º 2
0
 public bool TryGetGroup(IBinaryReadStream stream, out GroupHeader meta, int offset = 0, bool checkIsGroup = true)
 {
     if (stream.Remaining < GroupConstants.HeaderLength + offset)
     {
         meta = default;
         return(false);
     }
     meta = GetGroup(stream, offset);
     return(!checkIsGroup || meta.IsGroup);
 }
Ejemplo n.º 3
0
        public static void FillModTypes(
            IBinaryReadStream stream,
            ModTypeFillWrapper fill,
            BinaryOverlayFactoryPackage package)
        {
            int?      lastParsed      = null;
            ModHeader headerMeta      = stream.GetModHeader(package);
            var       minimumFinalPos = checked ((int)(stream.Position + headerMeta.TotalLength));

            fill(
                stream: stream,
                finalPos: minimumFinalPos,
                offset: 0,
                type: headerMeta.RecordType,
                lastParsed: lastParsed,
                recordTypeConverter: null);
            stream.Position = (int)headerMeta.TotalLength;
            while (!stream.Complete)
            {
                GroupHeader groupMeta = stream.GetGroup(package);
                if (!groupMeta.IsGroup)
                {
                    throw new ArgumentException("Did not see GRUP header as expected.");
                }
                if (groupMeta.ContentLength == 0)
                {
                    stream.Position += groupMeta.TotalLength;
                    continue;
                }
                minimumFinalPos = checked ((int)(stream.Position + groupMeta.TotalLength));
                var parsed = fill(
                    stream: stream,
                    finalPos: minimumFinalPos,
                    offset: 0,
                    type: groupMeta.ContainedRecordType,
                    lastParsed: lastParsed,
                    recordTypeConverter: null);
                if (!parsed.KeepParsing)
                {
                    break;
                }
                if (!parsed.KeepParsing)
                {
                    break;
                }
                if (minimumFinalPos > stream.Position)
                {
                    stream.Position = checked ((int)minimumFinalPos);
                }
                lastParsed = parsed.ParsedIndex;
            }
        }
Ejemplo n.º 4
0
        public static RecordType GetNextType(
            IMutagenReadStream reader,
            out int contentLength,
            out long finalPos,
            bool hopGroup = true)
        {
            GroupHeader groupMeta = reader.GetGroup();
            RecordType  ret       = groupMeta.RecordType;

            contentLength = checked ((int)groupMeta.RecordLength);
            if (groupMeta.IsGroup)
            {
                if (hopGroup)
                {
                    ret = groupMeta.ContainedRecordType;
                }
                finalPos = reader.Position + groupMeta.TotalLength;
            }
            else
            {
                finalPos = reader.Position + reader.MetaData.Constants.MajorConstants.HeaderLength + contentLength;
            }
            return(ret);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="header">Existing GroupHeader struct</param>
 /// <param name="span">Span to overlay on, aligned to the start of the Group's header</param>
 public GroupMemoryFrame(GroupHeader header, ReadOnlyMemorySlice <byte> span)
 {
     this.Header = header;
     this.HeaderAndContentData = span.Slice(0, checked ((int)this.Header.TotalLength));
 }
Ejemplo n.º 6
0
 public static bool TryReadGroup(this IMutagenReadStream stream, out GroupHeader header, bool checkIsGroup = true) => stream.MetaData.Constants.TryReadGroup(stream, out header, checkIsGroup);