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(); } }
public void WriteNullable( MutagenWriter writer, ITranslatedStringGetter?item, RecordType header, StringBinaryType binaryType, StringsSource source) { if (item == null) { return; } using (HeaderExport.Header(writer, header, ObjectType.Subrecord)) { if (writer.MetaData.StringsWriter == null) { writer.Write( item.String, binaryType: binaryType); } else { writer.Write(writer.MetaData.StringsWriter.Register(item, source)); } } }
public void WriteNullable( MutagenWriter writer, ITranslatedStringGetter?item, RecordType header, StringBinaryType binaryType, StringsSource source) { if (item == null) { return; } try { using (HeaderExport.Header(writer, header, ObjectType.Subrecord)) { if (writer.MetaData.StringsWriter == null) { writer.Write( item.String ?? string.Empty, binaryType: binaryType); } else { writer.Write(writer.MetaData.StringsWriter.Register(item, source)); } } } catch (Exception ex) { throw SubrecordException.Factory(ex, header); } }
public void Write( MutagenWriter writer, string item, StringBinaryType binaryType) { writer.Write(item, binaryType); }
public bool Parse( MutagenFrame frame, bool parseWhole, out string item, StringBinaryType binaryType = StringBinaryType.NullTerminate) { item = Parse(frame, parseWhole: parseWhole, stringBinaryType: binaryType); return(true); }
public bool Parse( MutagenFrame frame, StringsSource source, StringBinaryType binaryType, out TranslatedString item, bool parseWhole = true) { item = Parse(frame, source, binaryType, parseWhole); return(true); }
public void Write( MutagenWriter writer, string item, RecordType header, StringBinaryType binaryType = StringBinaryType.NullTerminate) { using (HeaderExport.Header(writer, header, ObjectType.Subrecord)) { writer.Write( item, binaryType: binaryType); } }
public void WriteNullable( MutagenWriter writer, string?item, StringBinaryType binaryType = StringBinaryType.NullTerminate) { if (item == null) { return; } writer.Write( item, binaryType: binaryType); }
public void Write( MutagenWriter writer, ITranslatedStringGetter item, RecordType header, StringBinaryType binaryType, StringsSource source) { using (HeaderExport.Header(writer, header, ObjectType.Subrecord)) { Write( writer, item, binaryType, source); } }
public void Write( MutagenWriter writer, ITranslatedStringGetter item, StringBinaryType binaryType, StringsSource source) { if (writer.MetaData.StringsWriter == null) { writer.Write( item.String, binaryType: binaryType); } else { writer.Write(writer.MetaData.StringsWriter.Register(item, source)); } }
public void WriteNullable( MutagenWriter writer, string?item, RecordType header, StringBinaryType binaryType = StringBinaryType.NullTerminate) { if (item == null) { return; } using (HeaderExport.Header(writer, header, ObjectType.Subrecord)) { writer.Write( item, binaryType: binaryType); } }
public void Write( MutagenWriter writer, string item, RecordType header, StringBinaryType binaryType = StringBinaryType.NullTerminate) { try { using (HeaderExport.Header(writer, header, ObjectType.Subrecord)) { writer.Write( item, binaryType: binaryType); } } catch (Exception ex) { throw SubrecordException.Factory(ex, header); } }
public void WriteNullable( MutagenWriter writer, ITranslatedStringGetter?item, StringBinaryType binaryType, StringsSource source) { if (item == null) { return; } if (writer.MetaData.StringsWriter == null) { writer.Write( item.String ?? string.Empty, binaryType: binaryType); } else { writer.Write(writer.MetaData.StringsWriter.Register(item, source)); } }
public void Write( MutagenWriter writer, ITranslatedStringGetter item, RecordType header, StringBinaryType binaryType, StringsSource source) { try { using (HeaderExport.Header(writer, header, ObjectType.Subrecord)) { Write( writer, item, binaryType, source); } } catch (Exception ex) { throw SubrecordException.Factory(ex, header); } }
public TranslatedString Parse( MutagenFrame reader, StringsSource source, StringBinaryType stringBinaryType, bool parseWhole = true) { if (reader.MetaData.StringsLookup != null) { if (reader.Remaining != 4) { throw new ArgumentException($"String in Strings File format had unexpected length: {reader.Remaining} != 4"); } uint key = reader.ReadUInt32(); if (key == 0) { return(new TranslatedString(directString: null)); } return(reader.MetaData.StringsLookup.CreateString(source, key)); } else { return(Parse(reader, parseWhole, stringBinaryType)); } }
public virtual TranslatedString Parse( MutagenFrame frame, StringsSource source, StringBinaryType stringBinaryType, bool parseWhole = true) { if (frame.MetaData.StringsLookup != null) { if (frame.Remaining != 4) { throw new ArgumentException($"String in Strings File format had unexpected length: {frame.Remaining} != 4"); } uint key = frame.ReadUInt32(); if (key == 0) { return(string.Empty); } return(frame.MetaData.StringsLookup.CreateString(source, key)); } else { return(Parse(frame, parseWhole, stringBinaryType)); } }
public void WriteNullable( MutagenWriter writer, string?item, RecordType header, StringBinaryType binaryType = StringBinaryType.NullTerminate) { if (item == null) { return; } try { using (HeaderExport.Header(writer, header, ObjectType.Subrecord)) { writer.Write( item, binaryType: binaryType); } } catch (Exception ex) { throw SubrecordException.Enrich(ex, header); } }
public override async Task Load(XElement node, bool requireName = true) { this.BinaryType = node.GetAttribute <StringBinaryType>("binaryType", defaultVal: StringBinaryType.NullTerminate); this.Translated = node.GetAttribute <StringsSource?>("translated", defaultVal: null); await base.Load(node, requireName); }