#pragma once #ifndef _FUNCTIONS_HPP_ #define _FUNCTIONS_HPP_ static int AnsiToW(CStringA & Src, CStringW & Dest) { int j,l; l=Src.GetLength(); j=MultiByteToWideChar(CP_ACP,0,Src,l,Dest.GetBuffer(l),l); Dest.ReleaseBuffer(j); return 0; } static int WToAnsi(CStringW & Src, CStringA & Dest) { int j,l; l=Src.GetLength(); j=WideCharToMultiByte(CP_ACP,0,Src,l,Dest.GetBuffer(l*2),l*2,NULL,0); Dest.ReleaseBuffer(j); return 0; } inline int AnsiToT(CStringA & Src, CString & Dest) { #ifdef UNICODE AnsiToW(Src,Dest); #else Dest=Src; #endif return 0; } static int TToAnsi(CString & Src, CStringA & Dest) { #ifdef UNICODE WToAnsi(Src,Dest); #else Dest=Src; #endif return 0; } static int TToW(CString & Src, CStringW & Dest) { #ifdef UNICODE Dest=Src; #else AnsiToW(Src,Dest); #endif return 0; } static int WToT(CStringW & Src, CString & Dest) { #ifdef UNICODE Dest=Src; #else WToAnsi(Src,Dest); #endif return 0; } inline double GetTickCountmS() { LARGE_INTEGER perfreq; LARGE_INTEGER percounter1; //,percounter2; double time1; //,time2,timeinter1; QueryPerformanceFrequency(&perfreq); QueryPerformanceCounter(&percounter1); // percounter1.QuadPart=rdtsc(); /* _asm { RDTSC; mov percounter1.LowPart,eax; mov percounter1.HighPart,edx; } */ time1=(double)percounter1.QuadPart/perfreq.QuadPart ; // time2=(double)percounter2.QuadPart/perfreq.QuadPart ; // timeinter1=time2-time1; return (time1*1000); }; /* template int Split(ST s1,ST divider, ST resultstr[]) { int i,j,k,l; // CString s2; k=0; i=0; l=s1.GetLength(); for (i=0;k(CStringA a,CStringA b,CStringA c[]); ///* static inline int Xtoi(const char * hexstr) { int i,j,k; unsigned char ch; k=0;j=0; int len=(int)strlen(hexstr); for (i=0;i='0'&&ch<='9') { k=ch-'0'; j=j*16+k; continue; } if (ch>='A'&&ch<='F') { k=ch-'A'+10; j=j*16+k; continue; } if (ch>='a'&&ch<='f') { k=ch-'a'+10; j=j*16+k; continue; } if (ch==' '||ch==' ') { continue; } break; } return j; } static inline int Xtoi(CString hexstr) { int i,j,k; TCHAR ch; k=0;j=0; int len=hexstr.GetLength(); for (i=0;i=_T('0')&&ch<=_T('9')) { k=ch-_T('0'); j=j*16+k; continue; } if (ch>=_T('A')&&ch<=_T('F')) { k=ch-_T('A')+10; j=j*16+k; continue; } if (ch>=_T('a')&&ch<=_T('f')) { k=ch-_T('a')+10; j=j*16+k; continue; } if (ch==_T(' ')||ch==_T(' ')) { continue; } break; } return j; } inline int Split(CString s1,CString divider,CString resultstr[]) { int i,j,k,l; // CString s2; k=0; i=0; l=s1.GetLength(); for (i=0;k