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);
109 template<
typename TSrc,
typename TDst>
110 static void BlockCopy(
const System::Details::ArrayView<TSrc>& src,
int srcOffset,
const System::Details::ArrayView<TDst>& dst,
int dstOffset,
int count)
112 static_assert(Details::IsPod<TSrc>::value,
"BlockCopy template argument must be a POD type.");
113 static_assert(Details::IsPod<TDst>::value,
"BlockCopy template argument must be a POD type.");
116 throw ArgumentNullException(u
"src");
119 throw ArgumentNullException(u
"dst");
121 if (0 > srcOffset || 0 > dstOffset || 0 > count)
122 throw ArgumentOutOfRangeException();
124 if (_ByteLength(src) < srcOffset || _ByteLength(src) < srcOffset + count)
125 throw ArgumentOutOfRangeException(u
"src->Count() < srcOffset |+count|");
127 if (_ByteLength(dst) < dstOffset || _ByteLength(dst) < dstOffset + count)
128 throw ArgumentOutOfRangeException(u
"dst->Count() < dstOffset |+count|");
133 _BlockCopy(src, srcOffset, dst, dstOffset, count);
144 template<
typename TSrc,
typename TDst>
147 BlockCopy(
static_cast<System::Details::ArrayView<TSrc>
>(src), srcOffset, dst, dstOffset, count);
158 template<
typename TSrc,
typename TDst>
161 BlockCopy(src, srcOffset,
static_cast<System::Details::ArrayView<TDst>
>(dst), dstOffset, count);
174 template<
typename TSrc, std::
size_t NS,
typename TDst, std::
size_t ND>
175 static void BlockCopy(
const System::Details::StackArray<TSrc, NS>& src,
int srcOffset,
const System::Details::StackArray<TDst, ND>& dst,
int dstOffset,
int count)
177 BlockCopy(
static_cast<System::Details::ArrayView<TSrc>
>(src), srcOffset,
static_cast<System::Details::ArrayView<TDst>
>(dst), dstOffset, count);
189 template<
typename TSrc,
typename TDst, std::
size_t ND>
192 BlockCopy(
static_cast<System::Details::ArrayView<TSrc>
>(src), srcOffset,
static_cast<System::Details::ArrayView<TDst>
>(dst), dstOffset, count);
204 template<
typename TSrc, std::
size_t NS,
typename TDst>
207 BlockCopy(
static_cast<System::Details::ArrayView<TSrc>
>(src), srcOffset,
static_cast<System::Details::ArrayView<TDst>
>(dst), dstOffset, count);
217 return ByteLength(
static_cast<System::Details::ArrayView<T>
>(array));
225 static int ByteLength(
const System::Details::ArrayView<T>& array)
227 static_assert(Details::IsPod<T>::value,
"ByteLength template argument must be a POD type.");
230 throw ArgumentNullException(u
"array");
232 return _ByteLength(array);
240 template<
class T, std::
size_t N>
241 static int ByteLength(
const System::Details::StackArray<T, N>& array)
243 return ByteLength(
static_cast<System::Details::ArrayView<T>
>(array));
254 return GetByte(
static_cast<System::Details::ArrayView<T>
>(array), index);
263 static uint8_t
GetByte(
const System::Details::ArrayView<T>& array,
int index)
265 static_assert(Details::IsPod<T>::value,
"GetByte template argument must be a POD type.");
268 throw ArgumentNullException(u
"array");
270 if (index < 0 || index >= _ByteLength(array))
271 throw ArgumentOutOfRangeException(u
"index");
273 return _GetByte<T>(array, index);
282 template<
typename T, std::
size_t N>
283 static uint8_t
GetByte(
const System::Details::StackArray<T, N>& array,
int index)
285 return GetByte(
static_cast<System::Details::ArrayView<T>
>(array), index);
296 SetByte(
static_cast<System::Details::ArrayView<T>
>(array), index, value);
305 static void SetByte(
const System::Details::ArrayView<T>& array,
int index, uint8_t value)
307 static_assert(Details::IsPod<T>::value,
"SetByte template argument must be a POD type.");
310 throw ArgumentNullException(u
"array");
312 if (index < 0 || index >= _ByteLength(array))
313 throw ArgumentOutOfRangeException(u
"index");
315 return _SetByte<T>(array, index, value);
324 template<
typename T, std::
size_t N>
325 static void SetByte(
const System::Details::StackArray<T, N>& array,
int index, uint8_t value)
327 SetByte(
static_cast<System::Details::ArrayView<T>
>(array), index, value);
337 static int _ByteLength(
const System::Details::ArrayView<T>& array)
339 return (
int)(array.Count()*
sizeof(T));
348 static uint8_t _GetByte(
const System::Details::ArrayView<T>& array,
int index)
350 return reinterpret_cast<const uint8_t*
>(array.data())[index];
359 static void _SetByte(
const System::Details::ArrayView<T>& array,
int index, uint8_t value)
361 reinterpret_cast<uint8_t*
>(array.data())[index] = value;
372 template<
typename TSrc,
typename TDst>
373 static void _BlockCopy(
const System::Details::ArrayView<TSrc>& src,
int srcOffset,
const System::Details::ArrayView<TDst>& dst,
int dstOffset,
int count)
375 std::copy(
reinterpret_cast<const uint8_t*
>(src.data()) +
static_cast<size_t>(srcOffset)
376 ,
reinterpret_cast<const uint8_t*
>(src.data()) +
static_cast<size_t>(srcOffset) +
static_cast<size_t>(count)
377 ,
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:285
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:145
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:175
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:263
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:110
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:225
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:190
static int ByteLength(const SharedPtr< Array< T > > &array)
Determines the number of bytes occupied by all elements of the specified array.
Definition: buffer.h:215
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:241
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:159
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:305
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:325
static void BlockCopy(const SharedPtr< ArrayBase > &src, int srcOffset, const SharedPtr< ArrayBase > &dst, int dstOffset, int count)
Interprets two specified arrays as raw arrays of bytes and copies data from one of them to another.
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:283
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:205
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:294
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:252
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