C# High-level library for byte manipulation, and fast encode/decode of datas
Usage
Namespace
using ByteBolt;// default: Writer, Reader
using ByteBolt.Core;// internal usage
Accepted Types
TYPE
VALUE
Byte
byte, byte[]
Char
char, string
Int16
short, ushort
Int32
int, uint
Int64
long, ulong
Floating-Point
float, double
Writer
using System;using ByteBolt;// import to use: Writer, Readerusing ByteBolt.Core;// import to use: Segment, Encode [ ASCII, UTF7, UTF8, UTF32, UNICODE ]// create instanceWriterw=new Writer();// default;/*Writer w = new Writer(int <length>); // set default Segment lengthWriter w = bew Writer(Segment <segment>); // set existent Segment */// write
w.Write("ByteBolt", Encode.UTF8);// Write string with (Encode), the default is UTF8.
w.Write("int, string, byte[], char, float, double, ...");// encoded resultbyte[]array= w.ToArray();Segmentsegment= w.ToSegment();
Reader
using System;using ByteBolt;// create instanceReaderr=new Reader(ref w);// default;/*Reader r = new Reader(byte[] <buffer>); // set BufferReader r = new Reader(Writer <writer>); // set WriterReader r = bew Reader(Segment <segment>); // set Segment */// readerbytemyByte= r.ReadByte();stringmyString= r.ReadString();stringmyStrName= r.ReadString(Encode.UTF8);// Reader string with (Encode), the default is UTF8.// otherbytepeekIndex= r.Peek();// peek current reading indexbytepeekMyIndex= r.Peek(7);// peek at custom segment indexintcurrent= r.Current;// get the current reading indexintlength= r.Length;// get the reader Segment length// Seek: move the current reading Segment position:// Syntax: Reader.Seek(int <position>); // WARNING (use this only if you know what you're doing)
r.Seek(current);