Skip to content

Commit

Permalink
add ReadBool
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastian-heinz committed Jan 10, 2022
1 parent 68815af commit 8dc10a6
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 131 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ jobs:
run: |
VERSION_FILE=${{ github.workspace }}/.version
VERSION=$(<"$VERSION_FILE")
echo ::set-env name=VERSION::$VERSION
echo ::set-env name=VERSION_E::$(echo ${GITHUB_SHA} | cut -c1-8)
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "VERSION_E=$(echo ${GITHUB_SHA} | cut -c1-8)" >> $GITHUB_ENV
mkdir ./release
for RUNTIME in win-x86 win-x64 linux-x64 osx-x64; do
# Server
Expand Down
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.0
1.0.1
19 changes: 2 additions & 17 deletions Arrowgene.Buffers/Buffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,13 @@ public Buffer(IEndiannessSwapper endiannessSwapper)
public abstract IBuffer Provide(byte[] buffer);
public abstract byte[] GetAllBytes();
public abstract byte[] GetAllBytes(int offset);
public abstract void WriteBool(bool value);
public abstract void WriteByte(byte value);
public abstract void WriteBytes(byte[] bytes);
public abstract void WriteBytes(byte[] source, int srcOffset, int length);
public abstract void WriteBytes(byte[] source, int srcOffset, int dstOffset, int count);
public abstract void WriteDecimal(decimal value);
public abstract bool ReadBool();
public abstract byte ReadByte();
public abstract byte GetByte(int offset);
public abstract byte[] ReadBytes(int length);
Expand Down Expand Up @@ -352,16 +354,6 @@ public virtual void WriteCString(string value, Func<string, byte[]> converter)
WriteByte(0);
}

public virtual string ToHexString(string separator = null)
{
return Service.ToHexString(GetAllBytes(), separator);
}

public virtual string ToAsciiString(string separator = " ")
{
return Service.ToAsciiString(GetAllBytes(), separator);
}

public virtual string GetString(int offset, int length)
{
return GetString(offset, length, NoEncoding);
Expand Down Expand Up @@ -556,13 +548,6 @@ public virtual void WriteDouble(double value, Endianness endianness)
_endiannessSwapper.WriteSwap(value, WriteDouble, _endiannessSwapper.SwapBytes, endianness);
}

public string Dump()
{
return ToAsciiString() +
Environment.NewLine +
ToHexString();
}

public override string ToString()
{
return $"Size:{Size} Position:{Position}";
Expand Down
56 changes: 0 additions & 56 deletions Arrowgene.Buffers/BufferManager.cs

This file was deleted.

24 changes: 12 additions & 12 deletions Arrowgene.Buffers/IBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ public interface IBuffer
/// Returns all written bytes from a specific offset, without affecting the position.
/// </summary>
byte[] GetAllBytes(int offset);

/// <summary>
/// Writes a 0x00 byte if false or 0x01 byte if true
/// </summary>
void WriteBool(bool value);

void WriteByte(byte value);

Expand Down Expand Up @@ -111,6 +116,11 @@ public interface IBuffer

void WriteBuffer(IBuffer value, int offset, int length);

/// <summary>
/// Reads 0x00 byte as false, everything else as true
/// </summary>
bool ReadBool();

/// <summary>
/// Read byte.
/// Advances the cursor.
Expand Down Expand Up @@ -356,12 +366,12 @@ public interface IBuffer
string ReadFixedString(int length);

/// <summary>
/// Reads a till a 0byte, but advances the position for the length.
/// Reads a string till a 0byte, but advances the position for the length.
/// </summary>
string ReadFixedString(int length, Encoding encoding);

/// <summary>
/// Reads a till a 0byte, but advances the position for the length.
/// Reads a string till a 0byte, but advances the position for the length.
/// </summary>
string ReadFixedString(int length, Func<byte[], string> converter);

Expand Down Expand Up @@ -433,15 +443,5 @@ public interface IBuffer
/// Advances the cursor.
/// </summary>
void WriteCString(string value, Func<string, byte[]> converter);

/// <summary>
/// Hex representation of the buffer.
/// </summary>
string ToHexString(string? separator = null);

/// <summary>
/// Ascii representation of the buffer.
/// </summary>
string ToAsciiString(string? separator = null);
}
}
43 changes: 0 additions & 43 deletions Arrowgene.Buffers/Service.cs

This file was deleted.

10 changes: 10 additions & 0 deletions Arrowgene.Buffers/StreamBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ public override byte[] GetAllBytes(int offset)
return GetBytes(offset, Size - offset);
}

public override void WriteBool(bool value)
{
_binaryWriter.Write(value);
}

public override void WriteBytes(byte[] bytes)
{
_binaryWriter.Write(bytes);
Expand Down Expand Up @@ -151,6 +156,11 @@ public override void WriteDecimal(decimal value)
_binaryWriter.Write(value);
}

public override bool ReadBool()
{
return _binaryReader.ReadBoolean();
}

public override byte ReadByte()
{
return _binaryReader.ReadByte();
Expand Down

0 comments on commit 8dc10a6

Please sign in to comment.