Qx v0.7.2
Qt Extensions Library
Loading...
Searching...
No Matches
Qx::FixedStringList< ViewT, N > Class Template Reference

The FixedStringList template class is a FixedList with a few added convenience functions for handling lists of string views (i.e. the FixedList equivalent of QStringList). More...

#include <qx/core/qx-fixedstringlist.h>

Inheritance diagram for Qx::FixedStringList< ViewT, N >:
[legend]

Public Member Functions

constexpr FixedStringList ()=default
 
template<typename A>
requires std::same_as<std::remove_cvref_t<A>, std::array<ViewT, N>>
constexpr FixedStringList (A &&arr)
 
template<typename... Args>
requires (N > 0 && sizeof...(Args) == N && (std::constructible_from<ViewT, Args> && ...))
constexpr FixedStringList (Args &&... args) noexcept
 
template<typename B>
requires std::same_as<std::remove_cvref_t<B>, Base>
constexpr FixedStringList (B &&base)
 
template<size_t M>
requires (M == N)
constexpr FixedStringList (const ViewT(&arr)[M])
 
template<qsizetype K>
constexpr auto chopped () const
 
bool contains (QLatin1StringView str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
 
bool contains (QStringView str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
 
constexpr reference first ()
 
template<qsizetype K>
constexpr auto first () const
 
qsizetype indexOf (QLatin1StringView str, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
 
qsizetype indexOf (QStringView str, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
 
QString join (QChar separator) const
 
QString join (QLatin1StringView separator) const
 
QString join (QStringView separator) const
 
constexpr reference last ()
 
template<qsizetype K>
constexpr auto last () const
 
qsizetype lastIndexOf (QLatin1StringView str, qsizetype from=-1, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
 
qsizetype lastIndexOf (QStringView str, qsizetype from=-1, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
 
template<qsizetype Pos, qsizetype Len = -1>
constexpr auto mid () const
 
template<size_t M>
constexpr FixedStringList< ViewT, N+M > operator+ (const FixedStringList< ViewT, M > &other) const
 
template<size_t M>
constexpr FixedStringList< ViewT, N+M > operator+ (const ViewT(&other)[M]) const
 
template<typename L>
requires std::constructible_from<ViewT, L>
constexpr FixedStringList< ViewT, N+1 > operator+ (L &&other) const
 
template<qsizetype Pos, qsizetype K>
constexpr auto sliced () const
 
template<qsizetype Pos>
constexpr auto sliced () const
 
QStringList toStringList () const
 
- Public Member Functions inherited from Qx::FixedList< ViewT, N >
constexpr FixedList ()=default
 
constexpr FixedList (A &&arr)
 
constexpr FixedList (A &&arr)
 
constexpr FixedList (Args &&... args)
 
constexpr FixedList (Args &&... args)
 
constexpr FixedList (const ViewT(&arr)[M])
 
constexpr FixedList (const ViewT(&arr)[M])
 
constexpr reference at (qsizetype i)
 
constexpr reference at (qsizetype i)
 
constexpr const_reference at (qsizetype i) const
 
constexpr const_reference at (qsizetype i) const
 
constexpr reference back ()
 
constexpr reference back ()
 
constexpr const_reference back () const
 
constexpr const_reference back () const
 
constexpr const_iterator begin () const noexcept
 
constexpr const_iterator begin () const noexcept
 
constexpr iterator begin () noexcept
 
constexpr iterator begin () noexcept
 
constexpr const_iterator cbegin () const noexcept
 
constexpr const_iterator cbegin () const noexcept
 
constexpr const_iterator cend () const noexcept
 
constexpr const_iterator cend () const noexcept
 
constexpr auto chopped () const
 
constexpr auto chopped () const
 
constexpr const_iterator constBegin () const noexcept
 
constexpr const_iterator constBegin () const noexcept
 
constexpr const_pointer constData () const noexcept
 
constexpr const_pointer constData () const noexcept
 
constexpr const_iterator constEnd () const noexcept
 
constexpr const_iterator constEnd () const noexcept
 
constexpr const_reference constFirst () const
 
constexpr const_reference constFirst () const
 
constexpr const_reference constLast () const
 
constexpr const_reference constLast () const
 
constexpr bool contains (const AT &t) const
 
constexpr bool contains (const AT &t) const
 
constexpr qsizetype count (const AT &t) const
 
constexpr qsizetype count (const AT &t) const
 
constexpr const_reverse_iterator crbegin () const noexcept
 
constexpr const_reverse_iterator crbegin () const noexcept
 
constexpr const_reverse_iterator crend () const noexcept
 
constexpr const_reverse_iterator crend () const noexcept
 
constexpr const_pointer data () const noexcept
 
constexpr const_pointer data () const noexcept
 
constexpr pointer data () noexcept
 
constexpr pointer data () noexcept
 
constexpr const_iterator end () const noexcept
 
constexpr const_iterator end () const noexcept
 
constexpr iterator end () noexcept
 
constexpr iterator end () noexcept
 
constexpr bool endsWith (const AT &t) const
 
constexpr bool endsWith (const AT &t) const
 
constexpr FixedList & fill (const AT &t)
 
constexpr FixedList & fill (const AT &t)
 
constexpr reference first ()
 
constexpr reference first ()
 
constexpr const_reference first () const
 
constexpr const_reference first () const
 
constexpr auto first () const
 
constexpr auto first () const
 
constexpr reference front ()
 
constexpr reference front ()
 
constexpr const_reference front () const
 
constexpr const_reference front () const
 
constexpr ViewT && get () &&noexcept
 
constexpr ViewT && get () &&noexcept
 
constexpr ViewT & get () &noexcept
 
constexpr ViewT & get () &noexcept
 
constexpr const ViewT & get () const &noexcept
 
constexpr const ViewT & get () const &noexcept
 
constexpr qsizetype indexOf (const AT &t, qsizetype from=0) const
 
constexpr qsizetype indexOf (const AT &t, qsizetype from=0) const
 
constexpr reference last ()
 
constexpr reference last ()
 
constexpr const_reference last () const
 
constexpr const_reference last () const
 
constexpr auto last () const
 
constexpr auto last () const
 
constexpr qsizetype lastIndexOf (const AT &t, qsizetype from=-1) const
 
constexpr qsizetype lastIndexOf (const AT &t, qsizetype from=-1) const
 
constexpr auto mid () const
 
constexpr auto mid () const
 
constexpr void move (qsizetype from, qsizetype to)
 
constexpr void move (qsizetype from, qsizetype to)
 
constexpr FixedList< ViewT, N+M > operator+ (const FixedList< ViewT, M > &other) const
 
constexpr FixedList< ViewT, N+M > operator+ (const FixedList< ViewT, M > &other) const
 
constexpr FixedList< ViewT, N+1 > operator+ (const ViewT &other) const
 
constexpr FixedList< ViewT, N+1 > operator+ (const ViewT &other) const
 
constexpr FixedList< ViewT, N+M > operator+ (const ViewT(&other)[M]) const
 
constexpr FixedList< ViewT, N+M > operator+ (const ViewT(&other)[M]) const
 
constexpr auto operator<=> (const FixedList &other) const=default
 
constexpr auto operator<=> (const FixedList &other) const=default
 
constexpr bool operator== (const FixedList &other) const=default
 
constexpr bool operator== (const FixedList &other) const=default
 
constexpr reference operator[] (qsizetype i)
 
constexpr reference operator[] (qsizetype i)
 
constexpr const_reference operator[] (qsizetype i) const
 
constexpr const_reference operator[] (qsizetype i) const
 
constexpr const_reverse_iterator rbegin () const noexcept
 
constexpr const_reverse_iterator rbegin () const noexcept
 
constexpr reverse_iterator rbegin () noexcept
 
constexpr reverse_iterator rbegin () noexcept
 
constexpr const_reverse_iterator rend () const noexcept
 
constexpr const_reverse_iterator rend () const noexcept
 
constexpr reverse_iterator rend () noexcept
 
constexpr reverse_iterator rend () noexcept
 
constexpr void replace (qsizetype i, const AT &t)
 
constexpr void replace (qsizetype i, const AT &t)
 
constexpr auto sliced () const
 
constexpr auto sliced () const
 
constexpr auto sliced () const
 
constexpr auto sliced () const
 
constexpr bool startsWith (const AT &t) const
 
constexpr bool startsWith (const AT &t) const
 
constexpr const std::array< ViewT, N > & stdArray () const noexcept
 
constexpr const std::array< ViewT, N > & stdArray () const noexcept
 
constexpr std::array< ViewT, N > & stdArray () noexcept
 
constexpr std::array< ViewT, N > & stdArray () noexcept
 
constexpr void swap (FixedList &other) noexcept(std::is_nothrow_swappable_v< ViewT >)
 
constexpr void swap (FixedList &other) noexcept(std::is_nothrow_swappable_v< ViewT >)
 
constexpr void swapItemsAt (qsizetype i, qsizetype j)
 
constexpr void swapItemsAt (qsizetype i, qsizetype j)
 
QList< ViewT > toList () const
 
QList< ViewT > toList () const
 
constexpr std::array< ViewT, N > toStdArray () const
 
constexpr std::array< ViewT, N > toStdArray () const
 
constexpr ViewT value (qsizetype i) const
 
constexpr ViewT value (qsizetype i) const
 
constexpr ViewT value (qsizetype i, const AT &defaultValue) const
 
constexpr ViewT value (qsizetype i, const AT &defaultValue) const
 

Related Symbols

(Note that these are not member symbols.)

template<typename ViewT, size_t M, size_t N>
constexpr FixedStringList< ViewT, M+N > operator+ (const ViewT(&a)[M], const FixedStringList< ViewT, N > &b)
 
template<typename L, typename ViewT, size_t N>
constexpr FixedStringList< ViewT, 1+N > operator+ (L &&a, const FixedStringList< ViewT, N > &b)
 

Additional Inherited Members

- Public Types inherited from Qx::FixedList< ViewT, N >
using const_iterator
 
using const_pointer
 
using const_reference
 
using const_reverse_iterator
 
using ConstIterator
 
using difference_type
 
using Iterator
 
using iterator
 
using parameter_type
 
using pointer
 
using reference
 
using reverse_iterator
 
using size_type
 
using value_type
 
- Static Public Member Functions inherited from Qx::FixedList< ViewT, N >
static constexpr qsizetype count () noexcept
 
static constexpr qsizetype count () noexcept
 
static constexpr bool empty () noexcept
 
static constexpr bool empty () noexcept
 
static constexpr bool isEmpty () noexcept
 
static constexpr bool isEmpty () noexcept
 
static constexpr qsizetype length () noexcept
 
static constexpr qsizetype length () noexcept
 
static constexpr qsizetype size () noexcept
 
static constexpr qsizetype size () noexcept
 
- Static Public Attributes inherited from Qx::FixedList< ViewT, N >
static constexpr qsizetype size_v
 
static constexpr qsizetype size_v
 

Detailed Description

template<typename ViewT, size_t N>
requires any_of<ViewT, QLatin1StringView, QStringView>
class Qx::FixedStringList< ViewT, N >

The element type must be either QStringView or QLatin1StringView. As with any other view, the underlying strings are not owned by the list, so they must outlive it. This is naturally the case for string literals, which is the primary use-case for this class.

All of FixedList's functionality also applies to FixedStringList. For example you can use functions like isEmpty(), at(), and size() to inspect the list.

Both the view type and the size can be deduced from the type of literal used to construct the list; char16_t literals (and QString or QStringView) will result in a QStringView list, while char literals (and QLatin1StringView) will result in a QLatin1StringView list. The StringViewList and Latin1StringViewList aliases can be used to make the type explicit while still having the size deduced.

Qx::FixedStringList fsl1{u"one", u"two", u"three"}; // FixedStringList<QStringView, 3>
Qx::FixedStringList fsl2{"one", "two"}; // FixedStringList<QLatin1StringView, 2>
Qx::StringViewList fsl3{u"one", u"two"}; // FixedStringList<QStringView, 2>
Qx::Latin1StringViewList fsl4{"one", "two"}; // FixedStringList<QLatin1StringView, 2>
Qx::StringViewList<2> fsl5{{u"one", u"two"}};
QString str = fsl1.join(u", "); // "one, two, three"
The FixedStringList template class is a FixedList with a few added convenience functions for handling...
Definition qx-fixedstringlist.h:36
QString join(QStringView separator) const
Definition qx-fixedstringlist.h:153
FixedStringList< QLatin1StringView, N > Latin1StringViewList
Definition qx-fixedstringlist.h:238
FixedStringList< QStringView, N > StringViewList
Definition qx-fixedstringlist.h:235
See also
FixedList, StringViewList, Latin1StringViewList

Constructor & Destructor Documentation

◆ FixedStringList() [1/5]

template<typename ViewT, size_t N>
Qx::FixedStringList< ViewT, N >::FixedStringList ( )
constexprdefault

Constructs an empty FixedStringList.

◆ FixedStringList() [2/5]

template<typename ViewT, size_t N>
template<size_t M>
requires (M == N)
Qx::FixedStringList< ViewT, N >::FixedStringList ( const ViewT(&) arr[M])
inlineconstexpr

Constructs a list that contains copies of the views in the C array arr.

Requires that M is equal to N.

◆ FixedStringList() [3/5]

template<typename ViewT, size_t N>
template<typename A>
requires std::same_as<std::remove_cvref_t<A>, std::array<ViewT, N>>
Qx::FixedStringList< ViewT, N >::FixedStringList ( A && arr)
inlineconstexpr

Constructs a list that contains the views in the std::array arr.

Requires that A is a (possibly cv-qualified/reference) std::array<ViewT, N>.

◆ FixedStringList() [4/5]

template<typename ViewT, size_t N>
template<typename B>
requires std::same_as<std::remove_cvref_t<B>, Base>
Qx::FixedStringList< ViewT, N >::FixedStringList ( B && base)
inlineexplicitconstexpr

Constructs a list from the FixedList base, which allows the result of a FixedList operation to be used as a FixedStringList.

Requires that B is a (possibly cv-qualified/reference) FixedList<ViewT, N>.

◆ FixedStringList() [5/5]

template<typename ViewT, size_t N>
template<typename... Args>
requires (N > 0 && sizeof...(Args) == N && (std::constructible_from<ViewT, Args> && ...))
Qx::FixedStringList< ViewT, N >::FixedStringList ( Args &&... args)
inlineconstexprnoexcept

Constructs a list from args, each of which must be usable to construct a ViewT, such as a string literal.

Requires that the number of arguments is equal to N, and that N is greater than zero.

Member Function Documentation

◆ chopped()

template<typename ViewT, size_t N>
template<qsizetype K>
auto Qx::FixedStringList< ViewT, N >::chopped ( ) const
inlineconstexpr

Returns a FixedStringList<ViewT, N - K> that contains copies of all but the last K views in this list.

K must be non-negative and no greater than N.

See also
FixedList::chopped()

◆ contains() [1/2]

template<typename ViewT, size_t N>
bool Qx::FixedStringList< ViewT, N >::contains ( QLatin1StringView str,
Qt::CaseSensitivity cs = Qt::CaseSensitive ) const
inlinenoexcept

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Returns true if the list contains the Latin-1 string viewed by str; otherwise, returns false.

◆ contains() [2/2]

template<typename ViewT, size_t N>
bool Qx::FixedStringList< ViewT, N >::contains ( QStringView str,
Qt::CaseSensitivity cs = Qt::CaseSensitive ) const
inlinenoexcept

Returns true if the list contains the string str; otherwise, returns false.

The search is case insensitive if cs is Qt::CaseInsensitive; the search is case sensitive by default.

See also
indexOf(), lastIndexOf()

◆ first() [1/2]

template<typename ViewT, size_t N>
reference Qx::FixedList< ViewT, N >::first ( )
inlineconstexpr

Returns a reference to the first item in the list.

Requires the list to not be empty.

See also
constFirst(), last(), isEmpty()

◆ first() [2/2]

template<typename ViewT, size_t N>
template<qsizetype K>
auto Qx::FixedStringList< ViewT, N >::first ( ) const
inlineconstexpr

Returns a FixedStringList<ViewT, K> that contains copies of the first K views in this list.

K must be non-negative and no greater than N.

See also
FixedList::first()

◆ indexOf() [1/2]

template<typename ViewT, size_t N>
qsizetype Qx::FixedStringList< ViewT, N >::indexOf ( QLatin1StringView str,
qsizetype from = 0,
Qt::CaseSensitivity cs = Qt::CaseSensitive ) const
inlinenoexcept

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Returns the index position of the first occurrence of the Latin-1 string viewed by str.

◆ indexOf() [2/2]

template<typename ViewT, size_t N>
qsizetype Qx::FixedStringList< ViewT, N >::indexOf ( QStringView str,
qsizetype from = 0,
Qt::CaseSensitivity cs = Qt::CaseSensitive ) const
inlinenoexcept

Returns the index position of the first occurrence of the string str in the list, searching forward from index position from. Returns -1 if no item matched.

If from is negative, it is interpreted as an offset from the end of the list (i.e. -1 starts the search at the last item).

The search is case insensitive if cs is Qt::CaseInsensitive; the search is case sensitive by default.

See also
lastIndexOf(), contains()

◆ join() [1/3]

template<typename ViewT, size_t N>
QString Qx::FixedStringList< ViewT, N >::join ( QChar separator) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ join() [2/3]

template<typename ViewT, size_t N>
QString Qx::FixedStringList< ViewT, N >::join ( QLatin1StringView separator) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ join() [3/3]

template<typename ViewT, size_t N>
QString Qx::FixedStringList< ViewT, N >::join ( QStringView separator) const
inline

Joins all the strings in the list into a single string with each element separated by the given separator (which can be an empty string).

If the list is empty, an empty string is returned.

See also
toStringList()

◆ last() [1/2]

template<typename ViewT, size_t N>
reference Qx::FixedList< ViewT, N >::last ( )
inlineconstexpr

Returns a reference to the last item in the list.

Requires the list to not be empty.

See also
constLast(), first(), isEmpty()

◆ last() [2/2]

template<typename ViewT, size_t N>
template<qsizetype K>
auto Qx::FixedStringList< ViewT, N >::last ( ) const
inlineconstexpr

Returns a FixedStringList<ViewT, K> that contains copies of the last K views in this list.

K must be non-negative and no greater than N.

See also
FixedList::last()

◆ lastIndexOf() [1/2]

template<typename ViewT, size_t N>
qsizetype Qx::FixedStringList< ViewT, N >::lastIndexOf ( QLatin1StringView str,
qsizetype from = -1,
Qt::CaseSensitivity cs = Qt::CaseSensitive ) const
inlinenoexcept

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Returns the index position of the last occurrence of the Latin-1 string viewed by str.

◆ lastIndexOf() [2/2]

template<typename ViewT, size_t N>
qsizetype Qx::FixedStringList< ViewT, N >::lastIndexOf ( QStringView str,
qsizetype from = -1,
Qt::CaseSensitivity cs = Qt::CaseSensitive ) const
inlinenoexcept

Returns the index position of the last occurrence of the string str in the list, searching backward from index position from. Returns -1 if no item matched.

If from is negative, it is interpreted as an offset from the end of the list (i.e. -1, the default, starts the search at the last item). If from is greater than or equal to the size of the list, the search starts at the last item.

The search is case insensitive if cs is Qt::CaseInsensitive; the search is case sensitive by default.

See also
indexOf(), contains()

◆ mid()

template<typename ViewT, size_t N>
template<qsizetype Pos, qsizetype Len = -1>
auto Qx::FixedStringList< ViewT, N >::mid ( ) const
inlineconstexpr

Returns a FixedStringList that contains copies of up to Len views in this list, starting at index position Pos.

The size of the result and the requirements of the parameters are the same as FixedList::mid().

See also
FixedList::mid()

◆ operator+() [1/3]

template<typename ViewT, size_t N>
template<size_t M>
FixedStringList< ViewT, N+M > Qx::FixedStringList< ViewT, N >::operator+ ( const FixedStringList< ViewT, M > & other) const
inlineconstexpr

Returns a FixedStringList of size N + M that contains all the views in this list followed by all the views in other.

◆ operator+() [2/3]

template<typename ViewT, size_t N>
template<size_t M>
FixedStringList< ViewT, N+M > Qx::FixedStringList< ViewT, N >::operator+ ( const ViewT(&) other[M]) const
inlineconstexpr

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Returns a FixedStringList of size N + M that contains all the views in this list followed by all the views in the C array other.

◆ operator+() [3/3]

template<typename ViewT, size_t N>
template<typename L>
requires std::constructible_from<ViewT, L>
FixedStringList< ViewT, N+1 > Qx::FixedStringList< ViewT, N >::operator+ ( L && other) const
inlineconstexpr

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Returns a FixedStringList of size N + 1 that contains all the views in this list followed by a ViewT constructed from other, which can be anything that a ViewT can be constructed from (i.e. a string literal).

◆ sliced() [1/2]

template<typename ViewT, size_t N>
template<qsizetype Pos, qsizetype K>
auto Qx::FixedStringList< ViewT, N >::sliced ( ) const
inlineconstexpr

Returns a FixedStringList<ViewT, K> that contains copies of K views in this list, starting at index position Pos.

Pos and K must be non-negative and Pos + K must be no greater than N.

See also
FixedList::sliced()

◆ sliced() [2/2]

template<typename ViewT, size_t N>
template<qsizetype Pos>
auto Qx::FixedStringList< ViewT, N >::sliced ( ) const
inlineconstexpr

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Returns a FixedStringList<ViewT, N - Pos> that contains copies of all views in this list from index position Pos to the end.

Pos must be non-negative and no greater than N.

◆ toStringList()

template<typename ViewT, size_t N>
QStringList Qx::FixedStringList< ViewT, N >::toStringList ( ) const
inline

Returns a QStringList that contains a QString copy of each of the strings in the list.

See also
join(), FixedList::toList()

Friends And Related Symbol Documentation

◆ operator+() [1/2]

template<typename ViewT, size_t M, size_t N>
FixedStringList< ViewT, M+N > operator+ ( const ViewT(&) a[M],
const FixedStringList< ViewT, N > & b )
related

Returns a FixedStringList which is the result of concatenating a and b.

◆ operator+() [2/2]

template<typename L, typename ViewT, size_t N>
FixedStringList< ViewT, 1+N > operator+ ( L && a,
const FixedStringList< ViewT, N > & b )
related

Returns a FixedStringList which is the result of concatenating a and b.


The documentation for this class was generated from the following files: