//取当前日期
string getCurDate()
{
time_t nowtime;
time(&nowtime);
//取当前时间值
struct tm *tPtr;
tPtr = localtime(&nowtime);
char dateStamp[32];
ACE_OS::sprintf(dateStamp, "%04d%02d%02d", tPtr->tm_year+1900 ,tPtr->tm_mon+1,tPtr->tm_mday);
return dateStamp;
}
//取得当前时间
string getCurTime()
{
time_t nowtime;
time(&nowtime);
struct tm *tPtr;
tPtr = localtime(&nowtime);
char timeStamp[15];
memset(timeStamp, 0x00, 15);
ACE_OS::sprintf(timeStamp, "%02d%02d%02d", tPtr->tm_hour,tPtr->tm_min,tPtr->tm_sec);
return timeStamp;
}
//int型转string 型
string intToString(
int value)
{
char tmpString[15];
memset(tmpString, 0x00, 15);
sprintf(tmpString, "%d", value);
return tmpString;
}
//将字符串处理为小写。
void toLower(
string &strTmp)
{
for (unsigned
int i = 0; i < strTmp.length(); i++)
{
strTmp[i] = tolower(strTmp[i]);
}
return;
}
///根据分隔标记flag将字符串放入。。。。
int getItem(
string &msg ,
char flag, vector<
string> &line)
{
try {
if (line.size() != 0)
{
line.clear();
}
if (msg.length() == 0)
{
return 0;
}
char *tmpMsg = &msg[0];
int begin = 0;
int end = 0;
string tmp;
for (unsigned
int i = 0; i < msg.length(); i ++)
{
if (tmpMsg[i] == flag)
{
end = i;
}
else {
continue;
}
if ((end-begin)> 0)
{
tmp =
string(&tmpMsg[begin], end-begin);
}
else {
tmp = "";
}
begin = end+1;
line.push_back(tmp);
}
if ((msg.length()-begin)> 0)
{
tmp =
string(&tmpMsg[begin], msg.length()-begin);
line.push_back(tmp);
}
}
catch(
)
{
ACE_DEBUG(( _INFO ACE_TEXT(" getItem execpaction:[%s].\n"), msg.c_str()));
return -1;
}
return 0;
}
////输出vector的内容。
void dispVector(
const vector<
string> &vecTmp)
{
if (vecTmp.size() == 0)
{
ACE_DEBUG(( _INFO ACE_TEXT( " vector is null\n" )));
return;
}
for (unsigned
int i = 0 ; i < vecTmp.size(); i++)
{
ACE_DEBUG(( _INFO ACE_TEXT( " [%25s]\n" ), vecTmp[i].c_str()));
}
return ;
}
////返回num后的字符串
string lastStr(
string &from,
int num)
{
if (from.length() <= (unsigned
int)num)
{
return from;
}
else {
return from.substr(from.length()-num, num);
}
}
string leftFullChar(
string &from,
int count,
char flag)
{
if (from.length() > (unsigned
int)count)
{
return from ;
}
int fullCount = (
int)from.length() - count;
string strTmp(fullCount, flag);
strTmp += from;
return strTmp;
}
string rightFullChar(
string &from,
int count,
char flag)
{
if (from.length() > (unsigned
int)count)
{
return from ;
}
int fullCount = (
int)from.length() - count;
string strTmp(fullCount, flag);
return from+strTmp;
}