Browse Source

docs: Clarify strlist_split

CodeYan01 2 years ago
parent
commit
abb2da99a8
1 changed files with 25 additions and 2 deletions
  1. 25 2
      docs/sphinx/reference-libobs-util-dstr.rst

+ 25 - 2
docs/sphinx/reference-libobs-util-dstr.rst

@@ -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
 
 ----------------------