diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2016-12-15 10:52:40 +0100 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2017-06-20 09:54:27 +0000 |
commit | 3fe9e5dff79590c79bc56cdee6a115d5cf6b3319 (patch) | |
tree | 7cc6488874a9c83565fd771712d8ec4944c926a1 /src/corelib/tools/qdatetimeparser_p.h | |
parent | e2eafc0c271e44fd9e8969b003e7f8ecd57cd2e6 (diff) |
Eliminate out-parameters from QDateTimeParser::parseSection()
Return a struct instead. This frees parse() of an assumption that -1
is an error value and leaves one in/out argument. Made this last an
actual pointer argument instead of a non-const ref. Shuffled the
remaining arguments so that this in/out is last and the offset into it
at which it gets modified is immediately before it. Removed a
spurious qdoc comment in the process.
Change-Id: I7d980e70a7711b1d706151eedce956fe2093e48e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qdatetimeparser_p.h')
-rw-r--r-- | src/corelib/tools/qdatetimeparser_p.h | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/corelib/tools/qdatetimeparser_p.h b/src/corelib/tools/qdatetimeparser_p.h index ee6f9f3054..3a97b9d468 100644 --- a/src/corelib/tools/qdatetimeparser_p.h +++ b/src/corelib/tools/qdatetimeparser_p.h @@ -200,13 +200,24 @@ private: int sectionMaxSize(Section s, int count) const; QString sectionText(const QString &text, int sectionIndex, int index) const; #ifndef QT_NO_DATESTRING - int parseSection(const QDateTime ¤tValue, int sectionIndex, QString &txt, int &cursorPosition, - int index, QDateTimeParser::State &state, int *used = 0) const; + struct ParsedSection { + int value; + int used; + int zeroes; + State state; + Q_DECL_CONSTEXPR ParsedSection(State ok = Invalid, + int val = 0, int read = 0, int zs = 0) + : value(ok == Invalid ? -1 : val), used(read), zeroes(zs), state(ok) + {} + }; + ParsedSection parseSection(const QDateTime ¤tValue, int sectionIndex, + int offset, QString *text) const; int findMonth(const QString &str1, int monthstart, int sectionIndex, QString *monthName = 0, int *used = 0) const; int findDay(const QString &str1, int intDaystart, int sectionIndex, QString *dayName = 0, int *used = 0) const; - int findTimeZone(QStringRef str, const QDateTime&when, int *used) const; + ParsedSection findTimeZone(QStringRef str, const QDateTime &when, + int maxVal, int minVal) const; static int startsWithLocalTimeZone(const QStringRef name); // implemented in qdatetime.cpp enum AmPmFinder { |