-
Notifications
You must be signed in to change notification settings - Fork 0
/
OscArgument.cs
47 lines (36 loc) · 1.12 KB
/
OscArgument.cs
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System;
namespace Suhock.Osc;
/// <summary>
/// Base class for OSC protocol message arguments
/// </summary>
public abstract class OscArgument : IOscArgument
{
public abstract byte TypeTag { get; }
public abstract int GetByteCount();
public abstract byte[] GetBytes();
public int WriteBytes(byte[] target) =>
WriteBytes(target, 0);
public int WriteBytes(byte[] target, int startIndex) =>
WriteBytes(target.AsSpan(startIndex, GetByteCount()));
public abstract int WriteBytes(Span<byte> target);
public abstract override string ToString();
}
/// <summary>
/// Represents an OSC protocol message argument with a value of native type <c>T</c>
/// </summary>
/// <typeparam name="T">The native type that this argument type represents</typeparam>
public abstract class OscArgument<T> : OscArgument
{
/// <summary>
/// The value of the argument
/// </summary>
public T Value { get; protected init; }
protected OscArgument(T value)
{
Value = value;
}
public override string ToString()
{
return '[' + Value?.ToString() + ']';
}
}