Asposecpplib
System::Buffer Class Reference

Contains methods that manipulate raw byte arrays. This is a static type with no instance services. You should never create instances of it by any means. More...

Static Public Member Functions

static void BlockCopy (const uint8_t *src, int srcOffset, uint8_t *dst, int dstOffset, int count)
 Copies a specified number of bytes from source buffer to destination buffer. More...
 
template<typename TSrc , typename TDst >
static void BlockCopy (const SharedPtr< Array< TSrc >> &src, int srcOffset, const SharedPtr< Array< TDst >> &dst, int dstOffset, int count)
 Interprets two specified typed arrays as raw arrays of bytes and copies data from one of them to another. More...
 
template<typename TSrc , typename TDst >
static void BlockCopy (const System::Details::ArrayView< TSrc > &src, int srcOffset, const System::Details::ArrayView< TDst > &dst, int dstOffset, int count)
 Interprets two specified typed arrays as raw arrays of bytes and copies data from one of them to another. More...
 
template<typename TSrc , typename TDst >
static void BlockCopy (const SharedPtr< Array< TSrc >> &src, int srcOffset, const System::Details::ArrayView< TDst > &dst, int dstOffset, int count)
 Interprets two specified typed arrays as raw arrays of bytes and copies data from one of them to another. More...
 
template<typename TSrc , typename TDst >
static void BlockCopy (const System::Details::ArrayView< TSrc > &src, int srcOffset, const SharedPtr< Array< TDst >> &dst, int dstOffset, int count)
 Interprets two specified typed arrays as raw arrays of bytes and copies data from one of them to another. More...
 
template<typename TSrc , std::size_t NS, typename TDst , std::size_t ND>
static void BlockCopy (const System::Details::StackArray< TSrc, NS > &src, int srcOffset, const System::Details::StackArray< TDst, ND > &dst, int dstOffset, int count)
 Interprets two specified typed arrays as raw arrays of bytes and copies data from one of them to another. More...
 
template<typename TSrc , typename TDst , std::size_t ND>
static void BlockCopy (const SharedPtr< Array< TSrc >> &src, int srcOffset, const System::Details::StackArray< TDst, ND > &dst, int dstOffset, int count)
 Interprets two specified typed arrays as raw arrays of bytes and copies data from one of them to another. More...
 
template<typename TSrc , std::size_t NS, typename TDst >
static void BlockCopy (const System::Details::StackArray< TSrc, NS > &src, int srcOffset, const SharedPtr< Array< TDst >> &dst, int dstOffset, int count)
 Interprets two specified typed arrays as raw arrays of bytes and copies data from one of them to another. More...
 
template<class T >
static int ByteLength (const SharedPtr< Array< T >> &array)
 Determines the number of bytes occupied by all elements of the specified array. More...
 
template<class T >
static int ByteLength (const System::Details::ArrayView< T > &array)
 Determines the number of bytes occupied by all elements of the specified array. More...
 
template<class T , std::size_t N>
static int ByteLength (const System::Details::StackArray< T, N > &array)
 Determines the number of bytes occupied by all elements of the specified array. More...
 
template<typename T >
static uint8_t GetByte (const SharedPtr< Array< T >> &array, int index)
 Interprets the specified typed array as a raw byte array and retrieves the byte value at specified byte offset. More...
 
template<typename T >
static uint8_t GetByte (const System::Details::ArrayView< T > &array, int index)
 Interprets the specified typed array as a raw byte array and retrieves the byte value at specified byte offset. More...
 
template<typename T , std::size_t N>
static uint8_t GetByte (const System::Details::StackArray< T, N > &array, int index)
 Interprets the specified typed array as a raw byte array and retrieves the byte value at specified byte offset. More...
 
template<typename T >
static void SetByte (const SharedPtr< Array< T >> &array, int index, uint8_t value)
 Interprets the specified typed array as a raw byte array and sets the specified byte value at specified byte offset. More...
 
template<typename T >
static void SetByte (const System::Details::ArrayView< T > &array, int index, uint8_t value)
 Interprets the specified typed array as a raw byte array and sets the specified byte value at specified byte offset. More...
 
template<typename T , std::size_t N>
static void SetByte (const System::Details::StackArray< T, N > &array, int index, uint8_t value)
 Interprets the specified typed array as a raw byte array and sets the specified byte value at specified byte offset. More...
 

Detailed Description

Contains methods that manipulate raw byte arrays. This is a static type with no instance services. You should never create instances of it by any means.

#include <system/buffer.h>
using namespace System;
void Print(const SmartPtr<Array<uint8_t>> &source, int size)
{
for (auto i = 0; i < size; i++)
{
std::cout << static_cast<int>(source[i]) << ' ';
}
std::cout << std::endl;
}
int main()
{
// Create and fill the array.
const int SIZE = 16;
auto first = MakeObject<Array<uint8_t>>(SIZE);
for (auto i = 0; i < SIZE; ++i)
{
first[i] = static_cast<uint8_t>(i * 2);
}
// Print the array items.
Print(first, SIZE);
// Create an array that contains a part of the first one.
auto second = MakeObject<Array<uint8_t>>(SIZE / 2);
Buffer::BlockCopy(first, SIZE / 2, second, 0, SIZE / 2);
// Print the items of the second array.
Print(second, SIZE / 2);
// Set the value of the item at index 0 and print the array items.
Buffer::SetByte(second, 0, 128);
Print(second, SIZE / 2);
return 0;
}
/*
This code example produces the following output:
0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30
16 18 20 22 24 26 28 30
128 18 20 22 24 26 28 30
*/
static void BlockCopy(const uint8_t *src, int srcOffset, uint8_t *dst, int dstOffset, int count)
Copies a specified number of bytes from source buffer to destination buffer.
static void SetByte(const SharedPtr< Array< T >> &array, int index, uint8_t value)
Interprets the specified typed array as a raw byte array and sets the specified byte value at specifi...
Definition: buffer.h:285
Definition: db_command.h:9

Member Function Documentation

◆ BlockCopy() [1/8]

template<typename TSrc , typename TDst >
static void System::Buffer::BlockCopy ( const SharedPtr< Array< TSrc >> &  src,
int  srcOffset,
const SharedPtr< Array< TDst >> &  dst,
int  dstOffset,
int  count 
)
inlinestatic

Interprets two specified typed arrays as raw arrays of bytes and copies data from one of them to another.

Parameters
srcThe source array
srcOffsetA byte offset in the tho source array at which copying starts
dstThe destination array
dstOffsetA byte offset in the destination array at which to start inserting data
countThe number of bytes to copy
Template Parameters
TSrcThe type of elements of the source array
TDstThe type of elements of the destination array

◆ BlockCopy() [2/8]

template<typename TSrc , typename TDst >
static void System::Buffer::BlockCopy ( const SharedPtr< Array< TSrc >> &  src,
int  srcOffset,
const System::Details::ArrayView< TDst > &  dst,
int  dstOffset,
int  count 
)
inlinestatic

Interprets two specified typed arrays as raw arrays of bytes and copies data from one of them to another.

Parameters
srcThe source array
srcOffsetA byte offset in the tho source array at which copying starts
dstThe destination array view
dstOffsetA byte offset in the destination array view at which to start inserting data
countThe number of bytes to copy
Template Parameters
TSrcThe type of elements of the source array
TDstThe type of elements of the destination array view

◆ BlockCopy() [3/8]

template<typename TSrc , typename TDst , std::size_t ND>
static void System::Buffer::BlockCopy ( const SharedPtr< Array< TSrc >> &  src,
int  srcOffset,
const System::Details::StackArray< TDst, ND > &  dst,
int  dstOffset,
int  count 
)
inlinestatic

Interprets two specified typed arrays as raw arrays of bytes and copies data from one of them to another.

Parameters
srcThe source array
srcOffsetA byte offset in the tho source array at which copying starts
dstThe destination stack array
dstOffsetA byte offset in the destination stack array at which to start inserting data
countThe number of bytes to copy
Template Parameters
TSrcThe type of elements of the source array
TDstThe type of elements of the destination stack array
NDThe size of the destination stack array

◆ BlockCopy() [4/8]

template<typename TSrc , typename TDst >
static void System::Buffer::BlockCopy ( const System::Details::ArrayView< TSrc > &  src,
int  srcOffset,
const SharedPtr< Array< TDst >> &  dst,
int  dstOffset,
int  count 
)
inlinestatic

Interprets two specified typed arrays as raw arrays of bytes and copies data from one of them to another.

Parameters
srcThe source array view
srcOffsetA byte offset in the tho source array view at which copying starts
dstThe destination array
dstOffsetA byte offset in the destination array at which to start inserting data
countThe number of bytes to copy
Template Parameters
TSrcThe type of elements of the source array view
TDstThe type of elements of the destination array

◆ BlockCopy() [5/8]

template<typename TSrc , typename TDst >
static void System::Buffer::BlockCopy ( const System::Details::ArrayView< TSrc > &  src,
int  srcOffset,
const System::Details::ArrayView< TDst > &  dst,
int  dstOffset,
int  count 
)
inlinestatic

Interprets two specified typed arrays as raw arrays of bytes and copies data from one of them to another.

Parameters
srcThe source array view
srcOffsetA byte offset in the tho source array view at which copying starts
dstThe destination array view
dstOffsetA byte offset in the destination array view at which to start inserting data
countThe number of bytes to copy
Template Parameters
TSrcThe type of elements of the source array view
TDstThe type of elements of the destination array view

◆ BlockCopy() [6/8]

template<typename TSrc , std::size_t NS, typename TDst >
static void System::Buffer::BlockCopy ( const System::Details::StackArray< TSrc, NS > &  src,
int  srcOffset,
const SharedPtr< Array< TDst >> &  dst,
int  dstOffset,
int  count 
)
inlinestatic

Interprets two specified typed arrays as raw arrays of bytes and copies data from one of them to another.

Parameters
srcThe source stack array
srcOffsetA byte offset in the tho source stack array at which copying starts
dstThe destination array
dstOffsetA byte offset in the destination array at which to start inserting data
countThe number of bytes to copy
Template Parameters
TSrcThe type of elements of the source stack array
NSThe size of the source stack array
TDstThe type of elements of the destination array

◆ BlockCopy() [7/8]

template<typename TSrc , std::size_t NS, typename TDst , std::size_t ND>
static void System::Buffer::BlockCopy ( const System::Details::StackArray< TSrc, NS > &  src,
int  srcOffset,
const System::Details::StackArray< TDst, ND > &  dst,
int  dstOffset,
int  count 
)
inlinestatic

Interprets two specified typed arrays as raw arrays of bytes and copies data from one of them to another.

Parameters
srcThe source stack array
srcOffsetA byte offset in the tho source stack array at which copying starts
dstThe destination stack array
dstOffsetA byte offset in the destination stack array at which to start inserting data
countThe number of bytes to copy
Template Parameters
TSrcThe type of elements of the source stack array
NSThe size of the source stack array
TDstThe type of elements of the destination stack array
NDThe size of the destination stack array

◆ BlockCopy() [8/8]

static void System::Buffer::BlockCopy ( const uint8_t *  src,
int  srcOffset,
uint8_t *  dst,
int  dstOffset,
int  count 
)
static

Copies a specified number of bytes from source buffer to destination buffer.

Parameters
srcPointer to the source buffer
srcOffsetA byte offset in source buffer at which copying starts
dstPointer to the destination buffer
dstOffsetA byte offset in the destination buffer at which to start inserting data
countThe number of bytes to copy

◆ ByteLength() [1/3]

template<class T >
static int System::Buffer::ByteLength ( const SharedPtr< Array< T >> &  array)
inlinestatic

Determines the number of bytes occupied by all elements of the specified array.

Parameters
arrayAn array
Returns
The number of bytes occupied by all elements of the specified array
Template Parameters
TThe type of elements of the array

◆ ByteLength() [2/3]

template<class T >
static int System::Buffer::ByteLength ( const System::Details::ArrayView< T > &  array)
inlinestatic

Determines the number of bytes occupied by all elements of the specified array.

Parameters
arrayAn array view
Returns
The number of bytes occupied by all elements of the specified array view
Template Parameters
TThe type of elements of the array view

◆ ByteLength() [3/3]

template<class T , std::size_t N>
static int System::Buffer::ByteLength ( const System::Details::StackArray< T, N > &  array)
inlinestatic

Determines the number of bytes occupied by all elements of the specified array.

Parameters
arrayAn stack array
Returns
The number of bytes occupied by all elements of the specified stack array
Template Parameters
TThe type of elements of the stack array
NThe size of the stack array

◆ GetByte() [1/3]

template<typename T >
static uint8_t System::Buffer::GetByte ( const SharedPtr< Array< T >> &  array,
int  index 
)
inlinestatic

Interprets the specified typed array as a raw byte array and retrieves the byte value at specified byte offset.

Parameters
arrayThe target array
indexZero-based offset of the byte to retrieve
Returns
The byte value at the specified index
Template Parameters
TThe type of elements of the array

◆ GetByte() [2/3]

template<typename T >
static uint8_t System::Buffer::GetByte ( const System::Details::ArrayView< T > &  array,
int  index 
)
inlinestatic

Interprets the specified typed array as a raw byte array and retrieves the byte value at specified byte offset.

Parameters
arrayThe target array view
indexZero-based offset of the byte to retrieve
Returns
The byte value at the specified index
Template Parameters
TThe type of elements of the array view

◆ GetByte() [3/3]

template<typename T , std::size_t N>
static uint8_t System::Buffer::GetByte ( const System::Details::StackArray< T, N > &  array,
int  index 
)
inlinestatic

Interprets the specified typed array as a raw byte array and retrieves the byte value at specified byte offset.

Parameters
arrayThe target stack array
indexZero-based offset of the byte to retrieve
Returns
The byte value at the specified index
Template Parameters
TThe type of elements of the stack array
NThe size of the stack array

◆ SetByte() [1/3]

template<typename T >
static void System::Buffer::SetByte ( const SharedPtr< Array< T >> &  array,
int  index,
uint8_t  value 
)
inlinestatic

Interprets the specified typed array as a raw byte array and sets the specified byte value at specified byte offset.

Parameters
arrayThe target array
indexZero-based offset of the byte to set
valueThe byte value to set
Template Parameters
TThe type of elements of the array

◆ SetByte() [2/3]

template<typename T >
static void System::Buffer::SetByte ( const System::Details::ArrayView< T > &  array,
int  index,
uint8_t  value 
)
inlinestatic

Interprets the specified typed array as a raw byte array and sets the specified byte value at specified byte offset.

Parameters
arrayThe target array view
indexZero-based offset of the byte to set
valueThe byte value to set
Template Parameters
TThe type of elements of the array

◆ SetByte() [3/3]

template<typename T , std::size_t N>
static void System::Buffer::SetByte ( const System::Details::StackArray< T, N > &  array,
int  index,
uint8_t  value 
)
inlinestatic

Interprets the specified typed array as a raw byte array and sets the specified byte value at specified byte offset.

Parameters
arrayThe target stack array
indexZero-based offset of the byte to set
valueThe byte value to set
Template Parameters
TThe type of elements of the array
NThe size of the stack array