more convenience
This commit is contained in:
@ -782,6 +782,47 @@ namespace ams
|
||||
int ret = -1;
|
||||
//todo
|
||||
|
||||
bool b1,b2,beq;
|
||||
int mode;
|
||||
int findstrlen = amsstring_strlen(findstr);
|
||||
int I,J;
|
||||
ams_chartype c1,c2,cc;
|
||||
|
||||
J = findstrlen-1;
|
||||
mode = 0;
|
||||
cc = 0;
|
||||
for(I=length-indstart-1;I>=0;I--)
|
||||
{
|
||||
c1 = cstring[I];
|
||||
c2 = findstr[J];
|
||||
b1 = casesens&&(c1==c2);
|
||||
b2 = (!casesens)&&(ams::tolower(c1)==ams::tolower(c2));
|
||||
beq = b1 || b2;
|
||||
|
||||
if(beq && mode==0)
|
||||
{
|
||||
mode = 1;
|
||||
}
|
||||
|
||||
if(beq && mode==1)
|
||||
{
|
||||
cc+=1;
|
||||
J--;
|
||||
if(cc==findstrlen || J<0)
|
||||
{
|
||||
ret = I;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!beq && mode==1)
|
||||
{
|
||||
mode = 0;
|
||||
cc = 0;
|
||||
J = findstrlen-1;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@ -352,8 +352,21 @@ amsstring stripallwhitespace(const amsstring &s)
|
||||
amsarray<amsstring> splitext(const amsstring &s)
|
||||
{
|
||||
amsarray<amsstring> ret;
|
||||
ret.resize(2);
|
||||
|
||||
//todo
|
||||
int ind;
|
||||
|
||||
ind = s.findright('.');
|
||||
if(ind<0)
|
||||
{
|
||||
ret[0] = s;
|
||||
ret[1] = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
ret[0] = s.substring(0,ind);
|
||||
ret[1] = s.substring(ind,s.length);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -363,8 +376,34 @@ amsarray<amsstring> splitext(const amsstring &s)
|
||||
amsarray<amsstring> splitpath(const amsstring &s)
|
||||
{
|
||||
amsarray<amsstring> ret;
|
||||
ret.resize(2);
|
||||
int ind1,ind2;
|
||||
|
||||
//todo
|
||||
ind1 = s.find('/');
|
||||
ind2 = s.find('\\');
|
||||
if(ind1>=0)
|
||||
{
|
||||
if(ind1==0)
|
||||
{
|
||||
ret[0] = "/";
|
||||
}
|
||||
else
|
||||
{
|
||||
ret[0] = s.substring(0,ind1);
|
||||
}
|
||||
ret[1] = s.substring(ind1+1,s.length);
|
||||
}
|
||||
else if(ind2>=0)
|
||||
{
|
||||
ret[0] = s.substring(0,ind2);
|
||||
ret[1] = s.substring(ind2+1,s.length);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret[0] = "";
|
||||
ret[1] = s;
|
||||
}
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -374,7 +413,15 @@ amsstring select_between(const amsstring &s, const ams_chartype delimitleft, con
|
||||
{
|
||||
amsstring ret;
|
||||
|
||||
//todo
|
||||
int ind1,ind2;
|
||||
|
||||
ind1 = s.find(delimitleft);
|
||||
ind2 = s.find(delimitright);
|
||||
|
||||
if(ind1<0) ind1=0;
|
||||
if(ind2<0) ind2=s.length;
|
||||
|
||||
ret = s.substring(ind1,ind2);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user