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

As a user of QStringBuilder, I would like to be able to express repetition and conditionals in expressions

    XMLWordPrintable

    Details

    • Type: User Story
    • Status: Open
    • Priority: P3: Somewhat important
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Labels:
      None

      Description

      For conditionals, we currently work around the lack of this feature by using the ternary operator nested within the QStringBuilder expression:

      QStringView foo = ~~~;
      QString s = str1 % ~~~~ % (shouldIncludeFoo ? foo : u"") % ~~~~ ;
      

      But this requires the LHS and RHS of the ternary to have a reasonably-identical type. I cannot add a QL1S in one and a QStringView in the other, let alone QStringBuilder<T,S> for differing T, S.

      I'm not sure whether one could just overload the ternary operator for QStringBuilder<>, but that would probably mean that at least one of the legs has to be a QStringBuilder expression itself, so maybe something more explicit is needed, like QStringBuilder::Conditional(cond, lhs, rhs)?

      For repetition we don't have any work-around, except storing a subexpression in QString and then using QString::repeated().

        Attachments

          Issue Links

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

            Activity

              People

              Assignee:
              cnn Qt Core & Network
              Reporter:
              mmutz Marc Mutz
              PM Owner:
              Vladimir Minenko Vladimir Minenko
              RnD Owner:
              Alex Blasche Alex Blasche
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:

                  Gerrit Reviews

                  There are no open Gerrit changes