C# Class FlacLibSharp.Helpers.BinaryDataHelper

A helper class for parsing byes and bits to actual numbers.
Currently always operates with Big-Endian numbers (because this was created for FLAC parsing which uses big-endian by default).
Exibir arquivo Open project: AaronLenoir/flaclibsharp

Public Methods

Method Description
GetBoolean ( byte data, int byteOffset, byte bitOffset ) : bool

From the data, reads boolean at the offset.

GetBytes ( System.UInt64 value, int size ) : byte[]

Converts the given value to a big-endian byte stream.

GetBytesUInt16 ( UInt16 value ) : byte[]

Converts the given value to a big-endian byte stream.

GetBytesUInt32 ( UInt32 value ) : byte[]

Converts the given value to a big-endian byte stream.

GetBytesUInt64 ( System.UInt64 value ) : byte[]

Converts the given value to a big-endian byte stream.

GetDataSubset ( byte data, int offset, int length ) : byte[]

From a given data array, get a subset of items in a deep copied array.

GetPaddedAsciiBytes ( string value, int size ) : byte[]

Will return an array of ascii printable characters (values 0x20 to 0x7e) and will pad with zero's so that the array of bytes is always of a given size.

GetUInt16 ( byte data, int byteOffset ) : UInt16

From the data, reads an unsigned 16 bit integer starting from the offset.

GetUInt24 ( byte data, int byteOffset ) : UInt32

From the data, reads an unsigned 24 bit integer starting from the offset.

GetUInt32 ( byte data, int byteOffset ) : UInt32

From the data, reads an unsigned 32 bit integer starting from the offset.

GetUInt64 ( byte data, int byteOffset ) : System.UInt64

From the data, reads an unsigned 64 bit integer starting from the offset.

GetUInt64 ( byte data, int byteOffset, int bitCount ) : System.UInt64

From the data, reads an integer value starting from the offset.

GetUInt64 ( byte data, int byteOffset, int bitCount, byte bitOffset ) : System.UInt64

Allows you to interpret part of a byte array as a number.

Always assumes Big-Endian in the data store.

SwitchEndianness ( byte data, int byteOffset, int length ) : byte[]

For a given array of bytes, switch the endiannes of the length-bytes starting at byteOffset.

Method Details

GetBoolean() public static method

From the data, reads boolean at the offset.
public static GetBoolean ( byte data, int byteOffset, byte bitOffset ) : bool
data byte The source data
byteOffset int Offset from where to start reading the boolean, in bytes.
bitOffset byte In the found byte, defines the bit that will represent the boolean.
return bool

GetBytes() public static method

Converts the given value to a big-endian byte stream.
public static GetBytes ( System.UInt64 value, int size ) : byte[]
value System.UInt64 The value to convert.
size int How many bytes to convert (the rest will be ignored in the value).
return byte[]

GetBytesUInt16() public static method

Converts the given value to a big-endian byte stream.
public static GetBytesUInt16 ( UInt16 value ) : byte[]
value System.UInt16 The value to convert.
return byte[]

GetBytesUInt32() public static method

Converts the given value to a big-endian byte stream.
public static GetBytesUInt32 ( UInt32 value ) : byte[]
value System.UInt32 The value to convert.
return byte[]

GetBytesUInt64() public static method

Converts the given value to a big-endian byte stream.
public static GetBytesUInt64 ( System.UInt64 value ) : byte[]
value System.UInt64 The value to convert.
return byte[]

GetDataSubset() public static method

From a given data array, get a subset of items in a deep copied array.
public static GetDataSubset ( byte data, int offset, int length ) : byte[]
data byte The input data (won't be altered)
offset int Where in the input data to start copying files.
length int The amount of bytes to copy.
return byte[]

GetPaddedAsciiBytes() public static method

Will return an array of ascii printable characters (values 0x20 to 0x7e) and will pad with zero's so that the array of bytes is always of a given size.
public static GetPaddedAsciiBytes ( string value, int size ) : byte[]
value string The text to convert to bytes.
size int The total length of the resulting byte array.
return byte[]

GetUInt16() public static method

From the data, reads an unsigned 16 bit integer starting from the offset.
public static GetUInt16 ( byte data, int byteOffset ) : UInt16
data byte The source data
byteOffset int Offset from where to start reading the integer, in bytes.
return System.UInt16

GetUInt24() public static method

From the data, reads an unsigned 24 bit integer starting from the offset.
public static GetUInt24 ( byte data, int byteOffset ) : UInt32
data byte The source data
byteOffset int Offset from where to start reading the integer, in bytes.
return System.UInt32

GetUInt32() public static method

From the data, reads an unsigned 32 bit integer starting from the offset.
public static GetUInt32 ( byte data, int byteOffset ) : UInt32
data byte The source data
byteOffset int Offset from where to start reading the integer, in bytes.
return System.UInt32

GetUInt64() public static method

From the data, reads an unsigned 64 bit integer starting from the offset.
public static GetUInt64 ( byte data, int byteOffset ) : System.UInt64
data byte The source data
byteOffset int Offset from where to start reading the integer, in bytes.
return System.UInt64

GetUInt64() public static method

From the data, reads an integer value starting from the offset.
public static GetUInt64 ( byte data, int byteOffset, int bitCount ) : System.UInt64
data byte The source data
byteOffset int Offset from where to start reading the integer, in bytes.
bitCount int How many bits to read (16, 32, or something arbitrary but less than or equal to 64)
return System.UInt64

GetUInt64() public static method

Allows you to interpret part of a byte array as a number.
Always assumes Big-Endian in the data store.
public static GetUInt64 ( byte data, int byteOffset, int bitCount, byte bitOffset ) : System.UInt64
data byte The source data.
byteOffset int Where in the data to start reading (offset in bytes)
bitCount int How many bits to read (16, 32, or something arbitrary but less than or equal to 64)
bitOffset byte In the first byte, at which bit to start reading the data from.
return System.UInt64

SwitchEndianness() public static method

For a given array of bytes, switch the endiannes of the length-bytes starting at byteOffset.
public static SwitchEndianness ( byte data, int byteOffset, int length ) : byte[]
data byte The source data.
byteOffset int Where to start switching the endianness.
length int How many bytes to switch.
return byte[]