-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(libccc/stringarray): implemented StringArray_Find|IndexOf() f…
…amily of functions
- Loading branch information
LexouDuck
committed
Jan 26, 2022
1 parent
e37b1ed
commit cd96b37
Showing
5 changed files
with
136 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
libccc@0.9.53-2022-01-26_9db813490cf69cc29db86711776b5aa32c25c20c | ||
libccc@0.9.54-2022-01-26_e37b1edb88e4309274413975f581420ec7d756f7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
|
||
#include "libccc/stringarray.h" | ||
|
||
#include LIBCONFIG_ERROR_INCLUDE | ||
|
||
|
||
|
||
t_char* const* StringArray_Find(t_char* const* strarr, t_char const* str) | ||
{ | ||
t_uint length; | ||
|
||
HANDLE_ERROR(NULLPOINTER, (strarr == NULL), return (NULL);) | ||
length = StringArray_Length((t_char const* const*)strarr); | ||
for (t_uint i = 0; i < length; ++i) | ||
{ | ||
if (String_Equals(strarr[i], str)) | ||
return (&(strarr[i])); | ||
} | ||
HANDLE_ERROR(NOTFOUND, (TRUE), return (NULL);) | ||
} | ||
|
||
|
||
t_char* const* StringArray_Find_F(t_char* const* strarr, t_bool (*match)(t_char const* str)) | ||
{ | ||
t_uint length; | ||
|
||
HANDLE_ERROR(NULLPOINTER, (strarr == NULL), return (NULL);) | ||
length = StringArray_Length((t_char const* const*)strarr); | ||
for (t_uint i = 0; i < length; ++i) | ||
{ | ||
if (match(strarr[i])) | ||
return (&(strarr[i])); | ||
} | ||
HANDLE_ERROR(NOTFOUND, (TRUE), return (NULL);) | ||
} | ||
|
||
|
||
t_sint StringArray_IndexOf(t_char const* const* strarr, t_char const* str) | ||
{ | ||
t_uint length; | ||
|
||
HANDLE_ERROR(NULLPOINTER, (strarr == NULL), return (ERROR);) | ||
length = StringArray_Length(strarr); | ||
for (t_uint i = 0; i < length; ++i) | ||
{ | ||
if (String_Equals(strarr[i], str)) | ||
return (i); | ||
} | ||
HANDLE_ERROR(NOTFOUND, (TRUE), return (ERROR);) | ||
} | ||
|
||
|
||
t_sint StringArray_IndexOf_F(t_char const* const* strarr, t_bool (*match)(t_char const* str)) | ||
{ | ||
t_uint length; | ||
|
||
HANDLE_ERROR(NULLPOINTER, (strarr == NULL), return (ERROR);) | ||
length = StringArray_Length(strarr); | ||
for (t_uint i = 0; i < length; ++i) | ||
{ | ||
if (match(strarr[i])) | ||
return (i); | ||
} | ||
HANDLE_ERROR(NOTFOUND, (TRUE), return (ERROR);) | ||
} |