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

QAnyStringView::data lacks a purpose - add encoding(), document or deprecate

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 6.9.0
    • Core: Other, Documentation
    • None
    • All

    Description

      QAnyStringView is great! I learned about it recently and really like it!

      However, in some areas it still feels a bit young. At some point, it is almost always needed to extract data from it and then there are some (performance-related) issues.

      We have toString(), but that will allocate a new QString. Sometimes, users don’t even want a string - they want an int, float or double - or appending to a string and then a not needed allocation is pretty expensive.

      I’d like to propose adding the following:

      • toInt(), toFloat(), toDouble() — like QStringView has.
      • QString::operator+=(QAnyStringView) and/or QStringView::writeTo(QString&) could also be useful.

      But importantly, until QAnyStringView gets these, it would be really nice to be able to handle this on the user side - but that’s not easy right now, because there are no good way to use data() without knowing the encoding of the view.

      So maybe add QAnyStringView::encoding() or something similar?

      Attachments

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

        Activity

          People

            thiago Thiago Macieira
            tmartsum Thorbjørn Lund Martsum
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes