更新 'util.hpp'

This commit is contained in:
Kirigaya Kazuto 2017-09-12 17:36:27 +08:00
parent e92c917ca5
commit fbae063c66

View File

@ -166,6 +166,44 @@ vector<string> ParseTag(const char* str)
return vec;
}
vector<string> ParseTagX(const char* str)
{
vector<string> vec;
char* s=(char*)str;
char* p=nullptr;
char buff[256];
while( (nullptr!=(p=strstr(s,"/"))) ||
(nullptr!=(p=strstr(s,","))) )
{
memset(buff,0,256);
strncpy(buff,s,p-s);
/// Recheck
for(int i=0;i<(p-s);i++)
{
if(buff[i]==',')
{
buff[i]=0;
break;
}
}
vec.push_back(string(buff));
s=p+1;
}
int len=strlen(str);
if(s<str+len)
{
memset(buff,0,256);
strcpy(buff,s);
vec.push_back(string(buff));
}
return vec;
}
/// 解析int
int ParseInt(const char* str)
{
@ -210,7 +248,7 @@ string Trim(const string& str)
}
if(R==-1)
{
/// All characters are [Space]/
/// All characters are [Space].
return "";
}