DotNetDupe 4.0.6
C++17/20 Implementation of the .NET Base Class Library (BCL)
Loading...
Searching...
No Matches
DotNetDupe::System::BitConverter Class Reference

Converts base data types to arrays of bytes, and vice versa. More...

#include <BitConverter.h>

Inheritance diagram for DotNetDupe::System::BitConverter:

Static Public Member Functions

static long long DoubleToInt64Bits (double dValue)
 Converts the specified 64-bit double-precision floating point number to a 64-bit signed integer bit pattern.
static Array< byteGetBytes (bool bValue)
 Returns the specified Boolean value as a byte array.
static Array< byteGetBytes (char chValue)
 Returns the specified character value as a byte array.
static Array< byteGetBytes (double dValue)
 Returns the specified double-precision floating-point value as a byte array.
static Array< byteGetBytes (float fValue)
 Returns the specified single-precision floating-point value as a byte array.
static Array< byteGetBytes (int iValue)
 Returns the specified 32-bit signed integer value as a byte array.
static Array< byteGetBytes (long long llValue)
 Returns the specified 64-bit signed integer value as a byte array.
static Array< byteGetBytes (short iValue)
 Returns the specified 16-bit signed integer value as a byte array.
static Array< byteGetBytes (unsigned int iValue)
static Array< byteGetBytes (unsigned long long llValue)
static Array< byteGetBytes (unsigned short iValue)
static float Int32BitsToSingle (int iValue)
 Reinterprets the specified 32-bit signed integer bit pattern as a 32-bit single-precision floating point number.
static double Int64BitsToDouble (long long llValue)
 Reinterprets the specified 64-bit signed integer bit pattern as a 64-bit double-precision floating point number.
static int SingleToInt32Bits (float fValue)
 Converts the specified 32-bit single-precision floating point number to a 32-bit signed integer bit pattern.
static bool ToBoolean (Array< byte > &arrValue, int iStartIndex)
 Returns a Boolean value converted from one byte at a specified position in a byte array.
static char ToChar (Array< byte > &arrValue, int iStartIndex)
static double ToDouble (Array< byte > &arrValue, int iStartIndex)
static short ToInt16 (Array< byte > &arrValue, int iStartIndex)
static int ToInt32 (Array< byte > &arrValue, int iStartIndex)
static long long ToInt64 (Array< byte > &arrValue, int iStartIndex)
static float ToSingle (Array< byte > &arrValue, int iStartIndex)
static String ToString (Array< byte > &arrValue)
 Converts the numeric value of each element of a specified array of bytes to its equivalent hexadecimal string representation.
static String ToString (Array< byte > &arrValue, int iStartIndex)
static String ToString (Array< byte > &arrValue, int iStartIndex, int iLength)
static unsigned short ToUInt16 (Array< byte > &arrValue, int iStartIndex)
static unsigned int ToUInt32 (Array< byte > &arrValue, int iStartIndex)
static unsigned long long ToUInt64 (Array< byte > &arrValue, int iStartIndex)
Static Public Member Functions inherited from DotNetDupe::System::Object
static bool Equals (const Object &obj1, const Object &obj2)
 Static helper determining whether two object instances are equal.

Static Public Attributes

static const bool IsLittleEndian = true
 Indicates whether this computer architecture is little-endian.

Additional Inherited Members

Public Member Functions inherited from DotNetDupe::System::Object
virtual ~Object ()=default
 Virtual destructor ensuring polymorphic cleanup.
virtual bool Equals (const Object &obj) const
 Determines whether the specified Object is equal to the current Object.
virtual int GetHashCode () const
 Serves as the default hash function.
bool operator== (const Object &obj) const
 Determines reference equality between two objects.
char * ToStringA () const
 Returns narrow-character string representation.
wchar_t * ToStringW () const
 Returns wide-character string representation.

Detailed Description

Converts base data types to arrays of bytes, and vice versa.

Conforms to .NET System.BitConverter specifications with endianness detection, primitive type byte extraction, and IEEE 754 floating-point bit-cast conversions. All methods are thread-safe and stateless.

Note
Conforms to ECMA-335 Partition IV Section 5.14 (System.BitConverter) and IEEE 754.
See also
Convert, Buffer

Definition at line 22 of file BitConverter.h.

Member Function Documentation

◆ DoubleToInt64Bits()

long long DotNetDupe::System::BitConverter::DoubleToInt64Bits ( double dValue)
static

Converts the specified 64-bit double-precision floating point number to a 64-bit signed integer bit pattern.

Reinterpret IEEE 754 floating-point bits to 64-bit integer via std::memcpy.

Definition at line 210 of file BitConverter.cpp.

◆ GetBytes() [1/10]

Array< byte > DotNetDupe::System::BitConverter::GetBytes ( bool bValue)
static

Returns the specified Boolean value as a byte array.

Step: Convert boolean to single byte.

Definition at line 13 of file BitConverter.cpp.

◆ GetBytes() [2/10]

Array< byte > DotNetDupe::System::BitConverter::GetBytes ( char chValue)
static

Returns the specified character value as a byte array.

Step: Convert char to single byte.

Definition at line 20 of file BitConverter.cpp.

◆ GetBytes() [3/10]

Array< byte > DotNetDupe::System::BitConverter::GetBytes ( double dValue)
static

Returns the specified double-precision floating-point value as a byte array.

Step: Copy IEEE 754 64-bit double bytes into byte array.

Definition at line 27 of file BitConverter.cpp.

References DotNetDupe::System::Array< T >::GetData().

◆ GetBytes() [4/10]

Array< byte > DotNetDupe::System::BitConverter::GetBytes ( float fValue)
static

Returns the specified single-precision floating-point value as a byte array.

Step: Copy IEEE 754 32-bit float bytes into byte array.

Definition at line 55 of file BitConverter.cpp.

References DotNetDupe::System::Array< T >::GetData().

◆ GetBytes() [5/10]

Array< byte > DotNetDupe::System::BitConverter::GetBytes ( int iValue)
static

Returns the specified 32-bit signed integer value as a byte array.

Step: Copy 32-bit signed integer bytes into byte array.

Definition at line 41 of file BitConverter.cpp.

References DotNetDupe::System::Array< T >::GetData().

◆ GetBytes() [6/10]

Array< byte > DotNetDupe::System::BitConverter::GetBytes ( long long llValue)
static

Returns the specified 64-bit signed integer value as a byte array.

Step: Copy 64-bit signed integer bytes into byte array.

Definition at line 48 of file BitConverter.cpp.

References DotNetDupe::System::Array< T >::GetData().

◆ GetBytes() [7/10]

Array< byte > DotNetDupe::System::BitConverter::GetBytes ( short iValue)
static

Returns the specified 16-bit signed integer value as a byte array.

Step: Copy 16-bit signed integer bytes into byte array.

Definition at line 34 of file BitConverter.cpp.

References DotNetDupe::System::Array< T >::GetData().

◆ GetBytes() [8/10]

Array< byte > DotNetDupe::System::BitConverter::GetBytes ( unsigned int iValue)
static

Step: Copy 32-bit unsigned integer bytes into byte array.

Definition at line 69 of file BitConverter.cpp.

References DotNetDupe::System::Array< T >::GetData().

◆ GetBytes() [9/10]

Array< byte > DotNetDupe::System::BitConverter::GetBytes ( unsigned long long llValue)
static

Step: Copy 64-bit unsigned integer bytes into byte array.

Definition at line 76 of file BitConverter.cpp.

References DotNetDupe::System::Array< T >::GetData().

◆ GetBytes() [10/10]

Array< byte > DotNetDupe::System::BitConverter::GetBytes ( unsigned short iValue)
static

Step: Copy 16-bit unsigned integer bytes into byte array.

Definition at line 62 of file BitConverter.cpp.

References DotNetDupe::System::Array< T >::GetData().

◆ Int32BitsToSingle()

float DotNetDupe::System::BitConverter::Int32BitsToSingle ( int iValue)
static

Reinterprets the specified 32-bit signed integer bit pattern as a 32-bit single-precision floating point number.

Reinterpret 32-bit integer bits to 32-bit float via std::memcpy.

Definition at line 231 of file BitConverter.cpp.

◆ Int64BitsToDouble()

double DotNetDupe::System::BitConverter::Int64BitsToDouble ( long long llValue)
static

Reinterprets the specified 64-bit signed integer bit pattern as a 64-bit double-precision floating point number.

Reinterpret 64-bit integer bits to IEEE 754 double via std::memcpy.

Definition at line 217 of file BitConverter.cpp.

◆ SingleToInt32Bits()

int DotNetDupe::System::BitConverter::SingleToInt32Bits ( float fValue)
static

Converts the specified 32-bit single-precision floating point number to a 32-bit signed integer bit pattern.

Reinterpret 32-bit float bits to 32-bit integer via std::memcpy.

Definition at line 224 of file BitConverter.cpp.

◆ ToBoolean()

bool DotNetDupe::System::BitConverter::ToBoolean ( Array< byte > & arrValue,
int iStartIndex )
static

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

Guard: Validate input buffer bounds.

Return: Boolean evaluation.

Definition at line 83 of file BitConverter.cpp.

References DotNetDupe::System::ArgumentNullException::ArgumentNullException(), DotNetDupe::System::ArgumentOutOfRangeException::ArgumentOutOfRangeException(), and DotNetDupe::System::Array< T >::GetLength().

◆ ToChar()

char DotNetDupe::System::BitConverter::ToChar ( Array< byte > & arrValue,
int iStartIndex )
static

◆ ToDouble()

double DotNetDupe::System::BitConverter::ToDouble ( Array< byte > & arrValue,
int iStartIndex )
static

◆ ToInt16()

short DotNetDupe::System::BitConverter::ToInt16 ( Array< byte > & arrValue,
int iStartIndex )
static

◆ ToInt32()

int DotNetDupe::System::BitConverter::ToInt32 ( Array< byte > & arrValue,
int iStartIndex )
static

◆ ToInt64()

long long DotNetDupe::System::BitConverter::ToInt64 ( Array< byte > & arrValue,
int iStartIndex )
static

◆ ToSingle()

float DotNetDupe::System::BitConverter::ToSingle ( Array< byte > & arrValue,
int iStartIndex )
static

◆ ToString() [1/3]

String DotNetDupe::System::BitConverter::ToString ( Array< byte > & arrValue)
static

Converts the numeric value of each element of a specified array of bytes to its equivalent hexadecimal string representation.

Forward: Delegate with full array range.

Definition at line 179 of file BitConverter.cpp.

References DotNetDupe::System::Array< T >::GetLength(), and ToString().

Referenced by ToString(), and ToString().

◆ ToString() [2/3]

String DotNetDupe::System::BitConverter::ToString ( Array< byte > & arrValue,
int iStartIndex )
static

Forward: Delegate with start index and remaining range.

Definition at line 184 of file BitConverter.cpp.

References DotNetDupe::System::Array< T >::GetLength(), and ToString().

◆ ToString() [3/3]

String DotNetDupe::System::BitConverter::ToString ( Array< byte > & arrValue,
int iStartIndex,
int iLength )
static

Guard: Validate index and range parameters.

Stream each byte as an uppercase 2-digit zero-padded hexadecimal number separated by '-'.

Definition at line 189 of file BitConverter.cpp.

References DotNetDupe::System::ArgumentException::ArgumentException(), DotNetDupe::System::ArgumentOutOfRangeException::ArgumentOutOfRangeException(), DotNetDupe::System::String::String(), and DotNetDupe::System::Array< T >::GetLength().

◆ ToUInt16()

unsigned short DotNetDupe::System::BitConverter::ToUInt16 ( Array< byte > & arrValue,
int iStartIndex )
static

◆ ToUInt32()

unsigned int DotNetDupe::System::BitConverter::ToUInt32 ( Array< byte > & arrValue,
int iStartIndex )
static

◆ ToUInt64()

unsigned long long DotNetDupe::System::BitConverter::ToUInt64 ( Array< byte > & arrValue,
int iStartIndex )
static

Member Data Documentation

◆ IsLittleEndian


The documentation for this class was generated from the following files: