C++中一些常见的方法
程序员文章站
2022-03-02 14:37:25
...
1.对规则的字符串进行处理的bool splitString(string strOrigin, string strSplit, vector<string>& vct_string)
{
string str;
int iIndex,iLen;
strOrigin += strSplit;
vct_string.clear();
while(1)
{
iIndex = (int)strOrigin.find(strSplit);
if ( 0 > iIndex || iIndex > strOrigin.length())
{
break;
}
str = strOrigin.substr(0,iIndex);
vct_string.push_back(str);
iLen = (int)strOrigin.length();
strOrigin = strOrigin.substr(iIndex+1,iLen-iIndex-1);
}
return true;
}
string CTools::GetDatetime(void) { time_t t; struct tm *tm; char cBuf[20]; memset(cBuf, 0,sizeof(cBuf)); t = time(NULL); tm = localtime(&t); sprintf(cBuf, "%d%02d%02d%02d%02d%02d", tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); string strDateTime = cBuf; return strDateTime; }
string CTools::GetDatetime(void) { time_t t; struct tm *tm; char cBuf[20]; memset(cBuf, 0,sizeof(cBuf)); t = time(NULL); tm = localtime(&t); sprintf(cBuf, "%d%02d%02d%02d%02d%02d", tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); string strDateTime = cBuf; return strDateTime; }
string CTools::GetSquence()
{
ACE_Date_Time now;
char time[11];
memset(time,0x00,11);
sprintf(time,"00A%02d%02d%03d", (int)now.minute(),(int)now.second(),(int)now.microsec());
string stRtime = time;
stRtime = stRtime.substr(0,10);
return stRtime;
}
上一篇: HTML笔记 ( 二 ) 一些常见的标签
下一篇: spring2.5集成jpa