public string Parse( MutagenFrame reader, bool parseWhole = true, StringBinaryType stringBinaryType = StringBinaryType.NullTerminate) { switch (stringBinaryType) { case StringBinaryType.Plain: case StringBinaryType.NullTerminate: if (parseWhole) { return(BinaryStringUtility.ProcessWholeToZString(reader.ReadMemory(checked ((int)reader.Remaining)))); } else { return(BinaryStringUtility.ParseUnknownLengthString(reader.Reader)); } case StringBinaryType.PrependLength: { var len = reader.ReadInt32(); return(BinaryStringUtility.ToZString(reader.ReadMemory(len))); } case StringBinaryType.PrependLengthUShort: { var len = reader.ReadInt16(); return(BinaryStringUtility.ToZString(reader.ReadMemory(len))); } default: throw new NotImplementedException(); } }
public static partial void FillBinaryEffectInitialCustom(MutagenFrame frame, IEffect item) { var subMeta = frame.ReadSubrecord(); if (subMeta.ContentLength != Plugins.Internals.Constants.HeaderLength) { throw new ArgumentException($"Magic effect name must be length 4. Was: {subMeta.ContentLength}"); } var magicEffName = frame.ReadMemory(4); if (!frame.Reader.TryGetSubrecord(RecordTypes.EFIT, out var efitMeta)) { throw new ArgumentException("Expected EFIT header."); } if (efitMeta.ContentLength < Plugins.Internals.Constants.HeaderLength) { throw new ArgumentException($"Magic effect ref length was less than 4. Was: {efitMeta.ContentLength}"); } var magicEffName2 = frame.GetMemory(amount: Plugins.Internals.Constants.HeaderLength, offset: efitMeta.HeaderLength); if (!magicEffName.Span.SequenceEqual(magicEffName2.Span)) { throw new ArgumentException($"Magic effect names did not match. {BinaryStringUtility.ToZString(magicEffName)} != {BinaryStringUtility.ToZString(magicEffName2)}"); } }
public static partial ParseResult FillBinaryEffectInitialCustom(MutagenFrame frame, IEffect item, PreviousParse lastParsed) { var subMeta = frame.ReadSubrecord(); if (subMeta.ContentLength != Mutagen.Bethesda.Plugins.Internals.Constants.HeaderLength) { throw new ArgumentException($"Magic effect name must be length 4. Was: {subMeta.ContentLength}"); } var magicEffName = frame.ReadMemory(4); if (!frame.Reader.TryGetSubrecord(RecordTypes.EFIT, out var efitMeta)) { throw new ArgumentException("Expected EFIT header."); } if (efitMeta.ContentLength < Mutagen.Bethesda.Plugins.Internals.Constants.HeaderLength) { throw new ArgumentException($"Magic effect ref length was less than 4. Was: {efitMeta.ContentLength}"); } var magicEffName2 = frame.GetMemory(amount: Mutagen.Bethesda.Plugins.Internals.Constants.HeaderLength, offset: efitMeta.HeaderLength); if (!magicEffName.Span.SequenceEqual(magicEffName2.Span)) { throw new ArgumentException($"Magic effect names did not match. {BinaryStringUtility.ToZString(magicEffName, frame.MetaData.Encodings.NonTranslated)} != {BinaryStringUtility.ToZString(magicEffName2, frame.MetaData.Encodings.NonTranslated)}"); } return(lastParsed.ParsedIndex); }