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

Manipulates arrays of primitive types efficiently at the byte level. More...

#include <Buffer.h>

Inheritance diagram for DotNetDupe::System::Buffer:

Static Public Member Functions

template<typename T>
static void BlockCopy (Array< T > &src, int srcOffset, Array< T > &dst, int dstOffset, int count)
 Copies a specified number of bytes from a source array starting at a particular offset to a destination array.
template<typename T>
static int ByteLength (Array< T > &array)
 Returns the number of bytes in the specified array.
template<typename T>
static byte GetByte (Array< T > &array, int index)
 Retrieves the byte at a specified location in a specified array.
template<typename T>
static void SetByte (Array< T > &array, int index, byte value)
 Assigns a specified value to a byte at a particular location in a specified array.
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.

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

Manipulates arrays of primitive types efficiently at the byte level.

Modeled after .NET System.Buffer. Provides methods to copy bytes between arrays, retrieve individual bytes, assign byte values, and calculate byte lengths.

Definition at line 25 of file Buffer.h.

Member Function Documentation

◆ BlockCopy()

template<typename T>
void DotNetDupe::System::Buffer::BlockCopy ( Array< T > & src,
int srcOffset,
Array< T > & dst,
int dstOffset,
int count )
inlinestatic

Copies a specified number of bytes from a source array starting at a particular offset to a destination array.

Template Parameters
TElement type of the arrays.
Parameters
srcSource array.
srcOffsetZero-based byte offset into src.
dstDestination array.
dstOffsetZero-based byte offset into dst.
countNumber of bytes to copy.
Exceptions
DotNetDupe::System::ArgumentNullExceptionIf src or dst is null.
DotNetDupe::System::ArgumentOutOfRangeExceptionIf offsets or count are negative.
DotNetDupe::System::ArgumentExceptionIf offsets + count exceeds byte length of either array.

Step: Copy contiguous byte segments from source into destination offset.

Definition at line 38 of file Buffer.h.

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

◆ ByteLength()

template<typename T>
int DotNetDupe::System::Buffer::ByteLength ( Array< T > & array)
inlinestatic

Returns the number of bytes in the specified array.

Template Parameters
TElement type of the array.
Parameters
arrayThe array whose byte length is determined.
Returns
Total byte length of array.
Exceptions
DotNetDupe::System::ArgumentNullExceptionIf array is null.

Definition at line 68 of file Buffer.h.

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

Referenced by GetByte(), and SetByte().

◆ GetByte()

template<typename T>
byte DotNetDupe::System::Buffer::GetByte ( Array< T > & array,
int index )
inlinestatic

Retrieves the byte at a specified location in a specified array.

Template Parameters
TElement type of the array.
Parameters
arrayThe array to read from.
indexZero-based byte index.
Returns
The byte at the specified index.
Exceptions
DotNetDupe::System::ArgumentOutOfRangeExceptionIf index is out of range.

Definition at line 81 of file Buffer.h.

References DotNetDupe::System::ArgumentOutOfRangeException::ArgumentOutOfRangeException(), ByteLength(), and DotNetDupe::System::Array< T >::GetData().

◆ SetByte()

template<typename T>
void DotNetDupe::System::Buffer::SetByte ( Array< T > & array,
int index,
byte value )
inlinestatic

Assigns a specified value to a byte at a particular location in a specified array.

Template Parameters
TElement type of the array.
Parameters
arrayThe array to modify.
indexZero-based byte index.
valueByte value to write.
Exceptions
DotNetDupe::System::ArgumentOutOfRangeExceptionIf index is out of range.

Definition at line 94 of file Buffer.h.

References DotNetDupe::System::ArgumentOutOfRangeException::ArgumentOutOfRangeException(), ByteLength(), and DotNetDupe::System::Array< T >::GetData().


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