コード例 #1
0
        public uint Add(XmbFileBuilder builder, int v)
        {
            foreach (var kv in mEntries)
            {
                if (kv.Value.Equals(v))
                {
                    return(kv.Key);
                }
            }

            var entry = PoolEntry.New(v);

            return(Add(builder, entry));
        }
コード例 #2
0
        PoolEntry DeBuffer(XmbVariantType type, uint offset, byte flags = 0)
        {
            if (!ValidOffset(offset))
            {
                throw new ArgumentOutOfRangeException("offset", string.Format("{0} > {1}",
                                                                              offset.ToString("X8"), mPoolSize.ToString("X6")));
            }

            PoolEntry e;

            if (!mEntries.TryGetValue(offset, out e))
            {
                if (mBufferedDataRemaining == 0)
                {
                    throw new InvalidOperationException("No data left in buffer");
                }
                else if (mBuffer == null)
                {
                    throw new InvalidOperationException("No underlying buffer");
                }

                // Create our new entry, setting any additional properties
                e = PoolEntry.New(type);
                if (type == XmbVariantType.String)
                {
                    e.IsUnicode = flags != 0;
                }
                else if (type == XmbVariantType.Vector)
                {
                    e.VectorLength = flags;
                }
                // Great, now read the entry's value data
                mBuffer.Seek32(offset);
                e.Read(mBuffer);

                // Update how much data is still remaining
                uint bytes_read = (uint)(mBuffer.BaseStream.Position - offset);
                mBufferedDataRemaining -= bytes_read;

                if (mBufferedDataRemaining == 0)
                {
                    DisposeBuffer();
                }

                mEntries.Add(offset, e);
            }

            return(e);
        }
コード例 #3
0
        public uint Add(XmbFileBuilder builder, string v, bool isUnicode = false)
        {
            foreach (var kv in mEntries)
            {
                if (kv.Value.Equals(v))
                {
                    return(kv.Key);
                }
            }

            var entry = PoolEntry.New(v);

            entry.IsUnicode = isUnicode;
            return(Add(builder, entry));
        }
コード例 #4
0
        PoolEntry DeBuffer(BinaryDataTreeVariantTypeDesc desc, uint offset, bool sizeIsIndirect = false)
        {
            if (!ValidOffset(offset))
            {
                throw new ArgumentOutOfRangeException("offset", string.Format("{0} > {1}",
                                                                              offset.ToString("X8"), mPoolSize.ToString("X6")));
            }

            PoolEntry e;

            if (!mEntries.TryGetValue(offset, out e))
            {
                if (mBufferedDataRemaining == 0)
                {
                    throw new InvalidOperationException("No data left in buffer");
                }
                else if (mBuffer == null)
                {
                    throw new InvalidOperationException("No underlying buffer");
                }

                // Create our new entry, setting any additional properties
                e = PoolEntry.New(desc);
                if (sizeIsIndirect)
                {
                    uint size = GetSizeValue(offset);
                    e.ArrayLength = (int)(size >> desc.SizeBit);
                }
                // Great, now read the entry's value data
                mBuffer.Seek32(offset);
                e.Read(mBuffer);

                // Update how much data is still remaining
                uint bytes_read = (uint)(mBuffer.BaseStream.Position - offset);
                mBufferedDataRemaining -= bytes_read;

                if (mBufferedDataRemaining == 0)
                {
                    DisposeBuffer();
                }

                mEntries.Add(offset, e);
            }

            return(e);
        }