2024-03-26 10:32:56 -03:00
|
|
|
#ifndef XNA_CSHARP_BUFFER_HPP
|
|
|
|
#define XNA_CSHARP_BUFFER_HPP
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace xna {
|
2024-05-29 09:42:18 -03:00
|
|
|
//A simplified port of the System.Buffer class.
|
2024-03-26 10:32:56 -03:00
|
|
|
class Buffer {
|
|
|
|
public:
|
2024-11-08 15:26:57 -03:00
|
|
|
//Copies from one primitive array to another primitive array without respecting types.
|
2024-03-26 10:32:56 -03:00
|
|
|
template <typename T>
|
2024-11-08 15:26:57 -03:00
|
|
|
static inline void BlockCopy(T const* src, rsize_t srcOffset, T* dst, rsize_t dstOffset, rsize_t byteCount) {
|
2024-03-26 10:32:56 -03:00
|
|
|
memmove_s(dst + dstOffset, byteCount, src + srcOffset, byteCount);
|
2024-05-04 21:07:39 -03:00
|
|
|
}
|
|
|
|
|
2024-11-08 15:26:57 -03:00
|
|
|
//Copies from one primitive array to another primitive array without respecting types.
|
2024-05-04 21:07:39 -03:00
|
|
|
template <typename TSOURCE, typename TDEST>
|
2024-11-08 15:26:57 -03:00
|
|
|
static inline void BlockCopy(TSOURCE const* src, rsize_t srcOffset, TDEST* dst, rsize_t dstOffset, rsize_t byteCount) {
|
2024-05-04 21:07:39 -03:00
|
|
|
memmove_s(dst + dstOffset, byteCount, src + srcOffset, byteCount);
|
|
|
|
}
|
2024-03-26 10:32:56 -03:00
|
|
|
|
|
|
|
private:
|
|
|
|
constexpr Buffer() = default;
|
|
|
|
constexpr Buffer(Buffer&&) = default;
|
|
|
|
constexpr Buffer(const Buffer&) = default;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|