C# Класс SwfDotNet.IO.Utils.EndianBitConverter

Equivalent of System.BitConverter, but with either endianness.
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
CopyBytes ( bool value, byte buffer, int index ) : void

Copies the specified Boolean value into the specified byte array, beginning at the specified index.

CopyBytes ( char value, byte buffer, int index ) : void

Copies the specified Unicode character value into the specified byte array, beginning at the specified index.

CopyBytes ( decimal value, byte buffer, int index ) : void

Copies the specified decimal value into the specified byte array, beginning at the specified index.

CopyBytes ( double value, byte buffer, int index ) : void

Copies the specified double-precision floating point value into the specified byte array, beginning at the specified index.

CopyBytes ( float value, byte buffer, int index ) : void

Copies the specified single-precision floating point value into the specified byte array, beginning at the specified index.

CopyBytes ( int value, byte buffer, int index ) : void

Copies the specified 32-bit signed integer value into the specified byte array, beginning at the specified index.

CopyBytes ( long value, byte buffer, int index ) : void

Copies the specified 64-bit signed integer value into the specified byte array, beginning at the specified index.

CopyBytes ( short value, byte buffer, int index ) : void

Copies the specified 16-bit signed integer value into the specified byte array, beginning at the specified index.

CopyBytes ( uint value, byte buffer, int index ) : void

Copies the specified 32-bit unsigned integer value into the specified byte array, beginning at the specified index.

CopyBytes ( ulong value, byte buffer, int index ) : void

Copies the specified 64-bit unsigned integer value into the specified byte array, beginning at the specified index.

CopyBytes ( ushort value, byte buffer, int index ) : void

Copies the specified 16-bit unsigned integer value into the specified byte array, beginning at the specified index.

DoubleToInt64Bits ( double value ) : long

Converts the specified double-precision floating point number to a 64-bit signed integer. Note: the endianness of this converter does not affect the returned value.

GetBytes ( bool value ) : byte[]

Returns the specified Boolean value as an array of bytes.

GetBytes ( char value ) : byte[]

Returns the specified Unicode character value as an array of bytes.

GetBytes ( decimal value ) : byte[]

Returns the specified decimal value as an array of bytes.

GetBytes ( double value ) : byte[]

Returns the specified double-precision floating point value as an array of bytes.

GetBytes ( float value ) : byte[]

Returns the specified single-precision floating point value as an array of bytes.

GetBytes ( int value ) : byte[]

Returns the specified 32-bit signed integer value as an array of bytes.

GetBytes ( long value ) : byte[]

Returns the specified 64-bit signed integer value as an array of bytes.

GetBytes ( short value ) : byte[]

Returns the specified 16-bit signed integer value as an array of bytes.

GetBytes ( uint value ) : byte[]

Returns the specified 32-bit unsigned integer value as an array of bytes.

GetBytes ( ulong value ) : byte[]

Returns the specified 64-bit unsigned integer value as an array of bytes.

GetBytes ( ushort value ) : byte[]

Returns the specified 16-bit unsigned integer value as an array of bytes.

Int32BitsToSingle ( int value ) : float

Converts the specified 32-bit signed integer to a single-precision floating point number. Note: the endianness of this converter does not affect the returned value.

Int64BitsToDouble ( long value ) : double

Converts the specified 64-bit signed integer to a double-precision floating point number. Note: the endianness of this converter does not affect the returned value.

IsLittleEndian ( ) : bool

Indicates the byte order ("endianess") in which data is converted using this class.

Different computer architectures store data using different byte orders. "Big-endian" means the most significant byte is on the left end of a word. "Little-endian" means the most significant byte is on the right end of a word.

SingleToInt32Bits ( float value ) : int

Converts the specified single-precision floating point number to a 32-bit signed integer. Note: the endianness of this converter does not affect the returned value.

ToBoolean ( byte value, int startIndex ) : bool

Returns a Boolean value converted from one byte at a specified position in a byte array.

ToChar ( byte value, int startIndex ) : char

Returns a Unicode character converted from two bytes at a specified position in a byte array.

ToDecimal ( byte value, int startIndex ) : decimal

Returns a decimal value converted from sixteen bytes at a specified position in a byte array.

ToDouble ( byte value, int startIndex ) : double

Returns a double-precision floating point number converted from eight bytes at a specified position in a byte array.

ToInt16 ( byte value, int startIndex ) : short

Returns a 16-bit signed integer converted from two bytes at a specified position in a byte array.

ToInt32 ( byte value, int startIndex ) : int

Returns a 32-bit signed integer converted from four bytes at a specified position in a byte array.

ToInt64 ( byte value, int startIndex ) : long

Returns a 64-bit signed integer converted from eight bytes at a specified position in a byte array.

ToSingle ( byte value, int startIndex ) : float

Returns a single-precision floating point number converted from four bytes at a specified position in a byte array.

ToString ( byte value ) : string

Returns a String converted from the elements of a byte array.

All the elements of value are converted.

ToString ( byte value, int startIndex ) : string

Returns a String converted from the elements of a byte array starting at a specified array position.

The elements from array position startIndex to the end of the array are converted.

ToString ( byte value, int startIndex, int length ) : string

Returns a String converted from a specified number of bytes at a specified position in a byte array.

The length elements from array position startIndex are converted.

ToUInt16 ( byte value, int startIndex ) : ushort

Returns a 16-bit unsigned integer converted from two bytes at a specified position in a byte array.

ToUInt32 ( byte value, int startIndex ) : uint

Returns a 32-bit unsigned integer converted from four bytes at a specified position in a byte array.

ToUInt64 ( byte value, int startIndex ) : ulong

Returns a 64-bit unsigned integer converted from eight bytes at a specified position in a byte array.

Защищенные методы

Метод Описание
CopyBytesImpl ( long value, int bytes, byte buffer, int index ) : void

Copies the given number of bytes from the least-specific end of the specified value into the specified byte array, beginning at the specified index. This must be implemented in concrete derived classes, but the implementation may assume that the value will fit into the buffer.

FromBytes ( byte value, int startIndex, int bytesToConvert ) : long

Convert the given number of bytes from the given array, from the given start position, into a long, using the bytes as the least significant part of the long. By the time this is called, the arguments have been checked for validity.

Приватные методы

Метод Описание
CheckByteArgument ( byte value, int startIndex, int bytesRequired ) : void

Checks the given argument for validity.

CheckedFromBytes ( byte value, int startIndex, int bytesToConvert ) : long

Checks the arguments for validity before calling FromBytes (which can therefore assume the arguments are valid).

CopyBytes ( long value, int bytes, byte buffer, int index ) : void

Copies the given number of bytes from the least-specific end of the specified value into the specified byte array, beginning at the specified index. This is used to implement the other CopyBytes methods.

GetBytes ( long value, int bytes ) : byte[]

Returns an array with the given number of bytes formed from the least significant bytes of the specified value. This is used to implement the other GetBytes methods.

Описание методов

CopyBytes() публичный Метод

Copies the specified Boolean value into the specified byte array, beginning at the specified index.
public CopyBytes ( bool value, byte buffer, int index ) : void
value bool A Boolean value.
buffer byte The byte array to copy the bytes into
index int The first index into the array to copy the bytes into
Результат void

CopyBytes() публичный Метод

Copies the specified Unicode character value into the specified byte array, beginning at the specified index.
public CopyBytes ( char value, byte buffer, int index ) : void
value char A character to convert.
buffer byte The byte array to copy the bytes into
index int The first index into the array to copy the bytes into
Результат void

CopyBytes() публичный Метод

Copies the specified decimal value into the specified byte array, beginning at the specified index.
public CopyBytes ( decimal value, byte buffer, int index ) : void
value decimal A character to convert.
buffer byte The byte array to copy the bytes into
index int The first index into the array to copy the bytes into
Результат void

CopyBytes() публичный Метод

Copies the specified double-precision floating point value into the specified byte array, beginning at the specified index.
public CopyBytes ( double value, byte buffer, int index ) : void
value double The number to convert.
buffer byte The byte array to copy the bytes into
index int The first index into the array to copy the bytes into
Результат void

CopyBytes() публичный Метод

Copies the specified single-precision floating point value into the specified byte array, beginning at the specified index.
public CopyBytes ( float value, byte buffer, int index ) : void
value float The number to convert.
buffer byte The byte array to copy the bytes into
index int The first index into the array to copy the bytes into
Результат void

CopyBytes() публичный Метод

Copies the specified 32-bit signed integer value into the specified byte array, beginning at the specified index.
public CopyBytes ( int value, byte buffer, int index ) : void
value int The number to convert.
buffer byte The byte array to copy the bytes into
index int The first index into the array to copy the bytes into
Результат void

CopyBytes() публичный Метод

Copies the specified 64-bit signed integer value into the specified byte array, beginning at the specified index.
public CopyBytes ( long value, byte buffer, int index ) : void
value long The number to convert.
buffer byte The byte array to copy the bytes into
index int The first index into the array to copy the bytes into
Результат void

CopyBytes() публичный Метод

Copies the specified 16-bit signed integer value into the specified byte array, beginning at the specified index.
public CopyBytes ( short value, byte buffer, int index ) : void
value short The number to convert.
buffer byte The byte array to copy the bytes into
index int The first index into the array to copy the bytes into
Результат void

CopyBytes() публичный Метод

Copies the specified 32-bit unsigned integer value into the specified byte array, beginning at the specified index.
public CopyBytes ( uint value, byte buffer, int index ) : void
value uint The number to convert.
buffer byte The byte array to copy the bytes into
index int The first index into the array to copy the bytes into
Результат void

CopyBytes() публичный Метод

Copies the specified 64-bit unsigned integer value into the specified byte array, beginning at the specified index.
public CopyBytes ( ulong value, byte buffer, int index ) : void
value ulong The number to convert.
buffer byte The byte array to copy the bytes into
index int The first index into the array to copy the bytes into
Результат void

CopyBytes() публичный Метод

Copies the specified 16-bit unsigned integer value into the specified byte array, beginning at the specified index.
public CopyBytes ( ushort value, byte buffer, int index ) : void
value ushort The number to convert.
buffer byte The byte array to copy the bytes into
index int The first index into the array to copy the bytes into
Результат void

CopyBytesImpl() защищенный абстрактный Метод

Copies the given number of bytes from the least-specific end of the specified value into the specified byte array, beginning at the specified index. This must be implemented in concrete derived classes, but the implementation may assume that the value will fit into the buffer.
protected abstract CopyBytesImpl ( long value, int bytes, byte buffer, int index ) : void
value long The value to copy bytes for
bytes int The number of significant bytes to copy
buffer byte The byte array to copy the bytes into
index int The first index into the array to copy the bytes into
Результат void

DoubleToInt64Bits() публичный Метод

Converts the specified double-precision floating point number to a 64-bit signed integer. Note: the endianness of this converter does not affect the returned value.
public DoubleToInt64Bits ( double value ) : long
value double The number to convert.
Результат long

FromBytes() защищенный абстрактный Метод

Convert the given number of bytes from the given array, from the given start position, into a long, using the bytes as the least significant part of the long. By the time this is called, the arguments have been checked for validity.
protected abstract FromBytes ( byte value, int startIndex, int bytesToConvert ) : long
value byte The bytes to convert
startIndex int The index of the first byte to convert
bytesToConvert int The number of bytes to use in the conversion
Результат long

GetBytes() публичный Метод

Returns the specified Boolean value as an array of bytes.
public GetBytes ( bool value ) : byte[]
value bool A Boolean value.
Результат byte[]

GetBytes() публичный Метод

Returns the specified Unicode character value as an array of bytes.
public GetBytes ( char value ) : byte[]
value char A character to convert.
Результат byte[]

GetBytes() публичный Метод

Returns the specified decimal value as an array of bytes.
public GetBytes ( decimal value ) : byte[]
value decimal The number to convert.
Результат byte[]

GetBytes() публичный Метод

Returns the specified double-precision floating point value as an array of bytes.
public GetBytes ( double value ) : byte[]
value double The number to convert.
Результат byte[]

GetBytes() публичный Метод

Returns the specified single-precision floating point value as an array of bytes.
public GetBytes ( float value ) : byte[]
value float The number to convert.
Результат byte[]

GetBytes() публичный Метод

Returns the specified 32-bit signed integer value as an array of bytes.
public GetBytes ( int value ) : byte[]
value int The number to convert.
Результат byte[]

GetBytes() публичный Метод

Returns the specified 64-bit signed integer value as an array of bytes.
public GetBytes ( long value ) : byte[]
value long The number to convert.
Результат byte[]

GetBytes() публичный Метод

Returns the specified 16-bit signed integer value as an array of bytes.
public GetBytes ( short value ) : byte[]
value short The number to convert.
Результат byte[]

GetBytes() публичный Метод

Returns the specified 32-bit unsigned integer value as an array of bytes.
public GetBytes ( uint value ) : byte[]
value uint The number to convert.
Результат byte[]

GetBytes() публичный Метод

Returns the specified 64-bit unsigned integer value as an array of bytes.
public GetBytes ( ulong value ) : byte[]
value ulong The number to convert.
Результат byte[]

GetBytes() публичный Метод

Returns the specified 16-bit unsigned integer value as an array of bytes.
public GetBytes ( ushort value ) : byte[]
value ushort The number to convert.
Результат byte[]

Int32BitsToSingle() публичный Метод

Converts the specified 32-bit signed integer to a single-precision floating point number. Note: the endianness of this converter does not affect the returned value.
public Int32BitsToSingle ( int value ) : float
value int The number to convert.
Результат float

Int64BitsToDouble() публичный Метод

Converts the specified 64-bit signed integer to a double-precision floating point number. Note: the endianness of this converter does not affect the returned value.
public Int64BitsToDouble ( long value ) : double
value long The number to convert.
Результат double

IsLittleEndian() публичный абстрактный Метод

Indicates the byte order ("endianess") in which data is converted using this class.
Different computer architectures store data using different byte orders. "Big-endian" means the most significant byte is on the left end of a word. "Little-endian" means the most significant byte is on the right end of a word.
public abstract IsLittleEndian ( ) : bool
Результат bool

SingleToInt32Bits() публичный Метод

Converts the specified single-precision floating point number to a 32-bit signed integer. Note: the endianness of this converter does not affect the returned value.
public SingleToInt32Bits ( float value ) : int
value float The number to convert.
Результат int

ToBoolean() публичный Метод

Returns a Boolean value converted from one byte at a specified position in a byte array.
public ToBoolean ( byte value, int startIndex ) : bool
value byte An array of bytes.
startIndex int The starting position within value.
Результат bool

ToChar() публичный Метод

Returns a Unicode character converted from two bytes at a specified position in a byte array.
public ToChar ( byte value, int startIndex ) : char
value byte An array of bytes.
startIndex int The starting position within value.
Результат char

ToDecimal() публичный Метод

Returns a decimal value converted from sixteen bytes at a specified position in a byte array.
public ToDecimal ( byte value, int startIndex ) : decimal
value byte An array of bytes.
startIndex int The starting position within value.
Результат decimal

ToDouble() публичный Метод

Returns a double-precision floating point number converted from eight bytes at a specified position in a byte array.
public ToDouble ( byte value, int startIndex ) : double
value byte An array of bytes.
startIndex int The starting position within value.
Результат double

ToInt16() публичный Метод

Returns a 16-bit signed integer converted from two bytes at a specified position in a byte array.
public ToInt16 ( byte value, int startIndex ) : short
value byte An array of bytes.
startIndex int The starting position within value.
Результат short

ToInt32() публичный Метод

Returns a 32-bit signed integer converted from four bytes at a specified position in a byte array.
public ToInt32 ( byte value, int startIndex ) : int
value byte An array of bytes.
startIndex int The starting position within value.
Результат int

ToInt64() публичный Метод

Returns a 64-bit signed integer converted from eight bytes at a specified position in a byte array.
public ToInt64 ( byte value, int startIndex ) : long
value byte An array of bytes.
startIndex int The starting position within value.
Результат long

ToSingle() публичный Метод

Returns a single-precision floating point number converted from four bytes at a specified position in a byte array.
public ToSingle ( byte value, int startIndex ) : float
value byte An array of bytes.
startIndex int The starting position within value.
Результат float

ToString() публичный статический Метод

Returns a String converted from the elements of a byte array.
All the elements of value are converted.
public static ToString ( byte value ) : string
value byte An array of bytes.
Результат string

ToString() публичный статический Метод

Returns a String converted from the elements of a byte array starting at a specified array position.
The elements from array position startIndex to the end of the array are converted.
public static ToString ( byte value, int startIndex ) : string
value byte An array of bytes.
startIndex int The starting position within value.
Результат string

ToString() публичный статический Метод

Returns a String converted from a specified number of bytes at a specified position in a byte array.
The length elements from array position startIndex are converted.
public static ToString ( byte value, int startIndex, int length ) : string
value byte An array of bytes.
startIndex int The starting position within value.
length int The number of bytes to convert.
Результат string

ToUInt16() публичный Метод

Returns a 16-bit unsigned integer converted from two bytes at a specified position in a byte array.
public ToUInt16 ( byte value, int startIndex ) : ushort
value byte An array of bytes.
startIndex int The starting position within value.
Результат ushort

ToUInt32() публичный Метод

Returns a 32-bit unsigned integer converted from four bytes at a specified position in a byte array.
public ToUInt32 ( byte value, int startIndex ) : uint
value byte An array of bytes.
startIndex int The starting position within value.
Результат uint

ToUInt64() публичный Метод

Returns a 64-bit unsigned integer converted from eight bytes at a specified position in a byte array.
public ToUInt64 ( byte value, int startIndex ) : ulong
value byte An array of bytes.
startIndex int The starting position within value.
Результат ulong