#ifndef QMK_PARSER_H
#define QMK_PARSER_H

#include <qstringlist.h>
#include <qvector.h>

class qmk_parser
{
public:
    qmk_parser();
    ~qmk_parser();

    // Parsing of all needed qmk files. If parsing finishes processing without errors, returns zero-size str, else returns error description
    QString parseFiles(QString mainLayout, QString revLayout, QString mainConfig, QString revConfig, QString keymapConfig, QString keymap, QString keycodes, bool ignoreUndefinedKeys = true);

    QStringList findMacro(QString src);
    QStringList parseMacro(QString macro);

    QString deleteCommentsAndStrings(QString src, bool deleteStrings = true);

    QString findExpression(QString src, QString expression);

    QStringList findEnums(QString src);

    QString getEnumName(QString enumSrc);
    QVector<QVector<QString>> getEnumValues(QString src);   //  val 0 - name, val 1 - number in text format

    QString setMacroToExpression(QString expression, QVector<QStringList> macroList);

    QVector<QString> parseOneDimArr(QString arr);
    QVector<QVector<QString>> parseTwoDimArr(QString arr);
    QVector<QVector<QVector<QString>>> parseThreeDimArr(QString arr);

    int strToNum(QString s);

    QVector<QString> getColumns();
    QVector<QString> getRows();
    QVector<QVector<int>> getMatrix();
    QVector<QVector<int>> getFnMatrix();
    int getDiodeDirection();

private:

    bool m_isError;
    QVector<QString> m_Columns;
    QVector<QString> m_Rows;
    int m_diodeDirection;
    QVector<QVector<int> > m_Matrix;
    QVector<QVector<int> > m_FnMatrix;

};

#endif // QMK_PARSER_H
