Re: [Development] Wither QString?

2019-10-17 Thread Thiago Macieira
On Thursday, 17 October 2019 17:28:34 PDT Henry Skoglund wrote:
> std::string s = std::format("{0:b} {0:d} {0:x}", 42);   // s ==
> "101010 42 2a"|
> 
> Using QString::arg() works fine but it's getting harder to ignore all
> the new C++ stuff and C++20 looks to be one of the bigger additions to
> the language since C++11.

BTW, that doesn't mean we have to stick to QString::arg(). We had the 
beginnings of a change to implement format() like the fmt lib and like Python, 
but it hasn't been merged yet. That's a good thing because now we can look at 
what C++20 will have, including the very latest fixes to width and precision, 
and apply them correctly to Qt.

If we could use the Standard Library implementation, we would, but we can't 
depend on it until 2025 or thereabouts. We'll need to deploy our own.

https://github.com/fmtlib/fmt is MIT-licensed. If we can leverage the 
implementation, it's a path forward.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel System Software Products



___
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development


Re: [Development] Wither QString?

2019-10-17 Thread Thiago Macieira
On Thursday, 17 October 2019 17:28:34 PDT Henry Skoglund wrote:
> Perhaps the time has come to think about a retirement plan for QString?

Sure. As soon as the C++ standard has something that we can replace it with 
*and* we can reliably use it for all our target compilers.

Since the earliest this can happen in C++23, lLet's table this discussion 
until 2028.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel System Software Products



___
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development


Re: [Development] Wither QString?

2019-10-17 Thread Henry Skoglund

Thanks for the answers!
I haven't got much experience yet of std::string so I thought the grass 
was greener over there. But sure, functions like split() and trimmed() I 
use regularly, and they indeed seem to be lacking in std::string.
So sorry QString about that brief moment of infidelity, won't happen 
again :-)



On 2019-10-18 03:49, Sze Howe Koh wrote:

On Fri, 18 Oct 2019 at 08:43, Alexander Nassian
 wrote:

C++ hasn‘t even proper Unicode handling integrated. std::string is a mess in my 
opinion.

Beste Grüße / Best regards,
Alexander Nassian

Am 18.10.2019 um 02:30 schrieb Henry Skoglund :


 Hi, while writing lots of QString string fiddling code (keyboard macro 
utility) I feel something tugging at my sleeve:
the upcoming C++20, looking at std::format(), it seems really handy, e.g.:

std::string s = std::format("String '{}' has {} characters\n", string, 
string.length());

// for a German flavor you can use arg #
std::string s = std::format("{1} Zeichen lang ist die Zeichenkette '{0}'\n", 
string, string.length());

// lots of formatting options with a ':' inside the curlies
std::string s = std::format("{0:b} {0:d} {0:x}", 42);   // s == "101010 42 2a"

Using QString::arg() works fine but it's getting harder to ignore all the new 
C++ stuff and C++20 looks to be one of the bigger additions to the language 
since C++11.

Perhaps the time has come to think about a retirement plan for QString?

Rgrds Henry

I agree with Alexander; QString is far more pleasant to use than
std::string for many everyday tasks.

Aside from Unicode support, std::string lacks (clean) equivalents of
the following functions which I use regularly:
- QString::startsWith(), QString::endsWith()
- QString::split(), QString::section()
- QString::simplified(), QString::trimmed()
- QString::contains(), QString::indexOf() by regex
- QString::replace(), QString::remove() by substring or by regex

I refuse to ditch QString for std::string until Unicode and the above
functionality are offered in std::string, at the very least.


Here are more functions that are lacking in std::string. I personally
don't use them much, but they look pretty handy if the right project
comes along:
- QString::right()
- QString::localeAwareCompare()
- QString::compare() with Qt::CaseInsensitive
- QString::chop(), QString::chopped()
- QString::leftJustified(), QString::rightJustified()


Regards,
Sze-Howe
___
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development


___
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development


Re: [Development] Wither QString?

2019-10-17 Thread Sze Howe Koh
On Fri, 18 Oct 2019 at 08:43, Alexander Nassian
 wrote:
>
> C++ hasn‘t even proper Unicode handling integrated. std::string is a mess in 
> my opinion.
>
> Beste Grüße / Best regards,
> Alexander Nassian
>
> Am 18.10.2019 um 02:30 schrieb Henry Skoglund :
>
> >  Hi, while writing lots of QString string fiddling code (keyboard macro 
> > utility) I feel something tugging at my sleeve:
> > the upcoming C++20, looking at std::format(), it seems really handy, e.g.:
> >
> > std::string s = std::format("String '{}' has {} characters\n", string, 
> > string.length());
> >
> > // for a German flavor you can use arg #
> > std::string s = std::format("{1} Zeichen lang ist die Zeichenkette 
> > '{0}'\n", string, string.length());
> >
> > // lots of formatting options with a ':' inside the curlies
> > std::string s = std::format("{0:b} {0:d} {0:x}", 42);   // s == "101010 42 
> > 2a"
> >
> > Using QString::arg() works fine but it's getting harder to ignore all the 
> > new C++ stuff and C++20 looks to be one of the bigger additions to the 
> > language since C++11.
> >
> > Perhaps the time has come to think about a retirement plan for QString?
> >
> > Rgrds Henry

I agree with Alexander; QString is far more pleasant to use than
std::string for many everyday tasks.

Aside from Unicode support, std::string lacks (clean) equivalents of
the following functions which I use regularly:
- QString::startsWith(), QString::endsWith()
- QString::split(), QString::section()
- QString::simplified(), QString::trimmed()
- QString::contains(), QString::indexOf() by regex
- QString::replace(), QString::remove() by substring or by regex

I refuse to ditch QString for std::string until Unicode and the above
functionality are offered in std::string, at the very least.


Here are more functions that are lacking in std::string. I personally
don't use them much, but they look pretty handy if the right project
comes along:
- QString::right()
- QString::localeAwareCompare()
- QString::compare() with Qt::CaseInsensitive
- QString::chop(), QString::chopped()
- QString::leftJustified(), QString::rightJustified()


Regards,
Sze-Howe
___
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development


Re: [Development] Wither QString?

2019-10-17 Thread Alexander Nassian
C++ hasn‘t even proper Unicode handling integrated. std::string is a mess in my 
opinion.

Beste Grüße / Best regards,
Alexander Nassian

> Am 18.10.2019 um 02:30 schrieb Henry Skoglund :
> 
>  Hi, while writing lots of QString string fiddling code (keyboard macro 
> utility) I feel something tugging at my sleeve:
> the upcoming C++20, looking at std::format(), it seems really handy, e.g.:
> 
> std::string s = std::format("String '{}' has {} characters\n", string, 
> string.length());
> 
> // for a German flavor you can use arg #
> std::string s = std::format("{1} Zeichen lang ist die Zeichenkette '{0}'\n", 
> string, string.length());
> 
> // lots of formatting options with a ':' inside the curlies
> std::string s = std::format("{0:b} {0:d} {0:x}", 42);   // s == "101010 42 2a"
> 
> Using QString::arg() works fine but it's getting harder to ignore all the new 
> C++ stuff and C++20 looks to be one of the bigger additions to the language 
> since C++11.
> 
> Perhaps the time has come to think about a retirement plan for QString?
> 
> Rgrds Henry
> 
> ___
> Development mailing list
> Development@qt-project.org
> https://lists.qt-project.org/listinfo/development

-- 













—


bitshift dynamics GmbH
Neudorfer Str. 1, 79541 Lörrach

Registergericht: Amtsgericht Freiburg i. Breisgau, HRB 713747

Geschäftsführer: Alexander Nassian, Markus Pfaffinger



http://www.bitshift-dynamics.de 


Zentrale: +49 762158673 - 0
Fax: +49 7621 58673 - 90


Allgemeine Anfragen: 
i...@bitshift-dynamics.com 
Technischer 
Support: supp...@bitshift-dynamics.com 

Buchhaltung: 
invo...@bitshift-dynamics.com 
___
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development


[Development] Wither QString?

2019-10-17 Thread Henry Skoglund
Hi, while writing lots of QString string fiddling code (keyboard macro 
utility) I feel something tugging at my sleeve:

the upcoming C++20, looking at std::format(), it seems really handy, e.g.:

std::string s = std::format("String '{}' has {} characters\n", string, 
string.length());


// for a German flavor you can use arg #
std::string s = std::format("{1} Zeichen lang ist die Zeichenkette 
'{0}'\n", string, string.length());


// lots of formatting options with a ':'|inside the curlies
||std::string s = std::format("{0:b} {0:d} {0:x}", 42);   // s == 
"101010 42 2a"|

|
Using QString::arg() works fine but it's getting harder to ignore all 
the new C++ stuff and C++20 looks to be one of the bigger additions to 
the language since C++11.


Perhaps the time has come to think about a retirement plan for QString?

Rgrds Henry

|
___
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development