Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-135629

String View Additions

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • None
    • None

    Description

      When using QStringView, I sometimes miss functionality/shorthands that I know from other languages/libraries. While it's not impossible to emulate them with the current API, it hides a bit of intent when reading the code. This applies to all string view types, but I'm using QStringView as the example.

      • Remove a matching part from the beginning or end. LLVM: consume_front/back, Rust: strip_prefix/suffix, Python: remove_prefix/suffix
        I'm not sure what the ideal signature would be here. Having the ability to do chaining would be nice. So maybe stripPrefix(T prefix, Qt::CaseSensitivity cs = insensitive, bool *ok = nullptr) -> QStringView&?
      • Split a string into exactly two parts. LLVM: split, Rust: split_once
        This is particularly useful when you know that there will only be two parts. I think the behavior of LLVM would be nice in that it always returns a pair.

      A bit related to https://bugreports.qt.io/browse/QTBUG-115007: having toLower(), toUpper(), and replace() could make code more concise. This hides the allocation for a QString a bit, but avoiding the intermediate .toString() seems worthy.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            mmutz Marc Mutz
            nerixyz Tom Fors
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes