std::vector<bstr_t>  IObject::GetVectorString(bstr_t commastrs, std::string delim)
{
	std::vector<bstr_t> bstrs;
	std::string tmp(commastrs);
	RightTrim(tmp,delim);
	std::vector<std::string> strs = Tokenize(tmp, delim);
	for(int i=0; i< strs.size(); i++)
		bstrs.push_back(strs[i].c_str());

	return bstrs;
}
std::string IObject::GetPropertyValue(std::string name)
{
	for(int i=0; i< properties.size(); i++)
	{
		std::vector<std::string> tokens = Tokenize(RightTrim(std::string((LPCSTR) properties[i]),";"),",");
		if(tokens.size() < 2)
			continue;
		if(tokens[0]==name)
			return tokens[1];
	}
	return "";
}
Exemple #3
0
int UnZip32OutputLineToIndividualInfo(char *line,INDIVIDUALINFO *info)
{
	/*
	result of zip -v 
0         1         2         3         4         5         6
0123456789012345678901234567890123456789012345678901234567890123456789
 Length  Method   Size  Ratio   Date    Time   CRC-32     Name
 ------  ------   ----  -----   ----    ----   ------     ----
  13092  Deflate   5384  59%  95-08-25  14:48  e5081f1b   aiueo
 ------          ------  ---                              -------
  13092            5384  58%                              1      

	result of zip -l
0         1         2         3         4         5         6         7         8
012345678901234567890123456789012345678901234567890123456789012345678901234567890123
  Name          Original    Packed  Ratio   Date     Time   Attr Method   CRC-32
--------------  --------  -------- ------ -------- -------- ---- -------- --------
aiueo              13092      5384  59.4% 95-08-25  14:48:34 a--w Deflate e5081f1b
	
	*/
	char method[100];
	char attr[100];
	int ratio1,ratio2;
	int year,month,date,hour,min,sec;
	int ret;
	char *line2;

	if(strlen(line)<82){return -1;}

	line2=line+strlen(line)-(82-14);	//ファイル名を除いた部分
	*line2='\0';line2+=2;
	
	strcpy(info->szFileName,line);
	RightTrim(info->szFileName);	//右の空白削除
	/* -l オプションの結果を解析 */
	ret=sscanf(line2,"%d %d %d.%d%% %d-%d-%d %d:%d:%d %s %s %x"
		,&(info->dwOriginalSize)
		,&(info->dwCompressedSize)
		,&ratio1,&ratio2
		,&year,&month,&date
		,&hour,&min,&sec
		,attr
		,method
		,&(info->dwCRC));
	if(ret!=13){
		return -1;
	}
	info->uFlag=0;
	info->uOSType=(UINT)-1;
	info->wRatio=ratio1*10+ratio2;
	if(year<80){year=year+100;}
	info->wDate=(year-80 << 4+5) | (month <<5) | (date);
	info->wTime=(hour <<5+6) | (min <<5) | (sec / 2);
	strncpy(info->szAttribute,attr,8);
	strcpy(info->szMode,"-zip-");
	
	/* -v オプションの結果を解析
	ret=sscanf(line,"%d %s %d %d%% %d-%d-%d %d:%d %x"
		,&(info->dwOriginalSize)
		,&method
		,&(info->dwCompressedSize)
		,&ratio
		,&year,&month,&date
		,&hour,&second
		,&(info->dwCRC)
	);
	if(ret!=10){
		return -1;
	}
	info->wRatio=ratio*10;
	info->wDate=(year << 4+5) & (month <<5) & (date);
	info->wTime=(hour <<5+6) & (second <<6);
	strcpy(info->szFileName,line+58);
	*/
	return 0;
}
Exemple #4
0
 void StrOp::Trim(std::string& text) {
     RightTrim(text);
     LeftTrim(text);
 }
Exemple #5
0
 /**
  * Trim both sides.
  * 
  * @param s
  * @return 
  */
 static inline std::string& Trim(std::string &s) {
     return LeftTrim(RightTrim(s));
 }
 std::string &Trim(std::string &s) {
     return LeftTrim(RightTrim(s));
 }
wstring StringUtilities::Trim(wstring str)
{
    return LeftTrim(RightTrim(str));
}