[Lldb-commits] [lldb] Add new Python API `SBCommandInterpreter::GetTranscript()` (PR #90703)

Greg Clayton via lldb-commits lldb-commits at lists.llvm.org
Tue May 7 23:03:28 PDT 2024


================
@@ -290,6 +290,31 @@ class StructuredData {
 
     void GetDescription(lldb_private::Stream &s) const override;
 
+    /// Creates an Array of substrings by splitting a string around the
+    /// occurrences of a separator character.
+    ///
+    /// \param[in] s
+    ///   The input string.
+    ///
+    /// \param[in] separator
+    ///   The character to split on.
+    ///
+    /// \param[in] maxSplit
+    ///   The maximum number of times the string is split. If \a maxSplit is >=
+    ///   0, at most \a maxSplit splits are done and consequently <= \a maxSplit
+    ///   + 1 elements are returned.
+    ///
+    /// \param[in] keepEmpty
+    ///   True if empty substrings should be returned. Empty substrings still
+    ///   count when considering \a maxSplit.
+    ///
+    /// \return
+    ///   An array containing the substrings. If \a maxSplit == -1 and \a
+    ///   keepEmpty == true, then the concatination of the array forms the input
+    ///   string.
+    static ArraySP SplitString(llvm::StringRef s, char separator,
+                               int maxSplit = -1, bool keepEmpty = true);
+
----------------
clayborg wrote:

This API doesn't seem like it belongs in StructuredData. Also see the comment below about not splitting up the output and error into separate strings.

https://github.com/llvm/llvm-project/pull/90703


More information about the lldb-commits mailing list