-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathUtility.h
61 lines (52 loc) · 1.06 KB
/
Utility.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#pragma once
#include <vector>
using namespace System;
using namespace System::Numerics;
namespace PowerSolutions
{
namespace Interop
{
inline Complex MarshalComplex(const complexd value)
{
return Complex(value.real(), value.imag());
}
inline complexd MarshalComplex(Complex value)
{
return complexd(value.Real, value.Imaginary);
}
template <class T>
inline T* MarshalPointer(IntPtr ptr)
{
return (T*)(void*)(ptr);
}
template <class T>
inline IntPtr MarshalPointer(T* ptr)
{
return IntPtr(ptr);
}
inline cli::array<Complex>^ MarshalComplexArray(const std::vector<complexd>& value)
{
auto arr = gcnew cli::array<Complex>(value.size());
int i = 0;
for (auto item : value)
{
arr[i] = Complex(item.real(), item.imag());
i++;
}
return arr;
}
System::Exception^ TranslateException(const std::exception& ex);
/*template <class TFunc>
inline void CRTExceptionBoundary(TFunc&& action)
{
try
{
action();
}
catch (std::exception& ex)
{
throw TranslateException(ex);
}
}*/
}
}