P
payer
Unregistered / Unconfirmed
GUEST, unregistred user!
星号为通配符,这个是VC的程序,怎样转为 DELPHI?
inline BOOL CMainFrame::UrlFilterStar(CStringArray &pattern, CString url)
{
CString str, tmp, tmp2;
try{
int i = 0, i2=0, start = 0, start2 = 0;//start - str, start2 - tmp
BOOL cmode = TRUE
//compare mode;
BOOL isame = FALSE;
BOOL final = FALSE;
int p = 0;
while(p<=pattern.GetUpperBound() && !isame)
{
str = pattern.GetAt(p);
//star filter
i = 0
i2 = 0
start = 0
start2 = 0;
isame = TRUE;cmode = TRUE;final = FALSE;
while(start<str.GetLength() && isame)
{
//get the string before *
i=str.Find('*', start);
if(i<0)
{
tmp2 = str.Mid(start);
i=str.GetLength();
final = TRUE;
}
else
tmp2 = str.Mid(start,i-start);
if(tmp2!=""
{
if(cmode)
{
tmp = url.Mid(start2, i-start);
if(tmp != tmp2)
isame = FALSE;
}
else if(final)
{
tmp = url.Right(tmp2.GetLength());
if(tmp != tmp2)
isame = FALSE;
}
else
{
i2=url.Find(tmp2, start2);
if( i2<0)
isame = FALSE;
}
}
cmode = FALSE;
start = i+1;
start2 = i2 + tmp2.GetLength();
}
p++;
}
return isame;
}
catch(...)
{
return FALSE;
}
}
inline BOOL CMainFrame::UrlFilterStar(CStringArray &pattern, CString url)
{
CString str, tmp, tmp2;
try{
int i = 0, i2=0, start = 0, start2 = 0;//start - str, start2 - tmp
BOOL cmode = TRUE
//compare mode;
BOOL isame = FALSE;
BOOL final = FALSE;
int p = 0;
while(p<=pattern.GetUpperBound() && !isame)
{
str = pattern.GetAt(p);
//star filter
i = 0
i2 = 0
start = 0
start2 = 0;
isame = TRUE;cmode = TRUE;final = FALSE;
while(start<str.GetLength() && isame)
{
//get the string before *
i=str.Find('*', start);
if(i<0)
{
tmp2 = str.Mid(start);
i=str.GetLength();
final = TRUE;
}
else
tmp2 = str.Mid(start,i-start);
if(tmp2!=""
{
if(cmode)
{
tmp = url.Mid(start2, i-start);
if(tmp != tmp2)
isame = FALSE;
}
else if(final)
{
tmp = url.Right(tmp2.GetLength());
if(tmp != tmp2)
isame = FALSE;
}
else
{
i2=url.Find(tmp2, start2);
if( i2<0)
isame = FALSE;
}
}
cmode = FALSE;
start = i+1;
start2 = i2 + tmp2.GetLength();
}
p++;
}
return isame;
}
catch(...)
{
return FALSE;
}
}