|
DotNetDupe 4.0.6
C++17/20 Implementation of the .NET Base Class Library (BCL)
|
Converts base data types to arrays of bytes, and vice versa. More...
#include <BitConverter.h>
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< byte > | GetBytes (bool bValue) |
| Returns the specified Boolean value as a byte array. | |
| static Array< byte > | GetBytes (char chValue) |
| Returns the specified character value as a byte array. | |
| static Array< byte > | GetBytes (double dValue) |
| Returns the specified double-precision floating-point value as a byte array. | |
| static Array< byte > | GetBytes (float fValue) |
| Returns the specified single-precision floating-point value as a byte array. | |
| static Array< byte > | GetBytes (int iValue) |
| Returns the specified 32-bit signed integer value as a byte array. | |
| static Array< byte > | GetBytes (long long llValue) |
| Returns the specified 64-bit signed integer value as a byte array. | |
| static Array< byte > | GetBytes (short iValue) |
| Returns the specified 16-bit signed integer value as a byte array. | |
| static Array< byte > | GetBytes (unsigned int iValue) |
| static Array< byte > | GetBytes (unsigned long long llValue) |
| static Array< byte > | GetBytes (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. | |
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.
Definition at line 22 of file BitConverter.h.
|
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.
Returns the specified Boolean value as a byte array.
Step: Convert boolean to single byte.
Definition at line 13 of file BitConverter.cpp.
Returns the specified character value as a byte array.
Step: Convert char to single byte.
Definition at line 20 of file BitConverter.cpp.
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().
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().
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().
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().
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().
Step: Copy 32-bit unsigned integer bytes into byte array.
Definition at line 69 of file BitConverter.cpp.
References DotNetDupe::System::Array< T >::GetData().
Step: Copy 64-bit unsigned integer bytes into byte array.
Definition at line 76 of file BitConverter.cpp.
References DotNetDupe::System::Array< T >::GetData().
Step: Copy 16-bit unsigned integer bytes into byte array.
Definition at line 62 of file BitConverter.cpp.
References DotNetDupe::System::Array< T >::GetData().
|
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.
|
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.
|
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.
|
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().
Guard: Validate input buffer bounds.
Return: Char conversion.
Definition at line 91 of file BitConverter.cpp.
References DotNetDupe::System::ArgumentNullException::ArgumentNullException(), DotNetDupe::System::ArgumentOutOfRangeException::ArgumentOutOfRangeException(), and DotNetDupe::System::Array< T >::GetLength().
|
static |
Guard: Validate input buffer bounds.
Step: Copy 8 bytes into IEEE 754 double.
Definition at line 99 of file BitConverter.cpp.
References DotNetDupe::System::ArgumentNullException::ArgumentNullException(), DotNetDupe::System::ArgumentOutOfRangeException::ArgumentOutOfRangeException(), DotNetDupe::System::Array< T >::GetData(), and DotNetDupe::System::Array< T >::GetLength().
|
static |
Guard: Validate input buffer bounds.
Step: Copy 2 bytes into 16-bit integer.
Definition at line 109 of file BitConverter.cpp.
References DotNetDupe::System::ArgumentNullException::ArgumentNullException(), DotNetDupe::System::ArgumentOutOfRangeException::ArgumentOutOfRangeException(), DotNetDupe::System::Array< T >::GetData(), and DotNetDupe::System::Array< T >::GetLength().
Guard: Validate input buffer bounds.
Step: Copy 4 bytes into 32-bit integer.
Definition at line 119 of file BitConverter.cpp.
References DotNetDupe::System::ArgumentNullException::ArgumentNullException(), DotNetDupe::System::ArgumentOutOfRangeException::ArgumentOutOfRangeException(), DotNetDupe::System::Array< T >::GetData(), and DotNetDupe::System::Array< T >::GetLength().
|
static |
Guard: Validate input buffer bounds.
Step: Copy 8 bytes into 64-bit integer.
Definition at line 129 of file BitConverter.cpp.
References DotNetDupe::System::ArgumentNullException::ArgumentNullException(), DotNetDupe::System::ArgumentOutOfRangeException::ArgumentOutOfRangeException(), DotNetDupe::System::Array< T >::GetData(), and DotNetDupe::System::Array< T >::GetLength().
|
static |
Guard: Validate input buffer bounds.
Step: Copy 4 bytes into IEEE 754 float.
Definition at line 139 of file BitConverter.cpp.
References DotNetDupe::System::ArgumentNullException::ArgumentNullException(), DotNetDupe::System::ArgumentOutOfRangeException::ArgumentOutOfRangeException(), DotNetDupe::System::Array< T >::GetData(), and DotNetDupe::System::Array< T >::GetLength().
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().
|
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().
|
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().
|
static |
Guard: Validate input buffer bounds.
Step: Copy 2 bytes into 16-bit unsigned integer.
Definition at line 149 of file BitConverter.cpp.
References DotNetDupe::System::ArgumentNullException::ArgumentNullException(), DotNetDupe::System::ArgumentOutOfRangeException::ArgumentOutOfRangeException(), DotNetDupe::System::Array< T >::GetData(), and DotNetDupe::System::Array< T >::GetLength().
|
static |
Guard: Validate input buffer bounds.
Step: Copy 4 bytes into 32-bit unsigned integer.
Definition at line 159 of file BitConverter.cpp.
References DotNetDupe::System::ArgumentNullException::ArgumentNullException(), DotNetDupe::System::ArgumentOutOfRangeException::ArgumentOutOfRangeException(), DotNetDupe::System::Array< T >::GetData(), and DotNetDupe::System::Array< T >::GetLength().
|
static |
Guard: Validate input buffer bounds.
Step: Copy 8 bytes into 64-bit unsigned integer.
Definition at line 169 of file BitConverter.cpp.
References DotNetDupe::System::ArgumentNullException::ArgumentNullException(), DotNetDupe::System::ArgumentOutOfRangeException::ArgumentOutOfRangeException(), DotNetDupe::System::Array< T >::GetData(), and DotNetDupe::System::Array< T >::GetLength().
|
static |
Indicates whether this computer architecture is little-endian.
Definition at line 25 of file BitConverter.h.
Referenced by DotNetDupe::System::IO::BinaryReader::ReadDouble(), DotNetDupe::System::IO::BinaryReader::ReadInt16(), DotNetDupe::System::IO::BinaryReader::ReadInt32(), DotNetDupe::System::IO::BinaryReader::ReadInt64(), DotNetDupe::System::IO::BinaryReader::ReadSingle(), DotNetDupe::System::IO::BinaryWriter::Write(), DotNetDupe::System::IO::BinaryWriter::Write(), DotNetDupe::System::IO::BinaryWriter::Write(), DotNetDupe::System::IO::BinaryWriter::Write(), and DotNetDupe::System::IO::BinaryWriter::Write().