/// <summary> /// Read ctor /// </summary> internal Type(TypeSpec parent, ResReader reader) : base(reader, ChunkTypes.RES_TABLE_TYPE_TYPE) { this.parent = parent; var id = reader.ReadByte(); reader.Skip(3); // reserved if (id != parent.Id) { throw new IOException("Type id (" + id + ") " + "doesn't match parent id (" + parent.Id + ")."); } var entryCount = reader.ReadInt32(); if (entryCount != parent.EntryCount) { throw new IOException(string.Format("Type entry count ({0}) doesn't match parent entry count ({1})", entryCount, parent.EntryCount)); } var entriesStart = reader.ReadInt32(); configuration = new Configuration(reader); // Data var offsets = reader.ReadIntArray(entryCount); var dataSize = (Size - entriesStart); if ((dataSize % 4) != 0) { throw new IOException("Type data size (" + dataSize + ") is not multiple of 4."); } for (var i = 0; i < entryCount; i++ ) { if (offsets[i] != NO_ENTRY) { var actualOffset = reader.Position; var instance = EntryInstance.Read(this, reader); parent.GetEntry(i).Add(instance); } } }
/// <summary> /// Reading ctor /// </summary> internal Value(ResReader reader) { var size = reader.ReadUInt16(); reader.Skip(1); // res0 type = (Types)reader.ReadByte(); data = reader.ReadInt32(); }
/// <summary> /// Reading ctor /// </summary> protected Node(ResReader reader, XmlTree tree, ChunkTypes expectedType) : base(reader, expectedType) { this.tree = tree; LineNumber = reader.ReadInt32(); Comment = StringPoolRef.Read(reader, tree.StringPool); }
/// <summary> /// Reading ctor /// </summary> protected Node(ResReader reader, XmlTree tree, ChunkTypes expectedType) : base(reader, expectedType) { this.tree = tree; LineNumber = reader.ReadInt32(); Comment = StringPoolRef.Read(reader, tree.StringPool); }
/// <summary> /// Reading ctor /// </summary> internal Value(ResReader reader) { var size = reader.ReadUInt16(); reader.Skip(1); // res0 type = (Types)reader.ReadByte(); data = reader.ReadInt32(); }
/// <summary> /// Default ctor /// </summary> internal Package(Table table, ResReader reader) : base(reader, ChunkTypes.RES_TABLE_PACKAGE_TYPE) { this.table = table; id = reader.ReadInt32(); name = reader.ReadFixedLenghtUnicodeString(128); var typeStringsOffset = reader.ReadInt32(); var lastPublicType = reader.ReadInt32(); var keyStringsOffset = reader.ReadInt32(); var lastPublicKey = reader.ReadInt32(); // Record offset var dataOffset = reader.Position; // Data typeStrings = new StringPool(reader); keyStrings = new StringPool(reader); TypeSpec currentTypeSpec = null; while (reader.Position - dataOffset < DataSize) { var chunkType = reader.PeekChunkType(); if (chunkType == ChunkTypes.RES_TABLE_TYPE_SPEC_TYPE) { currentTypeSpec = Read(reader, () => new TypeSpec(this, reader)); typeSpecs.Add(currentTypeSpec); } else if (chunkType == ChunkTypes.RES_TABLE_TYPE_TYPE) { if (currentTypeSpec == null) { throw new IOException("Invalid chunk sequence: content read before typeSpec."); } var parent = currentTypeSpec; var type = Read(reader, () => new Type(parent, reader)); currentTypeSpec.Add(type); } else { throw new IOException("Unexpected chunk type (" + chunkType + ")."); } } }
/// <summary> /// Default ctor /// </summary> internal Package(Table table, ResReader reader) : base(reader, ChunkTypes.RES_TABLE_PACKAGE_TYPE) { this.table = table; id = reader.ReadInt32(); name = reader.ReadFixedLenghtUnicodeString(128); var typeStringsOffset = reader.ReadInt32(); var lastPublicType = reader.ReadInt32(); var keyStringsOffset = reader.ReadInt32(); var lastPublicKey = reader.ReadInt32(); // Record offset var dataOffset = reader.Position; // Data typeStrings = new StringPool(reader); keyStrings = new StringPool(reader); TypeSpec currentTypeSpec = null; while (reader.Position - dataOffset < DataSize) { var chunkType = reader.PeekChunkType(); if (chunkType == ChunkTypes.RES_TABLE_TYPE_SPEC_TYPE) { currentTypeSpec = Read(reader, () => new TypeSpec(this, reader)); typeSpecs.Add(currentTypeSpec); } else if (chunkType == ChunkTypes.RES_TABLE_TYPE_TYPE) { if (currentTypeSpec == null) { throw new IOException("Invalid chunk sequence: content read before typeSpec."); } var parent = currentTypeSpec; var type = Read(reader, () => new Type(parent, reader)); currentTypeSpec.Add(type); } else { throw new IOException("Unexpected chunk type (" + chunkType + ")."); } } }
/// <summary> /// Default ctor /// </summary> internal StringPool(ResReader reader) : base(reader, ChunkTypes.RES_STRING_POOL_TYPE) { var stringCount = reader.ReadInt32(); var styleOffsetCount = reader.ReadInt32(); var flags = (StringPoolFlags)reader.ReadInt32(); IsUtf8 = ((flags & StringPoolFlags.UTF8_FLAG) != 0); var stringsStart = reader.ReadInt32(); var stylesStart = reader.ReadInt32(); var stringOffsets = reader.ReadIntArray(stringCount); if (styleOffsetCount != 0) { styleOffsets = reader.ReadIntArray(styleOffsetCount); } byte[] stringData; { var size = ((stylesStart == 0) ? Size : stylesStart) - stringsStart; if ((size % 4) != 0) { throw new IOException(string.Format("String data size is not multiple of 4 ({0}).", size)); } stringData = reader.ReadByteArray(size); } if (stylesStart != 0) { var size = (Size - stylesStart); if ((size % 4) != 0) { throw new IOException(string.Format("Style data size is not multiple of 4 ({0}).", size)); } styles = reader.ReadIntArray(size / 4); } var count = (stringOffsets != null) ? stringOffsets.Length : 0; for (var i = 0; i != count; ++i) { list.Add(new Entry(GetRaw(i, stringOffsets, stringData, IsUtf8, reader), -1)); } }
/// <summary> /// Default ctor /// </summary> internal Table(ResReader reader) : base(reader, ChunkTypes.RES_TABLE_TYPE) { var packageCount = reader.ReadInt32(); strings = new StringPool(reader); for (var i = 0; i < packageCount; i++) { packages.Add(new Package(this, reader)); } }
/// <summary> /// Default ctor /// </summary> internal Table(ResReader reader) : base(reader, ChunkTypes.RES_TABLE_TYPE) { var packageCount = reader.ReadInt32(); strings = new StringPool(reader); for (var i = 0; i < packageCount; i++) { packages.Add(new Package(this, reader)); } }
/// <summary> /// Reader ctor /// </summary> internal TypeSpec(Package parent, ResReader reader) : base(reader, ChunkTypes.RES_TABLE_TYPE_SPEC_TYPE) { this.parent = parent; id = reader.ReadByte(); reader.Skip(3); // reserved var entryCount = reader.ReadInt32(); var flags = reader.ReadIntArray(entryCount).ToList(); entries.AddRange(flags.Select(x => new Entry(this, x))); }
/// <summary> /// Read ctor /// </summary> internal ComplexEntryInstance(Type parent, ResReader reader) : base(parent, reader) { var parentResId = TableRef.Read(reader); var count = reader.ReadInt32(); //reader.Skip(count*12); for (var i = 0; i < count; i++) { maps.Add(new Map(this, reader)); } }
/// <summary> /// Reader ctor /// </summary> internal TypeSpec(Package parent, ResReader reader) : base(reader, ChunkTypes.RES_TABLE_TYPE_SPEC_TYPE) { this.parent = parent; id = reader.ReadByte(); reader.Skip(3); // reserved var entryCount = reader.ReadInt32(); var flags = reader.ReadIntArray(entryCount).ToList(); entries.AddRange(flags.Select(x => new Entry(this, x))); }
/// <summary> /// Read ctor /// </summary> internal ComplexEntryInstance(Type parent, ResReader reader) : base(parent, reader) { var parentResId = TableRef.Read(reader); var count = reader.ReadInt32(); //reader.Skip(count*12); for (var i = 0; i < count; i++) { maps.Add(new Map(this, reader)); } }
/// <summary> /// Read ctor /// </summary> internal Type(TypeSpec parent, ResReader reader) : base(reader, ChunkTypes.RES_TABLE_TYPE_TYPE) { this.parent = parent; var id = reader.ReadByte(); reader.Skip(3); // reserved if (id != parent.Id) { throw new IOException("Type id (" + id + ") " + "doesn't match parent id (" + parent.Id + ")."); } var entryCount = reader.ReadInt32(); if (entryCount != parent.EntryCount) { throw new IOException(string.Format("Type entry count ({0}) doesn't match parent entry count ({1})", entryCount, parent.EntryCount)); } var entriesStart = reader.ReadInt32(); configuration = new Configuration(reader); // Data var offsets = reader.ReadIntArray(entryCount); var dataSize = (Size - entriesStart); if ((dataSize % 4) != 0) { throw new IOException("Type data size (" + dataSize + ") is not multiple of 4."); } for (var i = 0; i < entryCount; i++) { if (offsets[i] != NO_ENTRY) { var actualOffset = reader.Position; var instance = EntryInstance.Read(this, reader); parent.GetEntry(i).Add(instance); } } }
/// <summary> /// Reader ctor /// </summary> protected Chunk(ResReader reader) { type = (ChunkTypes)reader.ReadUInt16(); headerSize = reader.ReadUInt16(); size = reader.ReadInt32(); }
/// <summary> /// Read ctor /// </summary> internal Configuration(ResReader reader) { var size = reader.ReadInt32(); data = reader.ReadByteArray(size - 4); }