-
-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #624 from Reousa/update-serializer
- Loading branch information
Showing
11 changed files
with
2,087 additions
and
2,215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
// #pragma once | ||
// #ifndef INetDataReader.cs_H_ | ||
// #define INetDataReader.cs_H_ | ||
// | ||
// #endif | ||
|
||
using System; | ||
using System.Net; | ||
using System.Runtime.CompilerServices; | ||
|
||
namespace NebulaAPI.Interfaces; | ||
|
||
public interface INetDataReader | ||
{ | ||
byte[] RawData | ||
{ | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
get; | ||
} | ||
|
||
int RawDataSize | ||
{ | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
get; | ||
} | ||
|
||
int UserDataOffset | ||
{ | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
get; | ||
} | ||
|
||
int UserDataSize | ||
{ | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
get; | ||
} | ||
|
||
bool IsNull | ||
{ | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
get; | ||
} | ||
|
||
int Position | ||
{ | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
get; | ||
} | ||
|
||
bool EndOfData | ||
{ | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
get; | ||
} | ||
|
||
int AvailableBytes | ||
{ | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
get; | ||
} | ||
|
||
void SkipBytes(int count); | ||
void SetPosition(int position); | ||
void SetSource(INetDataWriter dataWriter); | ||
void SetSource(byte[] source); | ||
void SetSource(byte[] source, int offset, int maxSize); | ||
IPEndPoint GetNetEndPoint(); | ||
byte GetByte(); | ||
sbyte GetSByte(); | ||
T[] GetArray<T>(int size); | ||
bool[] GetBoolArray(); | ||
ushort[] GetUShortArray(); | ||
short[] GetShortArray(); | ||
int[] GetIntArray(); | ||
uint[] GetUIntArray(); | ||
float[] GetFloatArray(); | ||
double[] GetDoubleArray(); | ||
long[] GetLongArray(); | ||
ulong[] GetULongArray(); | ||
string[] GetStringArray(); | ||
|
||
/// <summary> | ||
/// Note that "maxStringLength" only limits the number of characters in a string, not its size in bytes. | ||
/// Strings that exceed this parameter are returned as empty | ||
/// </summary> | ||
string[] GetStringArray(int maxStringLength); | ||
|
||
bool GetBool(); | ||
char GetChar(); | ||
ushort GetUShort(); | ||
short GetShort(); | ||
long GetLong(); | ||
ulong GetULong(); | ||
int GetInt(); | ||
uint GetUInt(); | ||
float GetFloat(); | ||
double GetDouble(); | ||
|
||
/// <summary> | ||
/// Note that "maxLength" only limits the number of characters in a string, not its size in bytes. | ||
/// </summary> | ||
/// <returns>"string.Empty" if value > "maxLength"</returns> | ||
string GetString(int maxLength); | ||
|
||
string GetString(); | ||
ArraySegment<byte> GetBytesSegment(int count); | ||
ArraySegment<byte> GetRemainingBytesSegment(); | ||
T Get<T>() where T : struct, INetSerializable; | ||
T Get<T>(Func<T> constructor) where T : class, INetSerializable; | ||
byte[] GetRemainingBytes(); | ||
void GetBytes(byte[] destination, int start, int count); | ||
void GetBytes(byte[] destination, int count); | ||
sbyte[] GetSBytesWithLength(); | ||
byte[] GetBytesWithLength(); | ||
byte PeekByte(); | ||
sbyte PeekSByte(); | ||
bool PeekBool(); | ||
char PeekChar(); | ||
ushort PeekUShort(); | ||
short PeekShort(); | ||
long PeekLong(); | ||
ulong PeekULong(); | ||
int PeekInt(); | ||
uint PeekUInt(); | ||
float PeekFloat(); | ||
double PeekDouble(); | ||
|
||
/// <summary> | ||
/// Note that "maxLength" only limits the number of characters in a string, not its size in bytes. | ||
/// </summary> | ||
string PeekString(int maxLength); | ||
|
||
string PeekString(); | ||
bool TryGetByte(out byte result); | ||
bool TryGetSByte(out sbyte result); | ||
bool TryGetBool(out bool result); | ||
bool TryGetChar(out char result); | ||
bool TryGetShort(out short result); | ||
bool TryGetUShort(out ushort result); | ||
bool TryGetInt(out int result); | ||
bool TryGetUInt(out uint result); | ||
bool TryGetLong(out long result); | ||
bool TryGetULong(out ulong result); | ||
bool TryGetFloat(out float result); | ||
bool TryGetDouble(out double result); | ||
bool TryGetString(out string result); | ||
bool TryGetStringArray(out string[] result); | ||
bool TryGetBytesWithLength(out byte[] result); | ||
void Clear(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// #pragma once | ||
// #ifndef INetDataWriter.cs_H_ | ||
// #define INetDataWriter.cs_H_ | ||
// | ||
// #endif | ||
|
||
using System; | ||
using System.Net; | ||
using System.Runtime.CompilerServices; | ||
|
||
namespace NebulaAPI.Interfaces; | ||
|
||
public interface INetDataWriter | ||
{ | ||
int Capacity | ||
{ | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
get; | ||
} | ||
|
||
byte[] Data | ||
{ | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
get; | ||
} | ||
|
||
int Length | ||
{ | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
get; | ||
} | ||
|
||
void ResizeIfNeed(int newSize); | ||
void EnsureFit(int additionalSize); | ||
void Reset(int size); | ||
void Reset(); | ||
byte[] CopyData(); | ||
|
||
/// <summary> | ||
/// Sets position of NetDataWriter to rewrite previous values | ||
/// </summary> | ||
/// <param name="position">new byte position</param> | ||
/// <returns>previous position of data writer</returns> | ||
int SetPosition(int position); | ||
|
||
void Put(float value); | ||
void Put(double value); | ||
void Put(long value); | ||
void Put(ulong value); | ||
void Put(int value); | ||
void Put(uint value); | ||
void Put(char value); | ||
void Put(ushort value); | ||
void Put(short value); | ||
void Put(sbyte value); | ||
void Put(byte value); | ||
void Put(byte[] data, int offset, int length); | ||
void Put(byte[] data); | ||
void Put(bool value); | ||
void Put(IPEndPoint endPoint); | ||
void Put(string value); | ||
|
||
/// <summary> | ||
/// Note that "maxLength" only limits the number of characters in a string, not its size in bytes. | ||
/// </summary> | ||
void Put(string value, int maxLength); | ||
|
||
void Put<T>(T obj) where T : INetSerializable; | ||
void PutSBytesWithLength(sbyte[] data, int offset, int length); | ||
void PutSBytesWithLength(sbyte[] data); | ||
void PutBytesWithLength(byte[] data, int offset, int length); | ||
void PutBytesWithLength(byte[] data); | ||
void PutArray(Array arr, int sz); | ||
void PutArray(float[] value); | ||
void PutArray(double[] value); | ||
void PutArray(long[] value); | ||
void PutArray(ulong[] value); | ||
void PutArray(int[] value); | ||
void PutArray(uint[] value); | ||
void PutArray(ushort[] value); | ||
void PutArray(short[] value); | ||
void PutArray(bool[] value); | ||
void PutArray(string[] value); | ||
void PutArray(string[] value, int strMaxLength); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.