UniVRM/UniJSON/Scripts/IStore/IStore.cs
ousttrue df85433628 Merge commit 'df5f79584312cf4f6cc7ec1d73a78f6ba475c9ad' as 'UniJSON'
Co-authored-by: Deatrathias <dmailsec@gmail.com>
Co-authored-by: dj-kusuha <dj.kusuha+github@gmail.com>
Co-authored-by: ousttrue <ousttrue@gmail.com>
Co-authored-by: yutopp <yutopp@gmail.com>
2018-12-28 20:38:39 +09:00

64 lines
1.8 KiB
C#

using System;
using System.Linq;
using System.Collections.Generic;
namespace UniJSON
{
public interface IStore
{
void Clear();
ArraySegment<Byte> Bytes { get; }
void Write(Byte value);
void Write(SByte value);
// network
void WriteBigEndian(UInt16 value);
void WriteBigEndian(UInt32 value);
void WriteBigEndian(UInt64 value);
void WriteBigEndian(Int16 value);
void WriteBigEndian(Int32 value);
void WriteBigEndian(Int64 value);
void WriteBigEndian(Single value);
void WriteBigEndian(Double value);
// intel cpu
void WriteLittleEndian(UInt16 value);
void WriteLittleEndian(UInt32 value);
void WriteLittleEndian(UInt64 value);
void WriteLittleEndian(Int16 value);
void WriteLittleEndian(Int32 value);
void WriteLittleEndian(Int64 value);
void WriteLittleEndian(Single value);
void WriteLittleEndian(Double value);
void Write(ArraySegment<Byte> bytes);
void Write(string src);
void Write(char c);
}
public static class IStoreExtensions
{
public static void WriteValues(this IStore s, params Byte[] bytes)
{
s.Write(new ArraySegment<Byte>(bytes));
}
public static void Write(this IStore s, Byte[] bytes)
{
s.Write(new ArraySegment<Byte>(bytes));
}
public static void Write(this IStore s, IEnumerable<Byte> bytes)
{
s.Write(new ArraySegment<Byte>(bytes.ToArray()));
}
public static Utf8String ToUtf8String(this IStore s)
{
return new Utf8String(s.Bytes);
}
}
}