aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/Utilities/StructWriter.cs
blob: 86cfeedd776a96d87f2966307567d4de6b58760a (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 ChocolArm64.Memory;
using System.Runtime.InteropServices;

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

        public long Position { get; private set; }

        public StructWriter(MemoryManager 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>();
        }
    }
}