File indexing completed on 2024-05-19 05:49:14

0001 /*
0002     SPDX-FileCopyrightText: 2007 Nicolas Ternisien <nicolas.ternisien@gmail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include <QDateTime>
0010 
0011 #include <QMap>
0012 #include <QString>
0013 
0014 /**
0015  * TODO Fork this class in SyslogParsingHelper and HttpParsingHelper
0016  */
0017 class ParsingHelper
0018 {
0019 public:
0020     static ParsingHelper *instance();
0021 
0022     ~ParsingHelper();
0023 
0024     /**
0025      * Returns the months number represented by the 3 first letters in the QString parameter
0026      */
0027     int parseSyslogMonth(const QString &month);
0028 
0029     QDateTime parseHttpDateTime(const QString &dateTime);
0030 
0031     /*
0032      * TODO Use this method in SyslogAnalyzer, and add a parameter to use the current year instead
0033      * of trying to search it in string
0034      */
0035     QDateTime parseSyslogDateTime(const QString &dateTime);
0036     QString syslogDateTimeRegexp() const;
0037 
0038     QString parseSize(const QString &size);
0039 
0040     QString parseHttpResponse(const QString &response);
0041 
0042     QString parseAgent(const QString &agent);
0043 
0044 private:
0045     explicit ParsingHelper();
0046 
0047     static ParsingHelper *self;
0048 
0049     QMap<QString, int> mMapMonths;
0050 
0051     QMap<QString, QString> mMapHTTPResponse;
0052 };