Skip to content

Commit

Permalink
writer length
Browse files Browse the repository at this point in the history
  • Loading branch information
alec1o authored Sep 4, 2023
1 parent fffd19c commit b9707e6
Showing 1 changed file with 102 additions and 1 deletion.
103 changes: 102 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Byter
#### Byte parse. Convert byte to object and object to byte
Byter is a bytes serializer. It can serialize and deserialize from primitive type.

## Usage

Expand Down Expand Up @@ -29,6 +29,107 @@ using Byter
]
```

<hr/>

## Reader
> Proprietary
- #### ``Length``
```cs
using Byter;

var w = new Writer();

// Get lenght of buffer
int lenght = w.Length;
```

<br/>

> Methods
- #### ``Write(dynamic value)``
```cs
using Byter;

// Create writer instance;
using var w = new Writer();

// Write string
w.Write("KEZERO");

// Write char
w.Write('K');

// Write Float3 (Vector3)
w.Write(new Float3(10F, 10F, 10F));

// Get bytes (buffer)
byte[] buffer = w.GetBytes();

// Get byte list (buffer)
List<byte> bytes = w.GetList();
```

- #### ``GetBytes()``
```cs
using Byter;

var w = new Writer();

// Return buffer on <Writer> instance
byte[] buffer = w.GetBytes();
```

- #### ``GetList()``
```cs
using Byter;

var w = new Writer();

// Return buffer on <Writer> instance as byte list
List<byte> bytes = w.GetList();
```

- #### ``Clear()``
```cs
using Byter;

var w = new Writer();
w.Write((int)1000);
w.Write((float)100f);

// Clear internal buffer and reset internal index
w.Clear();
```


- #### ``Reader.Read<T>(T type)``
```cs
using Byter;

byte[] buffer = ...;

// Create reader instance
using r = new Reader(buffer);

string name = r.Read<string>();
char firstLatter = r.Read<char>();
Float3 position = r.Read<Float3>();

// Check if is success
if (r.Success)
{
Console.WriteLine($"Name: {name}");
Console.WriteLine($"First Latter: {firstLatter}");
Console.WriteLine($"Position: {position}");
}
else
{
Console.WriteLine("Error on get data");
}
```



- #### Writer
```csharp
using Byter;
Expand Down

0 comments on commit b9707e6

Please sign in to comment.