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
QDateTimeParser Class Reference

#include <qdatetimeparser_p.h>

+ Inheritance diagram for QDateTimeParser:
+ Collaboration diagram for QDateTimeParser:

Classes

struct  SectionNode
 
struct  StateNode
 

Public Types

enum  Context { FromString , DateTimeEdit }
 
enum  Section {
  NoSection = 0x00000 , AmPmSection = 0x00001 , MSecSection = 0x00002 , SecondSection = 0x00004 ,
  MinuteSection = 0x00008 , Hour12Section = 0x00010 , Hour24Section = 0x00020 , TimeZoneSection = 0x00040 ,
  HourSectionMask = (Hour12Section | Hour24Section) , TimeSectionMask , DaySection = 0x00100 , MonthSection = 0x00200 ,
  YearSection = 0x00400 , YearSection2Digits = 0x00800 , YearSectionMask = YearSection | YearSection2Digits , DayOfWeekSectionShort = 0x01000 ,
  DayOfWeekSectionLong = 0x02000 , DayOfWeekSectionMask = DayOfWeekSectionShort | DayOfWeekSectionLong , DaySectionMask = DaySection | DayOfWeekSectionMask , DateSectionMask = DaySectionMask | MonthSection | YearSectionMask ,
  Internal = 0x10000 , FirstSection = 0x20000 | Internal , LastSection = 0x40000 | Internal , CalendarPopupSection = 0x80000 | Internal
}
 
enum  State { Invalid , Intermediate , Acceptable }
 
enum  AmPm { AmText , PmText }
 
enum  FieldInfoFlag { Numeric = 0x01 , FixedWidth = 0x02 , AllowPartial = 0x04 , Fraction = 0x08 }
 

Public Member Functions

 QDateTimeParser (QMetaType::Type t, Context ctx, QCalendar cal=QCalendar())
 
virtual ~QDateTimeParser ()
 
StateNode parse (const QString &input, int position, const QDateTime &defaultValue, bool fixup) const
 
bool fromString (const QString &text, QDate *date, QTime *time, int baseYear=QLocale::DefaultTwoDigitBaseYear) const
 
bool fromString (const QString &text, QDateTime *datetime, int baseYear) const
 
bool parseFormat (QStringView format)
 
FieldInfo fieldInfo (int index) const
 
void setDefaultLocale (const QLocale &loc)
 
virtual QString displayText () const
 
void setCalendar (QCalendar calendar)
 Sets cal as the calendar to use.
 

Static Public Attributes

static constexpr int NoSectionIndex = -1
 
static constexpr int FirstSectionIndex = -2
 
static constexpr int LastSectionIndex = -3
 

Protected Member Functions

int sectionSize (int index) const
 
int sectionMaxSize (int index) const
 
int sectionPos (int index) const
 
int sectionPos (SectionNode sn) const
 
const SectionNodesectionNode (int index) const
 
Section sectionType (int index) const
 
QString sectionText (int sectionIndex) const
 
int getDigit (const QDateTime &dt, int index) const
 
bool setDigit (QDateTime &t, int index, int newval) const
 
int absoluteMax (int index, const QDateTime &value=QDateTime()) const
 
int absoluteMin (int index) const
 
bool skipToNextSection (int section, const QDateTime &current, QStringView sectionText) const
 
bool skipToNextSection (int section, const QDateTime &current, const QString &sectionText) const
 
QString stateName (State s) const
 
virtual QDateTime getMinimum (const QTimeZone &zone) const
 
virtual QDateTime getMaximum (const QTimeZone &zone) const
 
virtual int cursorPosition () const
 
virtual QLocale locale () const
 

Protected Attributes

int currentSectionIndex = int(NoSectionIndex)
 
int defaultCenturyStart = QLocale::DefaultTwoDigitBaseYear
 
Sections display
 
int cachedDay = -1
 
QString m_text
 
QList< SectionNodesectionNodes
 
QStringList separators
 
QString displayFormat
 
QLocale defaultLocale
 
QMetaType::Type parserType
 
bool fixday = false
 
Context context
 
QCalendar calendar
 

Friends

class QDTPUnitTestParser
 

Detailed Description

Definition at line 43 of file qdatetimeparser_p.h.

Member Enumeration Documentation

◆ AmPm

Enumerator
AmText 
PmText 

Definition at line 122 of file qdatetimeparser_p.h.

◆ Context

Enumerator
FromString 
DateTimeEdit 

Definition at line 46 of file qdatetimeparser_p.h.

◆ FieldInfoFlag

Enumerator
Numeric 
FixedWidth 
AllowPartial 
Fraction 

Definition at line 134 of file qdatetimeparser_p.h.

◆ Section

Enumerator
NoSection 
AmPmSection 
MSecSection 
SecondSection 
MinuteSection 
Hour12Section 
Hour24Section 
TimeZoneSection 
HourSectionMask 
TimeSectionMask 
DaySection 
MonthSection 
YearSection 
YearSection2Digits 
YearSectionMask 
DayOfWeekSectionShort 
DayOfWeekSectionLong 
DayOfWeekSectionMask 
DaySectionMask 
DateSectionMask 
Internal 
FirstSection 
LastSection 
CalendarPopupSection 

Definition at line 56 of file qdatetimeparser_p.h.

◆ State

Enumerator
Invalid 
Intermediate 
Acceptable 

Definition at line 106 of file qdatetimeparser_p.h.

Constructor & Destructor Documentation

◆ QDateTimeParser()

QDateTimeParser::QDateTimeParser ( QMetaType::Type t,
Context ctx,
QCalendar cal = QCalendar() )
inline

Definition at line 50 of file qdatetimeparser_p.h.

◆ ~QDateTimeParser()

QDateTimeParser::~QDateTimeParser ( )
virtual

Definition at line 40 of file qdatetimeparser.cpp.

Member Function Documentation

◆ absoluteMax()

int QDateTimeParser::absoluteMax ( int s,
const QDateTime & cur = QDateTime() ) const
protected

Returns the absolute maximum for a section

Definition at line 228 of file qdatetimeparser.cpp.

◆ absoluteMin()

int QDateTimeParser::absoluteMin ( int s) const
protected

Returns the absolute minimum for a section

Definition at line 272 of file qdatetimeparser.cpp.

◆ cursorPosition()

virtual int QDateTimeParser::cursorPosition ( ) const
inlineprotectedvirtual

Reimplemented in QDateTimeEditPrivate.

Definition at line 225 of file qdatetimeparser_p.h.

◆ displayText()

virtual QString QDateTimeParser::displayText ( ) const
inlinevirtual

Reimplemented in QDateTimeEditPrivate.

Definition at line 145 of file qdatetimeparser_p.h.

◆ fieldInfo()

QDateTimeParser::FieldInfo QDateTimeParser::fieldInfo ( int index) const

Definition at line 2032 of file qdatetimeparser.cpp.

◆ fromString() [1/2]

bool QDateTimeParser::fromString ( const QString & text,
QDate * date,
QTime * time,
int baseYear = QLocale::DefaultTwoDigitBaseYear ) const

Definition at line 2253 of file qdatetimeparser.cpp.

◆ fromString() [2/2]

bool QDateTimeParser::fromString ( const QString & text,
QDateTime * datetime,
int baseYear ) const

Definition at line 2279 of file qdatetimeparser.cpp.

◆ getDigit()

int QDateTimeParser::getDigit ( const QDateTime & t,
int index ) const
protected

Gets the digit from a datetime. E.g.

QDateTime var(QDate(2004, 02, 02)); int digit = getDigit(var, Year); digit = 2004

Definition at line 53 of file qdatetimeparser.cpp.

◆ getMaximum()

QDateTime QDateTimeParser::getMaximum ( const QTimeZone & zone) const
protectedvirtual

Reimplemented in QDateTimeEditPrivate.

Definition at line 2309 of file qdatetimeparser.cpp.

◆ getMinimum()

QDateTime QDateTimeParser::getMinimum ( const QTimeZone & zone) const
protectedvirtual

Reimplemented in QDateTimeEditPrivate.

Definition at line 2288 of file qdatetimeparser.cpp.

◆ locale()

virtual QLocale QDateTimeParser::locale ( ) const
inlineprotectedvirtual

Reimplemented in QDateTimeEditPrivate.

Definition at line 226 of file qdatetimeparser_p.h.

◆ parse()

QDateTimeParser::StateNode QDateTimeParser::parse ( const QString & input,
int position,
const QDateTime & defaultValue,
bool fixup ) const

Definition at line 1511 of file qdatetimeparser.cpp.

◆ parseFormat()

bool QDateTimeParser::parseFormat ( QStringView newFormat)

Parses the format newFormat. If successful, returns true and sets up the format. Else keeps the old format and returns false.

Definition at line 430 of file qdatetimeparser.cpp.

◆ sectionMaxSize()

int QDateTimeParser::sectionMaxSize ( int index) const
protected

Definition at line 724 of file qdatetimeparser.cpp.

◆ sectionNode()

const QDateTimeParser::SectionNode & QDateTimeParser::sectionNode ( int sectionIndex) const
protected

Returns the sectionNode for the Section s.

Definition at line 305 of file qdatetimeparser.cpp.

◆ sectionPos() [1/2]

int QDateTimeParser::sectionPos ( int sectionIndex) const
protected

Returns the starting position for section s.

Definition at line 340 of file qdatetimeparser.cpp.

◆ sectionPos() [2/2]

int QDateTimeParser::sectionPos ( SectionNode sn) const
protected

Definition at line 345 of file qdatetimeparser.cpp.

◆ sectionSize()

int QDateTimeParser::sectionSize ( int sectionIndex) const
protected

Returns the size of section s.

Definition at line 611 of file qdatetimeparser.cpp.

◆ sectionText()

QString QDateTimeParser::sectionText ( int sectionIndex) const
protected

Definition at line 773 of file qdatetimeparser.cpp.

◆ sectionType()

QDateTimeParser::Section QDateTimeParser::sectionType ( int index) const
protected

Definition at line 328 of file qdatetimeparser.cpp.

◆ setCalendar()

void QDateTimeParser::setCalendar ( QCalendar cal)

Sets cal as the calendar to use.

The default is Gregorian.

Definition at line 2356 of file qdatetimeparser.cpp.

◆ setDefaultLocale()

void QDateTimeParser::setDefaultLocale ( const QLocale & loc)
inline

Definition at line 144 of file qdatetimeparser_p.h.

◆ setDigit()

bool QDateTimeParser::setDigit ( QDateTime & v,
int index,
int newVal ) const
protected

Sets a digit in a datetime. E.g.

QDateTime var(QDate(2004, 02, 02)); int digit = getDigit(var, Year); digit = 2004 setDigit(&var, Year, 2005); digit = getDigit(var, Year); digit = 2005

Definition at line 123 of file qdatetimeparser.cpp.

◆ skipToNextSection() [1/2]

bool QDateTimeParser::skipToNextSection ( int section,
const QDateTime & current,
const QString & sectionText ) const
inlineprotected

Definition at line 217 of file qdatetimeparser_p.h.

◆ skipToNextSection() [2/2]

bool QDateTimeParser::skipToNextSection ( int index,
const QDateTime & current,
QStringView text ) const
protected

Definition at line 2159 of file qdatetimeparser.cpp.

◆ stateName()

QString QDateTimeParser::stateName ( State s) const
protected

For debugging. Returns the name of the state s.

Definition at line 2227 of file qdatetimeparser.cpp.

Friends And Related Symbol Documentation

◆ QDTPUnitTestParser

friend class QDTPUnitTestParser
friend

Definition at line 199 of file qdatetimeparser_p.h.

Member Data Documentation

◆ cachedDay

int QDateTimeParser::cachedDay = -1
mutableprotected

Definition at line 244 of file qdatetimeparser_p.h.

◆ calendar

QCalendar QDateTimeParser::calendar
protected

Definition at line 253 of file qdatetimeparser_p.h.

◆ context

◆ currentSectionIndex

int QDateTimeParser::currentSectionIndex = int(NoSectionIndex)
mutableprotected

Definition at line 228 of file qdatetimeparser_p.h.

◆ defaultCenturyStart

int QDateTimeParser::defaultCenturyStart = QLocale::DefaultTwoDigitBaseYear
mutableprotected

Definition at line 229 of file qdatetimeparser_p.h.

◆ defaultLocale

QLocale QDateTimeParser::defaultLocale
protected

Definition at line 249 of file qdatetimeparser_p.h.

◆ display

Sections QDateTimeParser::display
protected

Definition at line 230 of file qdatetimeparser_p.h.

◆ displayFormat

QString QDateTimeParser::displayFormat
protected

Definition at line 248 of file qdatetimeparser_p.h.

◆ FirstSectionIndex

int QDateTimeParser::FirstSectionIndex = -2
staticconstexpr

Definition at line 88 of file qdatetimeparser_p.h.

◆ fixday

bool QDateTimeParser::fixday = false
protected

Definition at line 251 of file qdatetimeparser_p.h.

◆ LastSectionIndex

int QDateTimeParser::LastSectionIndex = -3
staticconstexpr

Definition at line 89 of file qdatetimeparser_p.h.

◆ m_text

QString QDateTimeParser::m_text
mutableprotected

Definition at line 245 of file qdatetimeparser_p.h.

◆ NoSectionIndex

QT_BEGIN_NAMESPACE constexpr int QDateTimeParser::NoSectionIndex = -1
staticconstexpr

Definition at line 87 of file qdatetimeparser_p.h.

◆ parserType

QMetaType::Type QDateTimeParser::parserType
protected

Definition at line 250 of file qdatetimeparser_p.h.

◆ sectionNodes

QList<SectionNode> QDateTimeParser::sectionNodes
protected

Definition at line 246 of file qdatetimeparser_p.h.

◆ separators

QStringList QDateTimeParser::separators
protected

Definition at line 247 of file qdatetimeparser_p.h.


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