|
|
|
|
#pragma once
|
|
|
|
|
#include "GlobalDefine.h"
|
|
|
|
|
|
|
|
|
|
#define TRUE_STR _T("TRUE")
|
|
|
|
|
#define FALSE_STR _T("FALSE")
|
|
|
|
|
//<2F><>MFC CString <20><><EFBFBD>ص<EFBFBD>һЩ<D2BB><D0A9><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
//ȥ<><C8A5>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>治Ҫ<E6B2BB><D2AA>0
|
|
|
|
|
inline void DeleteZero(CString &s)
|
|
|
|
|
{
|
|
|
|
|
int nIndex;
|
|
|
|
|
nIndex=s.Find('.');
|
|
|
|
|
if (nIndex>=0)
|
|
|
|
|
{
|
|
|
|
|
s.TrimRight('0');
|
|
|
|
|
if (s.GetLength()==nIndex+1)
|
|
|
|
|
{
|
|
|
|
|
s=s.Left(nIndex);
|
|
|
|
|
if (s.IsEmpty())
|
|
|
|
|
s='0';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//double ת<><D7AA>ΪCString
|
|
|
|
|
inline CString Db2CString(double n)
|
|
|
|
|
{
|
|
|
|
|
CString s;
|
|
|
|
|
s.Format("%lf",n);
|
|
|
|
|
DeleteZero(s);
|
|
|
|
|
return s;
|
|
|
|
|
}
|
|
|
|
|
//int ת<><D7AA>ΪCString
|
|
|
|
|
inline CString Int2CString(int n)
|
|
|
|
|
{
|
|
|
|
|
CString s;
|
|
|
|
|
s.Format("%ld",n);
|
|
|
|
|
return s;
|
|
|
|
|
}
|
|
|
|
|
//<2F><>ȡbool <20><><EFBFBD>͵<EFBFBD>str
|
|
|
|
|
inline CString GetBoolValStr(bool b)
|
|
|
|
|
{
|
|
|
|
|
if(b)
|
|
|
|
|
return TRUE_STR;
|
|
|
|
|
else
|
|
|
|
|
return FALSE_STR;
|
|
|
|
|
}
|
|
|
|
|
//<2F><>str <20>в<EFBFBD><D0B2><EFBFBD>SubStr ,<2C>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD>true
|
|
|
|
|
inline bool FindSubStr(CString &str,CString &SubStr)
|
|
|
|
|
{
|
|
|
|
|
return (str.Find(SubStr) != -1);
|
|
|
|
|
}
|
|
|
|
|
//ɾ<><C9BE><EFBFBD>Ӵ<EFBFBD><D3B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʣ<EFBFBD><CAA3><EFBFBD>ұߵIJ<DFB5><C4B2><EFBFBD>
|
|
|
|
|
inline CString DelSubStr(CString str,CString &SubStr)
|
|
|
|
|
{
|
|
|
|
|
int pos = str.Find(SubStr);
|
|
|
|
|
if(pos != -1)
|
|
|
|
|
{
|
|
|
|
|
str = str.Right(str.GetLength()-(pos+SubStr.GetLength()));
|
|
|
|
|
}
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
inline int CStringToInt(CString &str)
|
|
|
|
|
{
|
|
|
|
|
return _tstoi(LPCTSTR(str));
|
|
|
|
|
}
|
|
|
|
|
inline double CStringToDouble(CString &str)
|
|
|
|
|
{
|
|
|
|
|
return _tstof(LPCTSTR(str));
|
|
|
|
|
}
|
|
|
|
|
inline bool CStringToBool(CString &str)
|
|
|
|
|
{
|
|
|
|
|
if(str == TRUE_STR)
|
|
|
|
|
return true;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
inline CString Bool2Str(bool b)
|
|
|
|
|
{
|
|
|
|
|
if(b)
|
|
|
|
|
return "TRUE";
|
|
|
|
|
else
|
|
|
|
|
return "FALSE";
|
|
|
|
|
}
|
|
|
|
|
inline bool Str2Bool(CString &str)
|
|
|
|
|
{
|
|
|
|
|
if(str == _T("TRUE"))
|
|
|
|
|
return true;
|
|
|
|
|
else
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
inline CString Time2Str(int n)
|
|
|
|
|
{
|
|
|
|
|
CString s;
|
|
|
|
|
if(n<10)
|
|
|
|
|
s.Format("0%ld",n);//<2F><><EFBFBD>߲<EFBFBD>0
|
|
|
|
|
else
|
|
|
|
|
s.Format("%ld",n);
|
|
|
|
|
return s;
|
|
|
|
|
}
|