// clang-format off #ifndef CSHARP_UTILS_H #define CSHARP_UTILS_H #include #include #include #include #using namespace CSharp { /** * Handy functions. */ inline std::string to_string(System::String^ value) { return msclr::interop::marshal_as(value); } inline std::wstring to_wstring(System::String^ value) { return msclr::interop::marshal_as(value); } inline QString to_qstring(System::String^ value) { msclr::interop::marshal_context ctx; return QString::fromWCharArray(ctx.marshal_as(value)); } template inline System::String^ from_string(Str const& string) { return msclr::interop::marshal_as(string); } inline System::String^ from_string(QString const& string) { return msclr::interop::marshal_as(string.toStdWString().c_str()); } } #endif