2#ifndef __aspose_system_marshal_h__
3#define __aspose_system_marshal_h__
6#include <system/exception.h>
10namespace System {
namespace Security {
class SecureString; }}
12namespace System {
namespace Runtime {
namespace InteropServices {
27 template<
typename container>
28 static void Copy(
const IntPtr source, container&& destination,
int startIndex,
int length) {
29 memcpy(&destination->data()[0]+startIndex, (
const void *)source, length*
sizeof(destination->data()[0]));
37 template<
typename container>
38 static void Copy(
const void * source, container&& destination,
int startIndex,
int length) {
39 memcpy(&destination->data()[0]+startIndex, source, length*
sizeof(destination->data()[0]));
48 template<
typename container>
49 static void Copy(
const container &source,
int startIndex,
void * destination,
int length) {
50 memcpy(destination, &source->data()[0]+startIndex, length*
sizeof(
typename container::ValueType));
58 template<
typename container>
59 static void Copy(
const container &source,
int startIndex, IntPtr destination,
int length) {
60 memcpy((
void *)destination, &source->data()[0]+startIndex, length*
sizeof(
typename container::ValueType));
67 static void WriteByte(IntPtr ptr,
int offset, uint8_t value)
69 *((uint8_t*)ptr + offset) = value;
83 static void WriteInt16(IntPtr ptr,
int offset, int16_t value)
85 *((int16_t*)((uint8_t*)ptr + offset)) = value;
92 static void WriteInt32(IntPtr ptr,
int offset, int32_t value)
94 *((int32_t*)((uint8_t*)ptr + offset)) = value;
101 static void WriteInt64(IntPtr ptr,
int offset, int64_t value)
103 *((int64_t*)((uint8_t*)ptr + offset)) = value;
110 static uint8_t
ReadByte(IntPtr ptr,
int offset = 0)
112 return *((uint8_t*)ptr + offset);
120 return *((int16_t*)((uint8_t*)ptr + offset));
128 return *((int32_t*)((uint8_t*)ptr + offset));
136 return exc->get_HResult();
Template that represents wrapper of exceptions that are derived from Exception class.
Definition: exception.h:113
Provides marshalling implementation. For compatibility with translated code only, as no managed code ...
Definition: marshal.h:19
static void ZeroFreeGlobalAllocAnsi(IntPtr s)
Frees unmanaged string pointer that was allocated using the SecureStringToGlobalAllocAnsi method.
static IntPtr StringToHGlobalUni(const String &s)
Copies the contents of a specified string into unmanaged memory.
static IntPtr SecureStringToGlobalAllocUnicode(const SharedPtr< Security::SecureString > &s)
Copies contents of specified secure string into unmanaged memory.
static void Copy(const container &source, int startIndex, void *destination, int length)
Implements public static void Copy(char[] source, int startIndex, IntPtr destination,...
Definition: marshal.h:49
static void Copy(const container &source, int startIndex, IntPtr destination, int length)
Implements public static void Copy(char[] source, int startIndex, IntPtr destination,...
Definition: marshal.h:59
static String PtrToStringAnsi(IntPtr ptr)
Creates a managed String from an unmanaged zero-terminated UTF8-string.
static String PtrToStringAuto(IntPtr ptr, int length)
Creates a managed String from an unmanaged string.
static int32_t ReadInt32(IntPtr ptr, int offset=0)
Reads int from memory.
Definition: marshal.h:126
static void Copy(const IntPtr source, container &&destination, int startIndex, int length)
Implements public static void Copy(IntPtr source, byte[] destination, int startIndex,...
Definition: marshal.h:28
static void FreeHGlobal(IntPtr address)
Frees unmanaged memory.
static String PtrToStringUni(IntPtr ptr, int length)
Creates a managed String from an unmanaged unicode string.
static void WriteByte(IntPtr ptr, int offset, uint8_t value)
Writes byte to memory.
Definition: marshal.h:67
static IntPtr StringToHGlobalAnsi(const String &s)
Copies the contents of a specified string into unmanaged memory.
static void WriteByte(IntPtr ptr, uint8_t value)
Writes byte to memory.
Definition: marshal.h:74
static IntPtr SecureStringToGlobalAllocAnsi(const SharedPtr< Security::SecureString > &s)
Copies contents of specified secure string into unmanaged memory, converting into ANSI format.
static IntPtr StringToHGlobalAuto(const String &s)
Copies the contents of a specified string into unmanaged memory, converting to ANSI format if require...
static int16_t ReadInt16(IntPtr ptr, int offset=0)
Reads short from memory.
Definition: marshal.h:118
static String PtrToStringUni(IntPtr ptr)
Creates a managed String from an unmanaged zero-terminated unicode string.
static void WriteInt64(IntPtr ptr, int offset, int64_t value)
Writes long to memory.
Definition: marshal.h:101
static void ZeroFreeGlobalAllocUnicode(IntPtr s)
Frees unmanaged string pointer that was allocated using the SecureStringToGlobalAllocUnicode method.
static int32_t GetHRForException(const System::Exception &exc)
Gets HResult from exception.
Definition: marshal.h:134
static void WriteInt32(IntPtr ptr, int offset, int32_t value)
Writes int to memory.
Definition: marshal.h:92
static String PtrToStringAuto(IntPtr ptr)
Creates a managed String from an unmanaged zero-terminated string.
static uint8_t ReadByte(IntPtr ptr, int offset=0)
Reads byte from memory.
Definition: marshal.h:110
static IntPtr AllocHGlobal(int32_t bytes_count)
Allocates unmanaged memory.
static void WriteInt16(IntPtr ptr, int offset, int16_t value)
Writes short to memory.
Definition: marshal.h:83
static String PtrToStringUTF8(IntPtr ptr)
Creates a managed String from an unmanaged zero-terminated UTF8-string.
static void Copy(const void *source, container &&destination, int startIndex, int length)
Implements public static void Copy(IntPtr source, byte[] destination, int startIndex,...
Definition: marshal.h:38
static String PtrToStringAnsi(IntPtr ptr, int length)
Creates a managed String from an unmanaged UTF8-string.
static IntPtr AllocHGlobal(IntPtr bytes_count)
Allocates unmanaged memory.
static String PtrToStringUTF8(IntPtr ptr, int length)
Creates a managed String from an unmanaged UTF8-string.
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
String class used across the library. Is a substitute for C# System.String when translating code....
Definition: string.h:122
Definition: db_command.h:9