summaryrefslogtreecommitdiffstats
path: root/src/corelib/text/qstringtokenizer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/text/qstringtokenizer.cpp')
-rw-r--r--src/corelib/text/qstringtokenizer.cpp132
1 files changed, 52 insertions, 80 deletions
diff --git a/src/corelib/text/qstringtokenizer.cpp b/src/corelib/text/qstringtokenizer.cpp
index 4e8ffc2c8e..fc6faed27f 100644
--- a/src/corelib/text/qstringtokenizer.cpp
+++ b/src/corelib/text/qstringtokenizer.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz <marc.mutz@kdab.com>
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz <marc.mutz@kdab.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qstringtokenizer.h"
#include "qstringalgorithms.h"
@@ -73,7 +37,7 @@ QT_BEGIN_NAMESPACE
Argument Deduction (CTAD), you may write
\c{QStringTokenizer{string, separator}} (without template
arguments). If you can't use C++17 CTAD, you must use the
- QStringView::split() or QLatin1String::split() member functions
+ QStringView::split() or QLatin1StringView::split() member functions
and store the return value only in \c{auto} variables:
\code
@@ -143,30 +107,30 @@ QT_BEGIN_NAMESPACE
use(e);
\endcode
- \sa QStringView::split(), QLatin1String::split(), QRegularExpression
+ \sa QStringView::split(), QString::split(), QRegularExpression
*/
/*!
- \typedef QStringTokenizer::value_type
+ \typealias QStringTokenizer::value_type
- Alias for \c{const QStringView} or \c{const QLatin1String},
+ Alias for \c{const QStringView} or \c{const QLatin1StringView},
depending on the tokenizer's \c Haystack template argument.
*/
/*!
- \typedef QStringTokenizer::difference_type
+ \typealias QStringTokenizer::difference_type
Alias for qsizetype.
*/
/*!
- \typedef QStringTokenizer::size_type
+ \typealias QStringTokenizer::size_type
Alias for qsizetype.
*/
/*!
- \typedef QStringTokenizer::reference
+ \typealias QStringTokenizer::reference
Alias for \c{value_type &}.
@@ -175,13 +139,13 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \typedef QStringTokenizer::const_reference
+ \typealias QStringTokenizer::const_reference
Alias for \c{value_type &}.
*/
/*!
- \typedef QStringTokenizer::pointer
+ \typealias QStringTokenizer::pointer
Alias for \c{value_type *}.
@@ -190,13 +154,13 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \typedef QStringTokenizer::const_pointer
+ \typealias QStringTokenizer::const_pointer
Alias for \c{value_type *}.
*/
/*!
- \typedef QStringTokenizer::iterator
+ \typealias QStringTokenizer::iterator
This typedef provides an STL-style const iterator for
QStringTokenizer.
@@ -217,7 +181,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \typedef QStringTokenizer::sentinel
+ \typealias QStringTokenizer::sentinel
This typedef provides an STL-style sentinel for
QStringTokenizer::iterator and QStringTokenizer::const_iterator.
@@ -226,8 +190,8 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn QStringTokenizer(Haystack haystack, String needle, Qt::CaseSensitivity cs, Qt::SplitBehavior sb)
- \fn QStringTokenizer(Haystack haystack, String needle, Qt::SplitBehavior sb, Qt::CaseSensitivity cs)
+ \fn template <typename Haystack, typename Needle> QStringTokenizer<Haystack, Needle>::QStringTokenizer(Haystack haystack, Needle needle, Qt::CaseSensitivity cs, Qt::SplitBehavior sb)
+ \fn template <typename Haystack, typename Needle> QStringTokenizer<Haystack, Needle>::QStringTokenizer(Haystack haystack, Needle needle, Qt::SplitBehavior sb, Qt::CaseSensitivity cs)
Constructs a string tokenizer that splits the string \a haystack
into substrings wherever \a needle occurs, and allows iteration
@@ -238,31 +202,24 @@ QT_BEGIN_NAMESPACE
\a cs specifies whether \a needle should be matched case
sensitively or case insensitively.
- If \a sb is QString::SkipEmptyParts, empty entries don't
+ If \a sb is Qt::SkipEmptyParts, empty entries don't
appear in the result. By default, empty entries are included.
- \sa QStringView::split(), QLatin1String::split(), Qt::CaseSensitivity, Qt::SplitBehavior
+ \sa QStringView::split(), QString::split(), Qt::CaseSensitivity, Qt::SplitBehavior
*/
/*!
- \fn QStringTokenizer::const_iterator QStringTokenizer::begin() const
+ \fn template <typename Haystack, typename Needle> QStringTokenizer<Haystack, Needle>::iterator QStringTokenizer<Haystack, Needle>::begin() const
+ \fn template <typename Haystack, typename Needle> QStringTokenizer<Haystack, Needle>::iterator QStringTokenizer<Haystack, Needle>::cbegin() const
Returns a const \l{STL-style iterators}{STL-style iterator}
pointing to the first token in the list.
- \sa end(), cbegin()
+ \sa end(), cend()
*/
/*!
- \fn QStringTokenizer::const_iterator QStringTokenizer::cbegin() const
-
- Same as begin().
-
- \sa cend(), begin()
-*/
-
-/*!
- \fn QStringTokenizer::sentinel QStringTokenizer::end() const
+ \fn template <typename Haystack, typename Needle> QStringTokenizer<Haystack, Needle>::sentinel QStringTokenizer<Haystack, Needle>::end() const
Returns a const \l{STL-style iterators}{STL-style sentinel}
pointing to the imaginary token after the last token in the list.
@@ -271,7 +228,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn QStringTokenizer::sentinel QStringTokenizer::cend() const
+ \fn template <typename Haystack, typename Needle> QStringTokenizer<Haystack, Needle>::sentinel QStringTokenizer<Haystack, Needle>::cend() const
Same as end().
@@ -279,19 +236,18 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn QStringTokenizer::toContainer(Container &&c) const &
+ \fn template <typename Haystack, typename Needle> template<typename LContainer> LContainer QStringTokenizer<Haystack, Needle>::toContainer(LContainer &&c) const &
- Convenience method to convert the lazy sequence into a
- (typically) random-access container.
+ Converts the lazy sequence into a (typically) random-access container of
+ type \c LContainer.
This function is only available if \c Container has a \c value_type
matching this tokenizer's value_type.
- If you pass in a named container (an lvalue), then that container
- is filled, and a reference to it is returned.
-
- If you pass in a temporary container (an rvalue, incl. the default
- argument), then that container is filled, and returned by value.
+ If you pass in a named container (an lvalue) for \a c, then that container
+ is filled, and a reference to it is returned. If you pass in a temporary
+ container (an rvalue, incl. the default argument), then that container is
+ filled, and returned by value.
\code
// assuming tok's value_type is QStringView, then...
@@ -311,9 +267,12 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn QStringTokenizer::toContainer(Container &&c) const &&
+ \fn template <typename Haystack, typename Needle> template<typename RContainer> RContainer QStringTokenizer<Haystack, Needle>::toContainer(RContainer &&c) const &&
\overload
+ Converts the lazy sequence into a (typically) random-access container of
+ type \c RContainer.
+
In addition to the constraints on the lvalue-this overload, this
rvalue-this overload is only available when this QStringTokenizer
does not store the haystack internally, as this could create a
@@ -341,17 +300,30 @@ QT_BEGIN_NAMESPACE
func(QStringTokenizer{QStringView{widget.text()}, u','}.toContainer());
// OK: compiler keeps widget.text() around until after func() has executed
\endcode
+
+ If you pass in a named container (an lvalue)for \a c, then that container
+ is filled, and a reference to it is returned. If you pass in a temporary
+ container (an rvalue, incl. the default argument), then that container is
+ filled, and returned by value.
*/
/*!
- \fn qTokenize(Haystack &&haystack, Needle &&needle, Flags...flags)
+ \fn template <typename Haystack, typename Needle, typename...Flags> auto qTokenize(Haystack &&haystack, Needle &&needle, Flags...flags)
\relates QStringTokenizer
\since 6.0
- Factory function for QStringTokenizer. You can use this function
- if your compiler doesn't, yet, support C++17 Class Template
- Argument Deduction (CTAD), but we recommend direct use of
- QStringTokenizer with CTAD instead.
+ Factory function for a QStringTokenizer that splits the string \a haystack
+ into substrings wherever \a needle occurs, and allows iteration
+ over those strings as they are found. If \a needle does not match
+ anywhere in \a haystack, a single element containing \a haystack
+ is produced.
+
+ Pass values from Qt::CaseSensitivity and Qt::SplitBehavior enumerators
+ as \a flags to modify the behavior of the tokenizer.
+
+ You can use this function if your compiler doesn't, yet, support C++17 Class
+ Template Argument Deduction (CTAD). We recommend direct use of QStringTokenizer
+ with CTAD instead.
*/
QT_END_NAMESPACE