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

    • Icon: User Story User Story
    • Resolution: Unresolved
    • Icon: P3: Somewhat important P3: Somewhat important
    • None
    • None
    • None

      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().

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

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

              Created:
              Updated:

                There are no open Gerrit changes