docs: Clarify strlist_split

This commit is contained in:
CodeYan01
2023-08-27 09:55:36 +10:00
committed by Matt Gajownik
parent 028b3c12cf
commit abb2da99a8
+25 -2
View File
@@ -87,8 +87,31 @@ General String Helper Functions
.. function:: char **strlist_split(const char *str, char split_ch, bool include_empty)
Splits a string in to a list of multiple sub-strings. Free with
:c:func:`strlist_free()`.
Splits a string in to a list of multiple sub-strings, terminated by
``NULL``. If ``split_ch`` does not exist in the string, the first
sub-string will be the same as ``str``. Free with :c:func:`strlist_free()`.
:param str: The string to be split
:param split_ch: The delimiter
:param include_empty: If *true*, empty strings caused by having the
``split_ch`` right next to another will be
included in the list. If *false*, they won't
be included.
Sample usage:
.. code:: cpp
char **words = strlist_split("OBS Studio", ' ', false);
int count = 0;
for (char **word = words; *word; ++word) {
count++;
blog(LOG_DEBUG, "%s", *word);
}
strlist_free(words);
// count == 2
----------------------