15.03.2017, 01:52, "Ch'Gans" <chg...@gna.org>: > On 14 March 2017 at 22:43, Harald Vistnes <harald.vist...@gmail.com> wrote: >> Hi, >> >> I'm currently working on reading and parsing large ASCII based text files >> and I am wondering what is the current best practice. There are so many >> classes and macros available, so it can be a bit confusing to know what to >> use when. > > Can you define 'large', eg, 1MG, 1GB or 1TB? > >> QString, QLatin1String, QByteArray, QStringLiteral, QLatin1Literal, >> QByteArrayLiteral, plain C++ string literal, QStringRef, QStringBuilder and >> so on. And then std::string and raw const char* strings. >> >> In my case I want to read a large ASCII file line by line, so I don't need >> unicode. I need to compare a string with a literal, extract substrings and >> convert some strings to numbers. > > If you use QIODevice, you'll get data as QByteArray, which can be used > for basic comparison, splitting, searching, substring extraction and > to/from numbers. > >> Should I just use QString all the way, or is it faster to use some other >> classes when you know you don't need unicode? >> >> Any hints on fast file parsing code in Qt itself that I could use as a >> guildeline? > > I once used QRegularExpression for parsing text file that had a > 'headache' file format, i was surprise by the velocity of the result, > at least i was good enough for me. I mean certainly slower than plain > C code using char*, but the code was so much easier to write, read and > test.
re2c tool (that I mentioned before) generates such C code from your regular expressions :) > > Chris > >> Thanks, >> Harald >> >> _______________________________________________ >> Interest mailing list >> Interest@qt-project.org >> http://lists.qt-project.org/mailman/listinfo/interest > > _______________________________________________ > Interest mailing list > Interest@qt-project.org > http://lists.qt-project.org/mailman/listinfo/interest -- Regards, Konstantin _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest