Наследование: EndianBinaryWriter
Пример #1
0
 public void Write(LngBinaryWriter writer)
 {
     writer.Write(Magic);
     writer.Write(Size);
     writer.Write(Buckets);
     writer.Write(Seed);
     writer.Write(Multiplier);
 }
Пример #2
0
 public void Write(LngBinaryWriter writer)
 {
     writer.Write(Magic);
     writer.Write(Size);
     writer.Write(Buckets);
     writer.Write(Seed);
     writer.Write(Multiplier);
 }
Пример #3
0
        public void Write(Stream fileStream)
        {
            // SETUP
            sida.Size  = count * 8;
            sida.Entry = new SidaEntry[count];
            List <byte> keys = new List <byte>(sidb.Size), values = new List <byte>(lngb.Size);

            byte[] keyBytes, valueBytes;
            int    keyOffset = 0, valueOffset = 0;
            int    index = 0;

            foreach (HashEntry entry in hsht.Entries)
            {
                sida.Entry[index].KeyOffset   = keyOffset;
                sida.Entry[index].ValueOffset = valueOffset;

                keyBytes   = encoding.GetBytes(entry.Key);
                valueBytes = encoding.GetBytes(entry.Value);
                keys.AddRange(keyBytes);
                keys.Add(0x00);
                values.AddRange(valueBytes);
                values.Add(0x00);

                keyOffset   += keyBytes.Length + 1;
                valueOffset += valueBytes.Length + 1;
                index++;
            }
            sidb.Size = keyOffset;
            lngb.Size = valueOffset;

            // Write
            using (LngBinaryWriter b = new LngBinaryWriter(BigEndianBitConverter.Big, fileStream))
            {
                b.Write(magic);
                // Final size = all section sizes + hshsSize12 + 5 * 4byte magics + 5 * 4byte sizes + sidanumEntries + lngtmagic + lngsize
                b.Write(0);

                hshs.Write(b);
                hsht.Write(b);

                sida.Write(b);
                // SIDB
                b.Write(sidb.Magic);
                b.Write(sidb.Size);
                b.Write(keys.ToArray());
                // LNGB
                b.Write(lngb.Magic);
                b.Write(lngb.Size);
                b.Write(values.ToArray());

                b.Seek(4, SeekOrigin.Begin);
                b.Write((int)b.BaseStream.Length);
            }

            hasChanges = false;
        }
Пример #4
0
 public void Write(LngBinaryWriter writer)
 {
     writer.Write(Magic);
     writer.Write(Size);
     writer.Write(Entry.Length);
     for (int i = 0; i < Entry.Length; i++)
     {
         writer.Write(Entry[i].KeyOffset);
         writer.Write(Entry[i].ValueOffset);
     }
 }
Пример #5
0
 public void Write(LngBinaryWriter writer)
 {
     writer.Write(Magic);
     writer.Write(Size);
     writer.Write(Entry.Length);
     for (int i = 0; i < Entry.Length; i++)
     {
         writer.Write(Entry[i].KeyOffset);
         writer.Write(Entry[i].ValueOffset);
     }
 }
Пример #6
0
        public void Write(LngBinaryWriter writer)
        {
            writer.Write(Magic);
            Size = Table.Length * 8;
            writer.Write(Size);

            int bucket = 0;

            for (int hash = 0; hash < Table.Length; hash++)
            {
                if (Table[hash].Count == 0)
                {
                    writer.Write(0);
                }
                else
                {
                    writer.Write(bucket);
                    bucket += Table[hash].Count;
                }
                writer.Write(Table[hash].Count);
            }
        }
Пример #7
0
        public void Write(LngBinaryWriter writer)
        {
            writer.Write(Magic);
            Size = Table.Length * 8;
            writer.Write(Size);

            int bucket = 0;
            for (int hash = 0; hash < Table.Length; hash++)
            {
                if (Table[hash].Count == 0)
                    writer.Write(0);
                else
                {
                    writer.Write(bucket);
                    bucket += Table[hash].Count;
                }
                writer.Write(Table[hash].Count);
            }
        }
Пример #8
0
        public void Write(Stream fileStream)
        {
            // SETUP
            sida.Size = count * 8;
            sida.Entry = new SidaEntry[count];
            List<byte> keys = new List<byte>(sidb.Size), values = new List<byte>(lngb.Size);
            byte[] keyBytes, valueBytes;
            int keyOffset = 0, valueOffset = 0;
            int index = 0;
            foreach (HashEntry entry in hsht.Entries)
            {
                sida.Entry[index].KeyOffset = keyOffset;
                sida.Entry[index].ValueOffset = valueOffset;

                keyBytes = encoding.GetBytes(entry.Key);
                valueBytes = encoding.GetBytes(entry.Value);
                keys.AddRange(keyBytes);
                keys.Add(0x00);
                values.AddRange(valueBytes);
                values.Add(0x00);

                keyOffset += keyBytes.Length + 1;
                valueOffset += valueBytes.Length + 1;
                index++;
            }
            sidb.Size = keyOffset;
            lngb.Size = valueOffset;

            // Write
            using (LngBinaryWriter b = new LngBinaryWriter(BigEndianBitConverter.Big, fileStream))
            {
                b.Write(magic);
                // Final size = all section sizes + hshsSize12 + 5 * 4byte magics + 5 * 4byte sizes + sidanumEntries + lngtmagic + lngsize
                b.Write(0);

                hshs.Write(b);
                hsht.Write(b);

                sida.Write(b);
                // SIDB
                b.Write(sidb.Magic);
                b.Write(sidb.Size);
                b.Write(keys.ToArray());
                // LNGB
                b.Write(lngb.Magic);
                b.Write(lngb.Size);
                b.Write(values.ToArray());

                b.Seek(4, SeekOrigin.Begin);
                b.Write((int)b.BaseStream.Length);
            }

            hasChanges = false;
        }