예제 #1
0
        public virtual string Parse(
            MutagenFrame frame,
            bool parseWhole = true,
            StringBinaryType stringBinaryType = StringBinaryType.NullTerminate)
        {
            switch (stringBinaryType)
            {
            case StringBinaryType.Plain:
            case StringBinaryType.NullTerminate:
                if (parseWhole)
                {
                    return(BinaryStringUtility.ProcessWholeToZString(frame.ReadMemory(checked ((int)frame.Remaining))));
                }
                else
                {
                    return(BinaryStringUtility.ParseUnknownLengthString(frame.Reader));
                }

            case StringBinaryType.PrependLength:
            {
                var len = frame.ReadInt32();
                return(BinaryStringUtility.ToZString(frame.ReadMemory(len)));
            }

            case StringBinaryType.PrependLengthUShort:
            {
                var len = frame.ReadInt16();
                return(BinaryStringUtility.ToZString(frame.ReadMemory(len)));
            }

            default:
                throw new NotImplementedException();
            }
        }
예제 #2
0
 /// <summary>
 /// Reads a ZString from the binary stream
 /// </summary>
 /// <param name="stream">Stream to read from</param>
 /// <param name="length">Length of the zstring</param>
 /// <returns>ZString of desired length</returns>
 public static string ReadZString(this IBinaryReadStream stream, int length)
 {
     return(BinaryStringUtility.ToZString(stream.ReadMemory(length)));
 }