File indexing completed on 2024-12-29 04:51:07
0001 /* 0002 SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org> 0003 SPDX-License-Identifier: LGPL-2.0-or-later 0004 */ 0005 0006 #ifndef KITINERARY_TIMEFINDER_H 0007 #define KITINERARY_TIMEFINDER_H 0008 0009 class QStringView; 0010 0011 #include <QVariant> 0012 0013 #include <vector> 0014 0015 namespace KItinerary { 0016 0017 /** Attempts to find time values in all locales mentioned in the given text. */ 0018 class TimeFinder 0019 { 0020 public: 0021 /** Search for all occurences of date/time values in @p text. */ 0022 void find(QStringView text); 0023 0024 /** Like the above, but assume there is exactly one time value in @p text. 0025 * If anything else is found, returns an invalid QTime. 0026 */ 0027 QTime findSingularTime(QStringView text); 0028 0029 struct Result { 0030 int begin = -1; 0031 int end = -1; 0032 QVariant dateTime; 0033 }; 0034 0035 const std::vector<Result>& results() const; 0036 0037 private: 0038 void findTimes(QStringView text); 0039 void findDates(QStringView text); 0040 void mergeResults(); 0041 0042 std::vector<Result> m_results; 0043 }; 0044 0045 } 0046 0047 #endif // KITINERARY_TIMEFINDER_H