aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/Utilities/StructWriter.cs
blob: c156956db7172b8a31359926b2441a9a42d2aa0a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
using ARMeilleure.Memory;
using System.Runtime.InteropServices;

namespace Ryujinx.HLE.Utilities
{
    class StructWriter
    {
        private IMemoryManager _memory;

        public long Position { get; private set; }

        public StructWriter(IMemoryManager memory, long position)
        {
            _memory  = memory;
            Position = position;
        }

        public void Write<T>(T value) where T : struct
        {
            MemoryHelper.Write(_memory, Position, value);

            Position += Marshal.SizeOf<T>();
        }
    }
}