/*
  This file is part of Lokalize

  SPDX-FileCopyrightText: 2022 Andreas Cord-Landwehr <cordlandwehr@kde.org>
  SPDX-FileCopyrightText: 2026 Varun Sajith Dass <varunsajithdas@gmail.com>

  SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/

#ifndef GETTEXTHEADERPARSER_H
#define GETTEXTHEADERPARSER_H

#include <QString>

/**
 * @brief The GetTextHeaderParser class
 *
 * This class operates on the file header that is represented as a list of lines.
 * The list itself should be generated by splitting the obtained file header by newlines.
 */
class GetTextHeaderParser
{
public:
    static void updateLastTranslator(QStringList &headerList, const QString &authorName, const QString &authorEmail);
    static void updateGeneralCopyrightYear(QStringList &commentList);
    static void updateAuthors(QStringList &commentList, const QString &authorName, const QString &authorEmail);
    static QString joinAuthor(const QString &authorName, const QString &authorEmail);
    /**
     * Parse the copyright line and return updated SPDX compatible license line with updated year
     *
     * This function performs no operation if the current year (due to system time) is already present in string.
     * The returned line is prefixed by a "#" comment marker.
     */
    static QString updateAuthorCopyrightLine(const QString &line);

    /**
     * Simplifies a list of copyright years by sorting them and grouping consecutive years.
     * Example: "2020, 2021, 2022" -> "2020-2022"
     * @param years The raw string of years (e.g. from regex capture)
     * @return The formatted, simplified string
     */
    static QString simplifyYearString(const QString &years);
    static const QString sCurrentYear;
};

#endif
