00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #pragma once
00020
00021 #include <string.h>
00022 #include <FdoCommon.h>
00023
00024
00025
00026 class StringToUni
00027 {
00028 private:
00029 void* m_ptr;
00030
00031 public:
00032 StringToUni(System::Object * str)
00033 {
00034 m_ptr = System::Runtime::InteropServices::Marshal::StringToHGlobalUni(__try_cast<System::String*>(str)).ToPointer();
00035 }
00036 StringToUni(System::String * str)
00037 {
00038 m_ptr = System::Runtime::InteropServices::Marshal::StringToHGlobalUni(str).ToPointer();
00039 }
00040 ~StringToUni()
00041 {
00042 System::Runtime::InteropServices::Marshal::FreeHGlobal(System::IntPtr(m_ptr));
00043 }
00044 operator const FdoString*()
00045 {
00046 return (const FdoString*)m_ptr;
00047 }
00048 };
00049
00050 class StringToAnsi
00051 {
00052 private:
00053 void* m_ptr;
00054
00055 public:
00056 StringToAnsi(System::Object * str)
00057 {
00058 m_ptr = System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(__try_cast<System::String*>(str)).ToPointer();
00059 }
00060 StringToAnsi(System::String * str)
00061 {
00062 m_ptr = System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(str).ToPointer();
00063 }
00064 ~StringToAnsi()
00065 {
00066 System::Runtime::InteropServices::Marshal::FreeHGlobal(System::IntPtr(m_ptr));
00067 }
00068 operator const char*()
00069 {
00070 return (const char*)m_ptr;
00071 }
00072 };
00073
00074 inline System::Byte FdoByteArrayToByteArray(const FdoByte* umBuffer, FdoInt32 len) []
00075 {
00076 System::Byte mgBuffer __gc[] = new System::Byte[len];
00077 for (FdoInt32 i = 0; i < len; i++)
00078 {
00079 mgBuffer[i] = umBuffer[i];
00080 }
00081 return mgBuffer;
00082 }
00083
00084
00085
00086
00087 inline FdoByteArray* ByteArrayToFdoByteArray(System::Byte mgBuffer __gc[])
00088 {
00089 FdoByte* umBuffer = new FdoByte[mgBuffer->Length];
00090 for (FdoInt32 i = 0; i < mgBuffer->Length; i++)
00091 {
00092 umBuffer[i] = mgBuffer[i];
00093 }
00094 return FdoByteArray::Create(umBuffer, mgBuffer->Length);
00095 }
00096
00097 inline System::String* FdoStringArrayToStringArray(const FdoString** umArray, FdoInt32 len) []
00098 {
00099 System::String* mgArray __gc[] = __gc new System::String*[len];
00100 for (FdoInt32 i = 0; i < len; i++)
00101 {
00102 mgArray[i] = new System::String(umArray[i]);
00103 }
00104 return mgArray;
00105 }
00106
00107 inline FdoString** UnwrapStringArray(System::String* mgArray[])
00108 {
00109 FdoString** umArray = new FdoString*[mgArray->Length];
00110
00111 for (FdoInt32 i = 0; i < mgArray->Length; i++)
00112 {
00113 wchar_t* temp = new wchar_t[mgArray[i]->Length];
00114 wcscpy(temp, StringToUni(mgArray[i]));
00115 umArray[i] = temp;
00116 }
00117 return umArray;
00118 }
00119
00120
00121 inline System::DateTime FdoDateTimeToDateTime(FdoDateTime& date)
00122 {
00123 return System::DateTime(date.year, date.month, date.day, date.hour, date.minute, System::Int32(date.seconds));;
00124 }
00125
00126 inline FdoDateTime SystemDateToFdoDateTime(System::DateTime date)
00127 {
00128 return FdoDateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, FdoFloat(date.Second));
00129 }
00130
00131 inline System::Boolean* FdoBoolToBoolean(FdoBoolean* b)
00132 {
00133 }
00134
00135 inline static FdoBoolean* BooleanToFdoBool(System::Boolean* b)
00136 {
00137 System::Boolean __pin* bb = b;
00138 return bb;
00139 }
00140
00141