Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
QLocaleData::DigitSequence Class Reference

Descriptor for a digit sequence within a text. More...

#include <qlocale_p.h>

Collaboration diagram for QLocaleData::DigitSequence:

Public Types

enum class  Option { Default = 0 , AllowSign = 1 }

Public Member Functions

 Q_DECLARE_FLAGS (Options, Option)
Q_AUTOTEST_EXPORT DigitSequence (QStringView text, NumericData &&numeric, DigitSequence::Options flags=DigitSequence::Option::Default, qsizetype from=0)
 DigitSequence (const DigitSequence &)=default
 DigitSequence (DigitSequence &&)=default
DigitSequenceoperator= (const DigitSequence &)=default
DigitSequenceoperator= (DigitSequence &&)=default
 ~DigitSequence ()=default
qsizetype endIndex () const
qsizetype size () const
 Returns the number of ASCII characters describing the digit sequence.
bool isEmpty () const
 Returns true precisely if this digit sequence represents nothing.
bool hasSign () const
 Returns true precisely if the digit sequence parsed includes a leading sign.
void transcribeTo (CharBuff *buff) const
 Transcribes the ASCII form of this digit sequence to buff.
DigitSequence first (qsizetype count) const
 Returns a DigitSequence describing a prefix of this.
DigitSequence last (qsizetype count) const
 Returns a DigitSequence describing a tail of this.
DigitSequence sliced (qsizetype from) const
 Returns a DigitSequence describing a tail of this.
DigitSequence sliced (qsizetype from, qsizetype count) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
QStringView used (const QStringView text, qsizetype from) const
QStringView used (const QStringView text) const
 Returns the slice of text described by this digit sequence.

Public Attributes

QByteArray digits
qsizetype digitStart
qint8 digitWidth
char sign = '\0'

Detailed Description

Descriptor for a digit sequence within a text.

Since
6.12

Packages the ASCII equivalent (optional sign and) digit sequence, along with a description of which parts come from where in the original text.

Supports construction or assignment by moving or copying. Modifying its members, other than by assigning a newly constructed value or a result of taking a subsequence, may lead to undefined behaviour.

See also
sliced(), first(), last()

Definition at line 452 of file qlocale_p.h.

Member Enumeration Documentation

◆ Option

Since
6.12

Options to modify how digit sequences are parsed.

\value Default The null option value. \value AllowSign A leading sign character may be present.

In the numeric fields of a date, only a year field ever has a sign, all others use ungrouped digits. Zero-padding on the left of day and month fields is common (and it may also appear in year fields). The hour field of a zone-offset may also have a sign. Otherwise all numeric time fields are similar to numeric month and day fields.

In numeric fields of a time, the least-significant given (be it hour, minute or second) may have a fractional part in some formats. The handling of this is left for the caller to take care of. Likewise, the caller is expected to deal with leading and trailing space appropriately.

Enumerator
Default 
AllowSign 

Definition at line 462 of file qlocale_p.h.

Constructor & Destructor Documentation

◆ DigitSequence() [1/3]

Q_AUTOTEST_EXPORT QLocaleData::DigitSequence::DigitSequence ( QStringView text,
NumericData && numeric,
DigitSequence::Options flags = DigitSequence::Option::Default,
qsizetype from = 0 )

◆ DigitSequence() [2/3]

QLocaleData::DigitSequence::DigitSequence ( const DigitSequence & )
default

◆ DigitSequence() [3/3]

QLocaleData::DigitSequence::DigitSequence ( DigitSequence && )
default

◆ ~DigitSequence()

QLocaleData::DigitSequence::~DigitSequence ( )
default

Member Function Documentation

◆ endIndex()

qsizetype QLocaleData::DigitSequence::endIndex ( ) const
inline

Definition at line 479 of file qlocale_p.h.

◆ first()

DigitSequence QLocaleData::DigitSequence::first ( qsizetype count) const
inline

Returns a DigitSequence describing a prefix of this.

The result describes the first count ASCII characters to which the sequence corresponds and their positions within the parsed text. The value of count must not be negative or exceed size().

Definition at line 503 of file qlocale_p.h.

References hasSign().

Here is the call graph for this function:

◆ hasSign()

bool QLocaleData::DigitSequence::hasSign ( ) const
inline

Returns true precisely if the digit sequence parsed includes a leading sign.

It is equivalent to {sign != '\0'}.

Definition at line 491 of file qlocale_p.h.

References sign.

Referenced by first(), and sliced().

Here is the caller graph for this function:

◆ isEmpty()

bool QLocaleData::DigitSequence::isEmpty ( ) const
inline

Returns true precisely if this digit sequence represents nothing.

This arises when the constructor found no digits and (when allowed) not even a sign. It may also result from extracting an empty subsequence of a digit sequence that was originally parsed. It is equivalent to \l {QLocaleData::DigitSequence::}{size()} == 0. To test whether any digits were found, use {digits.isEmpty()}, which may be true even though {isEmpty()} is false. That arises when only a sign was found (making {size() == 1}).

See also
size()

Definition at line 490 of file qlocale_p.h.

◆ last()

DigitSequence QLocaleData::DigitSequence::last ( qsizetype count) const
inline

Returns a DigitSequence describing a tail of this.

The result describes the last count ASCII characters to which the sequence corresponds. The value of count must not be negative or exceed size(). The result is equivalent to {sliced(size() - count)}.

Definition at line 511 of file qlocale_p.h.

◆ operator=() [1/2]

DigitSequence & QLocaleData::DigitSequence::operator= ( const DigitSequence & )
default

◆ operator=() [2/2]

DigitSequence & QLocaleData::DigitSequence::operator= ( DigitSequence && )
default

◆ Q_DECLARE_FLAGS()

QLocaleData::DigitSequence::Q_DECLARE_FLAGS ( Options ,
Option  )

◆ size()

qsizetype QLocaleData::DigitSequence::size ( ) const
inline

Returns the number of ASCII characters describing the digit sequence.

This is the number of digits plus, if present, one for the sign. It is the number of characters \l transcribeTo() will transcribe. For the number of digits found, use {digits.size()}. Note that this may be less than the length of the text parsed, for example when the digits are surrogate pairs or the sign includes special Unicode markers, such as those for text direction.

See also
isEmpty()

Definition at line 485 of file qlocale_p.h.

◆ sliced() [1/2]

DigitSequence QLocaleData::DigitSequence::sliced ( qsizetype from) const
inline

Returns a DigitSequence describing a tail of this.

This skips over the text to which the first from ASCII characters of the sequence correspond, to describe the remainder and their positions within the parsed text. The value of from must not be negative or exceed size().

Definition at line 513 of file qlocale_p.h.

References hasSign().

Here is the call graph for this function:

◆ sliced() [2/2]

DigitSequence QLocaleData::DigitSequence::sliced ( qsizetype from,
qsizetype count ) const
inline

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

Returns a DigitSequence describing a subsequence of this.

This skips over the portion of the text to which first from ASCII characters correspond and describes the portion described by the next count ASCII characters. The value of from must not be negative or exceed size(). The value of count must not be negative or exceed {size() - from}. The result is equivalent to {sliced(from).first(count)}.

Definition at line 522 of file qlocale_p.h.

◆ transcribeTo()

void QLocaleData::DigitSequence::transcribeTo ( CharBuff * buff) const
inline

Transcribes the ASCII form of this digit sequence to buff.

See also
size()

Definition at line 493 of file qlocale_p.h.

References sign.

◆ used() [1/2]

QStringView QLocaleData::DigitSequence::used ( const QStringView text) const
inlinenodiscard

Returns the slice of text described by this digit sequence.

The given text should be the one passed to the constructor either of this digit sequence or of one from which it was obtained by some combination of \l first(), \l sliced() and \l last(). In the directly-constructed case, or in the case of (optionally repeatedly) applying only \l first(), from may be passed: it should be the like-named offset passed to the original constructor, or 0 if no offset was passed. In that case, the whole text parsed for this digit sequence (alibeit possibly a prefix of the text originally parsed) is returned. Otherwise, from should be omitted and this function returns the text described by just the digits of this sequence, omitting (even when relevant) the sign.

See also
{QLocaleData::DigitSequence::}{DigitSequence()}

Definition at line 528 of file qlocale_p.h.

◆ used() [2/2]

QStringView QLocaleData::DigitSequence::used ( const QStringView text,
qsizetype from ) const
inlinenodiscard

Definition at line 526 of file qlocale_p.h.

Member Data Documentation

◆ digits

QByteArray QLocaleData::DigitSequence::digits

Definition at line 454 of file qlocale_p.h.

◆ digitStart

qsizetype QLocaleData::DigitSequence::digitStart

Definition at line 456 of file qlocale_p.h.

◆ digitWidth

qint8 QLocaleData::DigitSequence::digitWidth

Definition at line 459 of file qlocale_p.h.

◆ sign

char QLocaleData::DigitSequence::sign = '\0'

Definition at line 460 of file qlocale_p.h.

Referenced by hasSign(), and transcribeTo().


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