3#ifndef _aspose_system_buffer_h_
4#define _aspose_system_buffer_h_
9#include "system/array.h"
10#include "system/exceptions.h"
11#include "system/details/array_view.h"
12#include "system/details/stack_array.h"
76 static ASPOSECPP_SHARED_API
void BlockCopy(
const uint8_t* src,
int srcOffset, uint8_t* dst,
int dstOffset,
int count);
86 template<
typename TSrc,
typename TDst>
89 BlockCopy(
static_cast<System::Details::ArrayView<TSrc>
>(src), srcOffset,
static_cast<System::Details::ArrayView<TDst>
>(dst), dstOffset, count);
100 template<
typename TSrc,
typename TDst>
101 static void BlockCopy(
const System::Details::ArrayView<TSrc>& src,
int srcOffset,
const System::Details::ArrayView<TDst>& dst,
int dstOffset,
int count)
103 static_assert(Details::IsPod<TSrc>::value,
"BlockCopy template argument must be a POD type.");
104 static_assert(Details::IsPod<TDst>::value,
"BlockCopy template argument must be a POD type.");
107 throw ArgumentNullException(u
"src");
110 throw ArgumentNullException(u
"dst");
112 if (0 > srcOffset || 0 > dstOffset || 0 > count)
113 throw ArgumentOutOfRangeException();
115 if (_ByteLength(src) < srcOffset || _ByteLength(src) < srcOffset + count)
116 throw ArgumentOutOfRangeException(u
"src->Count() < srcOffset |+count|");
118 if (_ByteLength(dst) < dstOffset || _ByteLength(dst) < dstOffset + count)
119 throw ArgumentOutOfRangeException(u
"dst->Count() < dstOffset |+count|");
124 _BlockCopy(src, srcOffset, dst, dstOffset, count);
135 template<
typename TSrc,
typename TDst>
138 BlockCopy(
static_cast<System::Details::ArrayView<TSrc>
>(src), srcOffset, dst, dstOffset, count);
149 template<
typename TSrc,
typename TDst>
152 BlockCopy(src, srcOffset,
static_cast<System::Details::ArrayView<TDst>
>(dst), dstOffset, count);
165 template<
typename TSrc, std::
size_t NS,
typename TDst, std::
size_t ND>
166 static void BlockCopy(
const System::Details::StackArray<TSrc, NS>& src,
int srcOffset,
const System::Details::StackArray<TDst, ND>& dst,
int dstOffset,
int count)
168 BlockCopy(
static_cast<System::Details::ArrayView<TSrc>
>(src), srcOffset,
static_cast<System::Details::ArrayView<TDst>
>(dst), dstOffset, count);
180 template<
typename TSrc,
typename TDst, std::
size_t ND>
183 BlockCopy(
static_cast<System::Details::ArrayView<TSrc>
>(src), srcOffset,
static_cast<System::Details::ArrayView<TDst>
>(dst), dstOffset, count);
195 template<
typename TSrc, std::
size_t NS,
typename TDst>
198 BlockCopy(
static_cast<System::Details::ArrayView<TSrc>
>(src), srcOffset,
static_cast<System::Details::ArrayView<TDst>
>(dst), dstOffset, count);
208 return ByteLength(
static_cast<System::Details::ArrayView<T>
>(array));
216 static int ByteLength(
const System::Details::ArrayView<T>& array)
218 static_assert(Details::IsPod<T>::value,
"ByteLength template argument must be a POD type.");
221 throw ArgumentNullException(u
"array");
223 return _ByteLength(array);
231 template<
class T, std::
size_t N>
232 static int ByteLength(
const System::Details::StackArray<T, N>& array)
234 return ByteLength(
static_cast<System::Details::ArrayView<T>
>(array));
245 return GetByte(
static_cast<System::Details::ArrayView<T>
>(array), index);
254 static uint8_t
GetByte(
const System::Details::ArrayView<T>& array,
int index)
256 static_assert(Details::IsPod<T>::value,
"GetByte template argument must be a POD type.");
259 throw ArgumentNullException(u
"array");
261 if (index < 0 || index >= _ByteLength(array))
262 throw ArgumentOutOfRangeException(u
"index");
264 return _GetByte<T>(array, index);
273 template<
typename T, std::
size_t N>
274 static uint8_t
GetByte(
const System::Details::StackArray<T, N>& array,
int index)
276 return GetByte(
static_cast<System::Details::ArrayView<T>
>(array), index);
287 SetByte(
static_cast<System::Details::ArrayView<T>
>(array), index, value);
296 static void SetByte(
const System::Details::ArrayView<T>& array,
int index, uint8_t value)
298 static_assert(Details::IsPod<T>::value,
"SetByte template argument must be a POD type.");
301 throw ArgumentNullException(u
"array");
303 if (index < 0 || index >= _ByteLength(array))
304 throw ArgumentOutOfRangeException(u
"index");
306 return _SetByte<T>(array, index, value);
315 template<
typename T, std::
size_t N>
316 static void SetByte(
const System::Details::StackArray<T, N>& array,
int index, uint8_t value)
318 SetByte(
static_cast<System::Details::ArrayView<T>
>(array), index, value);
328 static int _ByteLength(
const System::Details::ArrayView<T>& array)
330 return (
int)(array.Count()*
sizeof(T));
339 static uint8_t _GetByte(
const System::Details::ArrayView<T>& array,
int index)
341 return reinterpret_cast<const uint8_t*
>(array.data())[index];
350 static void _SetByte(
const System::Details::ArrayView<T>& array,
int index, uint8_t value)
352 reinterpret_cast<uint8_t*
>(array.data())[index] = value;
363 template<
typename TSrc,
typename TDst>
364 static void _BlockCopy(
const System::Details::ArrayView<TSrc>& src,
int srcOffset,
const System::Details::ArrayView<TDst>& dst,
int dstOffset,
int count)
366 std::copy(
reinterpret_cast<const uint8_t*
>(src.data()) +
static_cast<size_t>(srcOffset)
367 ,
reinterpret_cast<const uint8_t*
>(src.data()) +
static_cast<size_t>(srcOffset) +
static_cast<size_t>(count)
368 ,
reinterpret_cast<uint8_t*
>(dst.data()) +
static_cast<size_t>(dstOffset));
Class that represents an array data structure. Objects of this class should only be allocated using S...
Definition: array.h:259
Contains methods that manipulate raw byte arrays. This is a static type with no instance services....
Definition: buffer.h:67
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 anot...
Definition: buffer.h:136
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 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 anot...
Definition: buffer.h:166
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 by...
Definition: buffer.h:254
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 anot...
Definition: buffer.h:101
static int ByteLength(const System::Details::ArrayView< T > &array)
Determines the number of bytes occupied by all elements of the specified array.
Definition: buffer.h:216
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 anot...
Definition: buffer.h:181
static int ByteLength(const SharedPtr< Array< T > > &array)
Determines the number of bytes occupied by all elements of the specified array.
Definition: buffer.h:206
static int ByteLength(const System::Details::StackArray< T, N > &array)
Determines the number of bytes occupied by all elements of the specified array.
Definition: buffer.h:232
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 anot...
Definition: buffer.h:150
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 specifi...
Definition: buffer.h:296
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 specifi...
Definition: buffer.h:316
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 anot...
Definition: buffer.h:87
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 by...
Definition: buffer.h:274
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 anot...
Definition: buffer.h:196
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
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 by...
Definition: buffer.h:243
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
Definition: db_command.h:9