@ -377,15 +377,15 @@ static bool str_kvs_fnc_isempty(KviKvsModuleFunctionCall * c)
}
/*
@ doc : str . tq contains
@ doc : str . contains
@ type :
function
@ title :
$ str . tq contains
$ str . contains
@ short :
Returns 1 if the first parameter contains the second
@ syntax :
< bool > $ str . tq contains( < container : string > , < to tq find: string > )
< bool > $ str . contains( < container : string > , < to find: string > )
@ description :
Returns 1 if the first string parameter contains the second string parameter .
This function is case sensitive .
@ -394,15 +394,15 @@ static bool str_kvs_fnc_isempty(KviKvsModuleFunctionCall * c)
*/
static bool str_kvs_fnc_ tq contains( KviKvsModuleFunctionCall * c )
static bool str_kvs_fnc_ contains( KviKvsModuleFunctionCall * c )
{
TQString szString , szSubString ;
bool bIs ;
KVSM_PARAMETERS_BEGIN ( c )
KVSM_PARAMETER ( " container " , KVS_PT_STRING , 0 , szString )
KVSM_PARAMETER ( " to tq find" , KVS_PT_STRING , 0 , szSubString )
KVSM_PARAMETER ( " to find" , KVS_PT_STRING , 0 , szSubString )
KVSM_PARAMETERS_END ( c )
bIs = szString . tq find( szSubString ) ! = - 1 ;
bIs = szString . find( szSubString ) ! = - 1 ;
c - > returnValue ( ) - > setBoolean ( bIs ) ;
return true ;
}
@ -416,12 +416,12 @@ static bool str_kvs_fnc_tqcontains(KviKvsModuleFunctionCall * c)
@ short :
Returns 1 if the first parameter contains the second , case insensitive
@ syntax :
< bool > $ str . containsnocase ( < container : string > , < to tq find: string > )
< bool > $ str . containsnocase ( < container : string > , < to find: string > )
@ description :
Returns 1 if the first string parameter contains the second string parameter
whithout taking in consideration the case of the characters in the string .
@ seealso :
[ fnc ] $ str . tq contains[ / fnc ]
[ fnc ] $ str . contains[ / fnc ]
*/
static bool str_kvs_fnc_containsnocase ( KviKvsModuleFunctionCall * c )
@ -430,9 +430,9 @@ static bool str_kvs_fnc_containsnocase(KviKvsModuleFunctionCall * c)
bool bIs ;
KVSM_PARAMETERS_BEGIN ( c )
KVSM_PARAMETER ( " container " , KVS_PT_STRING , 0 , szString )
KVSM_PARAMETER ( " to tq find" , KVS_PT_STRING , 0 , szSubString )
KVSM_PARAMETER ( " to find" , KVS_PT_STRING , 0 , szSubString )
KVSM_PARAMETERS_END ( c )
bIs = szString . tq find( szSubString , 0 , false ) ! = - 1 ;
bIs = szString . find( szSubString , 0 , false ) ! = - 1 ;
c - > returnValue ( ) - > setBoolean ( bIs ) ;
return true ;
}
@ -557,15 +557,15 @@ static bool str_kvs_fnc_cmpnocase(KviKvsModuleFunctionCall * c)
}
/*
@ doc : str . tq find
@ doc : str . find
@ type :
function
@ title :
$ str . tq find
$ str . find
@ short :
Find the index of the nth ocurrence of a substring in a string
@ syntax :
< int > $ str . tq find( < findIn : string > , < to tq find: string > [ , ocurrence : int ] )
< int > $ str . find( < findIn : string > , < to find: string > [ , ocurrence : int ] )
@ description :
This function search in the string given as the first parameter for the string
given as his second parameter , and will return the index where the nth ocurrence
@ -576,13 +576,13 @@ static bool str_kvs_fnc_cmpnocase(KviKvsModuleFunctionCall * c)
FIXME : The semantics of this function are totally broken : (
*/
static bool str_kvs_fnc_ tq find( KviKvsModuleFunctionCall * c )
static bool str_kvs_fnc_ find( KviKvsModuleFunctionCall * c )
{
TQString szFindIn , szToFind ;
kvs_int_t iOcurence ;
KVSM_PARAMETERS_BEGIN ( c )
KVSM_PARAMETER ( " findIn " , KVS_PT_STRING , 0 , szFindIn )
KVSM_PARAMETER ( " to tq find" , KVS_PT_STRING , 0 , szToFind )
KVSM_PARAMETER ( " to find" , KVS_PT_STRING , 0 , szToFind )
KVSM_PARAMETER ( " ocurrence " , KVS_PT_INTEGER , KVS_PF_OPTIONAL , iOcurence )
KVSM_PARAMETERS_END ( c )
int pos = 1 ;
@ -609,7 +609,7 @@ static bool str_kvs_fnc_tqfind(KviKvsModuleFunctionCall * c)
while ( cnt < = pos )
{
idx = szFindIn . right ( szFindIn . length ( ) - totalIdx ) . tq find( szToFind ) ;
idx = szFindIn . right ( szFindIn . length ( ) - totalIdx ) . find( szToFind ) ;
if ( idx = = - 1 )
{
c - > returnValue ( ) - > setInteger ( - 1 ) ;
@ -646,7 +646,7 @@ static bool str_kvs_fnc_findfirst(KviKvsModuleFunctionCall * c)
KVSM_PARAMETER ( " findIn " , KVS_PT_STRING , 0 , szString )
KVSM_PARAMETER ( " toFind " , KVS_PT_STRING , 0 , szString2 )
KVSM_PARAMETERS_END ( c )
c - > returnValue ( ) - > setInteger ( szString . tq find( szString2 ) ) ;
c - > returnValue ( ) - > setInteger ( szString . find( szString2 ) ) ;
return true ;
}
/*
@ -672,7 +672,7 @@ static bool str_kvs_fnc_findfirstnocase(KviKvsModuleFunctionCall * c)
KVSM_PARAMETER ( " findIn " , KVS_PT_STRING , 0 , szString )
KVSM_PARAMETER ( " toFind " , KVS_PT_STRING , 0 , szString2 )
KVSM_PARAMETERS_END ( c )
c - > returnValue ( ) - > setInteger ( szString . tq find( szString2 , 0 , false ) ) ;
c - > returnValue ( ) - > setInteger ( szString . find( szString2 , 0 , false ) ) ;
return true ;
}
/*
@ -698,7 +698,7 @@ static bool str_kvs_fnc_findlast(KviKvsModuleFunctionCall * c)
KVSM_PARAMETER ( " findIn " , KVS_PT_STRING , 0 , szString )
KVSM_PARAMETER ( " toFind " , KVS_PT_STRING , 0 , szString2 )
KVSM_PARAMETERS_END ( c )
c - > returnValue ( ) - > setInteger ( szString . tq findRev( szString2 ) ) ;
c - > returnValue ( ) - > setInteger ( szString . findRev( szString2 ) ) ;
return true ;
}
/*
@ -724,7 +724,7 @@ static bool str_kvs_fnc_findlastnocase(KviKvsModuleFunctionCall * c)
KVSM_PARAMETER ( " findIn " , KVS_PT_STRING , 0 , szString )
KVSM_PARAMETER ( " toFind " , KVS_PT_STRING , 0 , szString2 )
KVSM_PARAMETERS_END ( c )
c - > returnValue ( ) - > setInteger ( szString . tq findRev( szString2 , - 1 , false ) ) ;
c - > returnValue ( ) - > setInteger ( szString . findRev( szString2 , - 1 , false ) ) ;
return true ;
}
/*
@ -994,37 +994,37 @@ static bool str_kvs_fnc_stripcolors(KviKvsModuleFunctionCall * c)
}
/*
@ doc : str . tq replace
@ doc : str . replace
@ type :
function
@ title :
$ str . tq replace
$ str . replace
@ short :
Replace substrings in a string
@ syntax :
< string > $ str . tq replace( < string : string > , < replacewith : string > , < to tq replace: string > )
< string > $ str . replace( < string : string > , < replacewith : string > , < to replace: string > )
@ description :
This function returns a string created replacing all ocurrences of the third parameter
( ' to tq replace' ) in the string given as the first parameter ( ' string ' ) with the string
( ' to replace' ) in the string given as the first parameter ( ' string ' ) with the string
given as the second parameter ( ' replacewith ' ) .
The string replacement is case sensitive ! .
FIXME : The order of the parameters in this function is illogical ( and probably incompatible
with any other scripting language ) : D
@ examples :
[ example ]
echo $ str . tq replace( " I like big networks " , " neural " , " big " )
echo $ str . replace( " I like big networks " , " neural " , " big " )
[ / example ]
*/
static bool str_kvs_fnc_ tq replace( KviKvsModuleFunctionCall * c )
static bool str_kvs_fnc_ replace( KviKvsModuleFunctionCall * c )
{
TQString szString , szNewstr , szTo tq replace;
TQString szString , szNewstr , szTo replace;
KVSM_PARAMETERS_BEGIN ( c )
KVSM_PARAMETER ( " string " , KVS_PT_STRING , 0 , szString )
KVSM_PARAMETER ( " newstr " , KVS_PT_STRING , 0 , szNewstr )
KVSM_PARAMETER ( " to tq replace" , KVS_PT_STRING , 0 , szTo tq replace)
KVSM_PARAMETER ( " to replace" , KVS_PT_STRING , 0 , szTo replace)
KVSM_PARAMETERS_END ( c )
szString . tq replace( szTo tq replace, szNewstr ) ;
szString . replace( szTo replace, szNewstr ) ;
c - > returnValue ( ) - > setString ( szString ) ;
return true ;
}
@ -1038,10 +1038,10 @@ static bool str_kvs_fnc_tqreplace(KviKvsModuleFunctionCall * c)
@ short :
Replace substrings in a string ignoring case
@ syntax :
< string > $ str . replacenocase ( < string : string > , < newstr : string > , < to tq replace: string > )
< string > $ str . replacenocase ( < string : string > , < newstr : string > , < to replace: string > )
@ description :
This function returns a string created replacing all ocurrences of the third parameter
( ' to tq replace' ) in the string given as the first parameter ( ' string ' ) with the string
( ' to replace' ) in the string given as the first parameter ( ' string ' ) with the string
given as the second parameter ( ' newstr ' ) . [ br ]
The replacement is case insensitive . [ br ]
FIXME : The order of the parameters in this function is illogical ( and probably incompatible
@ -1050,13 +1050,13 @@ static bool str_kvs_fnc_tqreplace(KviKvsModuleFunctionCall * c)
static bool str_kvs_fnc_replacenocase ( KviKvsModuleFunctionCall * c )
{
TQString szString , szNewstr , szTo tq replace;
TQString szString , szNewstr , szTo replace;
KVSM_PARAMETERS_BEGIN ( c )
KVSM_PARAMETER ( " string " , KVS_PT_STRING , 0 , szString )
KVSM_PARAMETER ( " newstr " , KVS_PT_STRING , 0 , szNewstr )
KVSM_PARAMETER ( " to tq replace" , KVS_PT_STRING , 0 , szTo tq replace)
KVSM_PARAMETER ( " to replace" , KVS_PT_STRING , 0 , szTo replace)
KVSM_PARAMETERS_END ( c )
szString . tq replace( szTo tq replace, szNewstr , false ) ;
szString . replace( szTo replace, szNewstr , false ) ;
c - > returnValue ( ) - > setString ( szString ) ;
return true ;
}
@ -1090,12 +1090,12 @@ static bool str_kvs_fnc_urlencode(KviKvsModuleFunctionCall * c)
/*
for ( int idx = 0 , idx < 22 , idx + + )
szNewstr = szString . tq replace( toReplace [ idx ] , newStr [ idx ] , false ) ;
szNewstr = szString . replace( toReplace [ idx ] , newStr [ idx ] , false ) ;
*/
int idx = 0 ;
while ( idx < 20 ) {
szNewstr = szString . tq replace( toReplace [ idx ] , newStr [ idx ] , false ) ;
szNewstr = szString . replace( toReplace [ idx ] , newStr [ idx ] , false ) ;
idx + + ;
}
@ -1129,7 +1129,7 @@ static bool str_kvs_fnc_lefttofirst(KviKvsModuleFunctionCall * c)
KVSM_PARAMETER ( " string " , KVS_PT_STRING , 0 , szString )
KVSM_PARAMETER ( " substring " , KVS_PT_STRING , 0 , szNewstr )
KVSM_PARAMETERS_END ( c )
where = szString . tq find( szNewstr , false ) ;
where = szString . find( szNewstr , false ) ;
if ( where ! = - 1 ) c - > returnValue ( ) - > setString ( szString . left ( where ) ) ;
else c - > returnValue ( ) - > setString ( szString ) ;
return true ;
@ -1159,7 +1159,7 @@ static bool str_kvs_fnc_lefttolast(KviKvsModuleFunctionCall * c)
KVSM_PARAMETER ( " string " , KVS_PT_STRING , 0 , szString )
KVSM_PARAMETER ( " substring " , KVS_PT_STRING , 0 , szNewstr )
KVSM_PARAMETERS_END ( c )
int where = szString . tq findRev( szNewstr , - 1 , false ) ;
int where = szString . findRev( szNewstr , - 1 , false ) ;
if ( where ! = - 1 ) c - > returnValue ( ) - > setString ( szString . left ( where ) ) ;
else c - > returnValue ( ) - > setString ( szString ) ;
return true ;
@ -1189,7 +1189,7 @@ static bool str_kvs_fnc_rightfromfirst(KviKvsModuleFunctionCall * c)
KVSM_PARAMETER ( " string " , KVS_PT_STRING , 0 , szString )
KVSM_PARAMETER ( " substring " , KVS_PT_STRING , 0 , szNewstr )
KVSM_PARAMETERS_END ( c )
int idx = szString . tq find( szNewstr , false ) ;
int idx = szString . find( szNewstr , false ) ;
if ( idx ! = - 1 ) c - > returnValue ( ) - > setString ( szString . right ( szString . length ( ) - ( idx + szNewstr . length ( ) ) ) ) ;
else c - > returnValue ( ) - > setString ( " " ) ;
return true ;
@ -1220,7 +1220,7 @@ static bool str_kvs_fnc_rightfromlast(KviKvsModuleFunctionCall * c)
KVSM_PARAMETER ( " string " , KVS_PT_STRING , 0 , szString )
KVSM_PARAMETER ( " substring " , KVS_PT_STRING , 0 , szNewstr )
KVSM_PARAMETERS_END ( c )
int idx = szString . tq findRev( szNewstr , - 1 , false ) ;
int idx = szString . findRev( szNewstr , - 1 , false ) ;
if ( idx ! = - 1 ) c - > returnValue ( ) - > setString ( szString . right ( szString . length ( ) - ( idx + szNewstr . length ( ) ) ) ) ;
else c - > returnValue ( ) - > setString ( " " ) ;
return true ;
@ -1265,8 +1265,8 @@ static bool str_kvs_fnc_match(KviKvsModuleFunctionCall * c)
KVSM_PARAMETER ( " string " , KVS_PT_STRING , 0 , szString )
KVSM_PARAMETER ( " flags " , KVS_PT_STRING , KVS_PF_OPTIONAL , szFlags )
KVSM_PARAMETERS_END ( c )
bool bRegExp = ( szFlags . tq find( TQChar ( ' r ' ) ) ! = - 1 ) | | ( szFlags . tq find( TQChar ( ' R ' ) ) ! = - 1 ) ;
bool bExact = ( szFlags . tq find( TQChar ( ' e ' ) ) ! = - 1 ) | | ( szFlags . tq find( TQChar ( ' E ' ) ) ! = - 1 ) ;
bool bRegExp = ( szFlags . find( TQChar ( ' r ' ) ) ! = - 1 ) | | ( szFlags . find( TQChar ( ' R ' ) ) ! = - 1 ) ;
bool bExact = ( szFlags . find( TQChar ( ' e ' ) ) ! = - 1 ) | | ( szFlags . find( TQChar ( ' E ' ) ) ! = - 1 ) ;
c - > returnValue ( ) - > setBoolean ( KviTQString : : matchStringCS ( szWildcard , szString , bRegExp , bExact ) ) ;
return true ;
}
@ -1311,8 +1311,8 @@ static bool str_kvs_fnc_matchnocase(KviKvsModuleFunctionCall * c)
KVSM_PARAMETER ( " string " , KVS_PT_STRING , 0 , szString )
KVSM_PARAMETER ( " flags " , KVS_PT_STRING , KVS_PF_OPTIONAL , szFlags )
KVSM_PARAMETERS_END ( c )
bool bRegExp = ( szFlags . tq find( TQChar ( ' r ' ) ) ! = - 1 ) | | ( szFlags . tq find( TQChar ( ' R ' ) ) ! = - 1 ) ;
bool bExact = ( szFlags . tq find( TQChar ( ' e ' ) ) ! = - 1 ) | | ( szFlags . tq find( TQChar ( ' E ' ) ) ! = - 1 ) ;
bool bRegExp = ( szFlags . find( TQChar ( ' r ' ) ) ! = - 1 ) | | ( szFlags . find( TQChar ( ' R ' ) ) ! = - 1 ) ;
bool bExact = ( szFlags . find( TQChar ( ' e ' ) ) ! = - 1 ) | | ( szFlags . find( TQChar ( ' E ' ) ) ! = - 1 ) ;
c - > returnValue ( ) - > setBoolean ( KviTQString : : matchStringCI ( szWildcard , szString , bRegExp , bExact ) ) ;
return true ;
}
@ -1435,13 +1435,13 @@ static bool str_kvs_fnc_token(KviKvsModuleFunctionCall * c)
{
TQChar szTmp = szString [ idx ] . tqunicode ( ) ;
// while (szTmp==sep)
while ( sep . tq contains( szTmp ) )
while ( sep . contains( szTmp ) )
{
idx + + ;
szTmp = szString [ idx ] . tqunicode ( ) ;
}
begin = idx ;
while ( idx < len & & ! sep . tq contains( szTmp ) )
while ( idx < len & & ! sep . contains( szTmp ) )
{
idx + + ;
szTmp = szString [ idx ] . tqunicode ( ) ;
@ -1600,7 +1600,7 @@ static bool str_kvs_fnc_join(KviKvsModuleFunctionCall * c)
KVSM_PARAMETERS_END ( c )
TQString szRet ;
bool bSkipEmpty = szFlags . tq find( ' n ' , 0 , false ) ! = - 1 ;
bool bSkipEmpty = szFlags . find( ' n ' , 0 , false ) ! = - 1 ;
bool bFirst = true ;
@ -1693,9 +1693,9 @@ static bool str_kvs_fnc_grep(KviKvsModuleFunctionCall * c)
KviKvsArray * a = ac . array ( ) ;
bool bCaseSensitive = szFlags . tq find( ' s ' , 0 , false ) ! = - 1 ;
bool bRegexp = szFlags . tq find( ' r ' , 0 , false ) ! = - 1 ;
bool bWild = szFlags . tq find( ' w ' , 0 , false ) ! = - 1 ;
bool bCaseSensitive = szFlags . find( ' s ' , 0 , false ) ! = - 1 ;
bool bRegexp = szFlags . find( ' r ' , 0 , false ) ! = - 1 ;
bool bWild = szFlags . find( ' w ' , 0 , false ) ! = - 1 ;
int idx = 0 ;
int cnt = a - > size ( ) ;
@ -1726,7 +1726,7 @@ static bool str_kvs_fnc_grep(KviKvsModuleFunctionCall * c)
{
TQString sz ;
v - > asString ( sz ) ;
if ( sz . tq find( szMatch , 0 , bCaseSensitive ) ! = - 1 )
if ( sz . find( szMatch , 0 , bCaseSensitive ) ! = - 1 )
{
n - > set ( i , new KviKvsVariant ( sz ) ) ;
i + + ;
@ -1812,10 +1812,10 @@ static bool str_kvs_fnc_split(KviKvsModuleFunctionCall * c)
if ( iMaxItems = = 0 ) return true ;
bool bWild = szFla . tq find( ' w ' , 0 , false ) ! = - 1 ;
bool bContainsR = szFla . tq find( ' r ' , 0 , false ) ! = - 1 ;
bool bCaseSensitive = szFla . tq find( ' s ' , 0 , false ) ! = - 1 ;
bool bNoEmpty = szFla . tq find( ' n ' , 0 , false ) ! = - 1 ;
bool bWild = szFla . find( ' w ' , 0 , false ) ! = - 1 ;
bool bContainsR = szFla . find( ' r ' , 0 , false ) ! = - 1 ;
bool bCaseSensitive = szFla . find( ' s ' , 0 , false ) ! = - 1 ;
bool bNoEmpty = szFla . find( ' n ' , 0 , false ) ! = - 1 ;
int id = 0 ;
@ -1855,7 +1855,7 @@ static bool str_kvs_fnc_split(KviKvsModuleFunctionCall * c)
} else {
while ( ( iMatch ! = - 1 ) & & ( iMatch < iStrLen ) & & ( ( id < ( iMaxItems - 1 ) ) | | ( iMaxItems < 0 ) ) )
{
iMatch = szStr . tq find( szSep , iBegin , bCaseSensitive ) ;
iMatch = szStr . find( szSep , iBegin , bCaseSensitive ) ;
if ( iMatch ! = - 1 )
{
TQString tmp = szStr . mid ( iBegin , iMatch - iBegin ) ;
@ -2270,13 +2270,13 @@ static bool str_module_init(KviModule * m)
KVSM_REGISTER_FUNCTION ( m , " localelowcase " , str_kvs_fnc_localelowcase ) ;
KVSM_REGISTER_FUNCTION ( m , " isnumber " , str_kvs_fnc_isnumber ) ;
KVSM_REGISTER_FUNCTION ( m , " isunsignednumber " , str_kvs_fnc_isunsignednumber ) ;
KVSM_REGISTER_FUNCTION ( m , " tq contains" , str_kvs_fnc_ tq contains) ;
KVSM_REGISTER_FUNCTION ( m , " contains" , str_kvs_fnc_ contains) ;
KVSM_REGISTER_FUNCTION ( m , " containsnocase " , str_kvs_fnc_containsnocase ) ;
KVSM_REGISTER_FUNCTION ( m , " equal " , str_kvs_fnc_equal ) ;
KVSM_REGISTER_FUNCTION ( m , " equalnocase " , str_kvs_fnc_equalnocase ) ;
KVSM_REGISTER_FUNCTION ( m , " cmp " , str_kvs_fnc_cmp ) ;
KVSM_REGISTER_FUNCTION ( m , " cmpnocase " , str_kvs_fnc_cmpnocase ) ;
KVSM_REGISTER_FUNCTION ( m , " tq find" , str_kvs_fnc_ tq find) ;
KVSM_REGISTER_FUNCTION ( m , " find" , str_kvs_fnc_ find) ;
KVSM_REGISTER_FUNCTION ( m , " findfirst " , str_kvs_fnc_findfirst ) ;
KVSM_REGISTER_FUNCTION ( m , " findfirstnocase " , str_kvs_fnc_findfirstnocase ) ;
KVSM_REGISTER_FUNCTION ( m , " findlast " , str_kvs_fnc_findlast ) ;
@ -2291,7 +2291,7 @@ static bool str_module_init(KviModule * m)
KVSM_REGISTER_FUNCTION ( m , " stripright " , str_kvs_fnc_stripright ) ;
KVSM_REGISTER_FUNCTION ( m , " stripleft " , str_kvs_fnc_stripleft ) ;
KVSM_REGISTER_FUNCTION ( m , " stripcolors " , str_kvs_fnc_stripcolors ) ;
KVSM_REGISTER_FUNCTION ( m , " tq replace" , str_kvs_fnc_ tq replace) ;
KVSM_REGISTER_FUNCTION ( m , " replace" , str_kvs_fnc_ replace) ;
KVSM_REGISTER_FUNCTION ( m , " replacenocase " , str_kvs_fnc_replacenocase ) ;
KVSM_REGISTER_FUNCTION ( m , " urlencode " , str_kvs_fnc_urlencode ) ;
KVSM_REGISTER_FUNCTION ( m , " lefttolast " , str_kvs_fnc_lefttolast ) ;