cptr_indexOf
This commit is contained in:
parent
b09f6b802c
commit
856a0e3e3e
@ -48,6 +48,19 @@ bool cptr_endsWith(char* ptr, char* fragment){
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32 cptr_indexOf(char* ptr, char* fragment){
|
||||||
|
char sc=*ptr;
|
||||||
|
for(int si=0, fi=0; sc!=0; si++){
|
||||||
|
sc=ptr[si];
|
||||||
|
if(sc==fragment[fi]){
|
||||||
|
fi++;
|
||||||
|
if(fragment[fi]==0)
|
||||||
|
return si-fi+1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
void memcopy(void* from, void* to, uint32 size){
|
void memcopy(void* from, void* to, uint32 size){
|
||||||
if(from==NULL || to==NULL)
|
if(from==NULL || to==NULL)
|
||||||
throw(ERR_NULLPTR);
|
throw(ERR_NULLPTR);
|
||||||
|
|||||||
@ -22,6 +22,17 @@ bool cptr_startsWith(char* ptr, char* fragment);
|
|||||||
|
|
||||||
bool cptr_endsWith(char* ptr, char* fragment);
|
bool cptr_endsWith(char* ptr, char* fragment);
|
||||||
|
|
||||||
|
/// @brief search for <fragment> in <ptr>
|
||||||
|
/// @return index of first <fragment> inclusion or -1 if not found
|
||||||
|
uint32 cptr_indexOf(char* ptr, char* fragment);
|
||||||
|
|
||||||
|
static inline bool cptr_contains(char* ptr, char* fragment){
|
||||||
|
// if(cptr_indexOf(ptr, fragment)==-1)
|
||||||
|
// return false;
|
||||||
|
// return true;
|
||||||
|
return cptr_indexOf(ptr, fragment) +1;
|
||||||
|
}
|
||||||
|
|
||||||
void memcopy(void* from, void* to, uint32 size);
|
void memcopy(void* from, void* to, uint32 size);
|
||||||
|
|
||||||
char* __cptr_concat(uint16 n, ...);
|
char* __cptr_concat(uint16 n, ...);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user