-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aeffa87
commit a13dba5
Showing
13 changed files
with
313 additions
and
142 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
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
28 changes: 28 additions & 0 deletions
28
src/Addax.Formats.Tabular/Converters/TabularBase16ArrayConverter.cs
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,28 @@ | ||
// (c) Oleksandr Kozlenko. Licensed under the MIT license. | ||
|
||
using System.Diagnostics.CodeAnalysis; | ||
|
||
namespace Addax.Formats.Tabular.Converters; | ||
|
||
/// <summary>Converts binary data encoded with "base16" ("hex") encoding from or to a character sequence.</summary> | ||
public class TabularBase16ArrayConverter : TabularConverter<byte[]?> | ||
{ | ||
internal static readonly TabularBase16ArrayConverter Instance = new(); | ||
|
||
/// <summary>Initializes a new instance of the <see cref="TabularBase16ArrayConverter" /> class.</summary> | ||
public TabularBase16ArrayConverter() | ||
{ | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override bool TryFormat(byte[]? value, Span<char> destination, IFormatProvider? provider, out int charsWritten) | ||
{ | ||
return TabularBinary.TryFormatBase16(value, destination, out charsWritten); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override bool TryParse(ReadOnlySpan<char> source, IFormatProvider? provider, [NotNullWhen(true)] out byte[]? value) | ||
{ | ||
return TabularBinary.TryParseBase16(source, out value); | ||
} | ||
} |
67 changes: 0 additions & 67 deletions
67
src/Addax.Formats.Tabular/Converters/TabularBase16BinaryConverter.cs
This file was deleted.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
src/Addax.Formats.Tabular/Converters/TabularBase16MemoryConverter.cs
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,33 @@ | ||
// (c) Oleksandr Kozlenko. Licensed under the MIT license. | ||
|
||
namespace Addax.Formats.Tabular.Converters; | ||
|
||
/// <summary>Converts binary data encoded with "base16" ("hex") encoding from or to a character sequence.</summary> | ||
public class TabularBase16MemoryConverter : TabularConverter<Memory<byte>> | ||
{ | ||
/// <summary>Initializes a new instance of the <see cref="TabularBase16MemoryConverter" /> class.</summary> | ||
public TabularBase16MemoryConverter() | ||
{ | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override bool TryFormat(Memory<byte> value, Span<char> destination, IFormatProvider? provider, out int charsWritten) | ||
{ | ||
return TabularBinary.TryFormatBase16(value.Span, destination, out charsWritten); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override bool TryParse(ReadOnlySpan<char> source, IFormatProvider? provider, out Memory<byte> value) | ||
{ | ||
if (TabularBinary.TryParseBase16(source, out var array)) | ||
{ | ||
value = array; | ||
|
||
return true; | ||
} | ||
|
||
value = default; | ||
|
||
return false; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/Addax.Formats.Tabular/Converters/TabularBase16ReadOnlyMemoryConverter.cs
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,33 @@ | ||
// (c) Oleksandr Kozlenko. Licensed under the MIT license. | ||
|
||
namespace Addax.Formats.Tabular.Converters; | ||
|
||
/// <summary>Converts binary data encoded with "base16" ("hex") encoding from or to a character sequence.</summary> | ||
public class TabularBase16ReadOnlyMemoryConverter : TabularConverter<ReadOnlyMemory<byte>> | ||
{ | ||
/// <summary>Initializes a new instance of the <see cref="TabularBase16ReadOnlyMemoryConverter" /> class.</summary> | ||
public TabularBase16ReadOnlyMemoryConverter() | ||
{ | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override bool TryFormat(ReadOnlyMemory<byte> value, Span<char> destination, IFormatProvider? provider, out int charsWritten) | ||
{ | ||
return TabularBinary.TryFormatBase16(value.Span, destination, out charsWritten); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override bool TryParse(ReadOnlySpan<char> source, IFormatProvider? provider, out ReadOnlyMemory<byte> value) | ||
{ | ||
if (TabularBinary.TryParseBase16(source, out var array)) | ||
{ | ||
value = array; | ||
|
||
return true; | ||
} | ||
|
||
value = default; | ||
|
||
return false; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/Addax.Formats.Tabular/Converters/TabularBase64ArrayConverter.cs
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,28 @@ | ||
// (c) Oleksandr Kozlenko. Licensed under the MIT license. | ||
|
||
using System.Diagnostics.CodeAnalysis; | ||
|
||
namespace Addax.Formats.Tabular.Converters; | ||
|
||
/// <summary>Converts binary data encoded with "base64" encoding from or to a character sequence.</summary> | ||
public class TabularBase64ArrayConverter : TabularConverter<byte[]?> | ||
{ | ||
internal static readonly TabularBase64ArrayConverter Instance = new(); | ||
|
||
/// <summary>Initializes a new instance of the <see cref="TabularBase64ArrayConverter" /> class.</summary> | ||
public TabularBase64ArrayConverter() | ||
{ | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override bool TryFormat(byte[]? value, Span<char> destination, IFormatProvider? provider, out int charsWritten) | ||
{ | ||
return TabularBinary.TryFormatBase64(value, destination, out charsWritten); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override bool TryParse(ReadOnlySpan<char> source, IFormatProvider? provider, [NotNullWhen(true)] out byte[]? value) | ||
{ | ||
return TabularBinary.TryParseBase64(source, out value); | ||
} | ||
} |
62 changes: 0 additions & 62 deletions
62
src/Addax.Formats.Tabular/Converters/TabularBase64BinaryConverter.cs
This file was deleted.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
src/Addax.Formats.Tabular/Converters/TabularBase64MemoryConverter.cs
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,33 @@ | ||
// (c) Oleksandr Kozlenko. Licensed under the MIT license. | ||
|
||
namespace Addax.Formats.Tabular.Converters; | ||
|
||
/// <summary>Converts binary data encoded with "base64" encoding from or to a character sequence.</summary> | ||
public class TabularBase64MemoryConverter : TabularConverter<Memory<byte>> | ||
{ | ||
/// <summary>Initializes a new instance of the <see cref="TabularBase64MemoryConverter" /> class.</summary> | ||
public TabularBase64MemoryConverter() | ||
{ | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override bool TryFormat(Memory<byte> value, Span<char> destination, IFormatProvider? provider, out int charsWritten) | ||
{ | ||
return TabularBinary.TryFormatBase64(value.Span, destination, out charsWritten); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override bool TryParse(ReadOnlySpan<char> source, IFormatProvider? provider, out Memory<byte> value) | ||
{ | ||
if (TabularBinary.TryParseBase64(source, out var array)) | ||
{ | ||
value = array; | ||
|
||
return true; | ||
} | ||
|
||
value = default; | ||
|
||
return false; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/Addax.Formats.Tabular/Converters/TabularBase64ReadOnlyMemoryConverter.cs
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,33 @@ | ||
// (c) Oleksandr Kozlenko. Licensed under the MIT license. | ||
|
||
namespace Addax.Formats.Tabular.Converters; | ||
|
||
/// <summary>Converts binary data encoded with "base64" encoding from or to a character sequence.</summary> | ||
public class TabularBase64ReadOnlyMemoryConverter : TabularConverter<ReadOnlyMemory<byte>> | ||
{ | ||
/// <summary>Initializes a new instance of the <see cref="TabularBase64ReadOnlyMemoryConverter" /> class.</summary> | ||
public TabularBase64ReadOnlyMemoryConverter() | ||
{ | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override bool TryFormat(ReadOnlyMemory<byte> value, Span<char> destination, IFormatProvider? provider, out int charsWritten) | ||
{ | ||
return TabularBinary.TryFormatBase64(value.Span, destination, out charsWritten); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override bool TryParse(ReadOnlySpan<char> source, IFormatProvider? provider, out ReadOnlyMemory<byte> value) | ||
{ | ||
if (TabularBinary.TryParseBase64(source, out var array)) | ||
{ | ||
value = array; | ||
|
||
return true; | ||
} | ||
|
||
value = default; | ||
|
||
return false; | ||
} | ||
} |
Oops, something went wrong.