#ifndef DATAPARSER_H
#define DATAPARSER_H


#include "Systems/processingsystem.h"
#include "Systems/tools.h"
#include "logger.h"
#include "serverlmswidget.h"
#include "typesDataServerClient.h"

#include <QByteArray>
#include <QXmlStreamReader>
#include <QDebug>

class ProcessingSystem;
class ClientHandler;

class DataParser : public QObject
{

  Q_OBJECT
public:
    DataParser(ProcessingSystem *processingSystem,QObject* parent = nullptr);
    void xmlParser(ClientHandler *client, QByteArray array);
    void xmlFileDataParse(QByteArray array);

    QByteArray xmlAnswer(QList<SXmlAnswerTag> listTag,QString elemUp1 = "", QString elemUp2 = "");
    QByteArray xmlAnswer_authorization(bool result, QString instructorName, QString clientName, QString accessType);
    QByteArray xmlAnswer_message(QString text);
    QByteArray xmlAnswer_task(QString text);
    QByteArray xmlAnswer_notify(QString code);
    QByteArray xmlAnswer_tasks(QStringList listTasks);
    DataInfo *getCurrentDataInfo();
    void clearCurrentDataInfo();
    ~DataParser();

    QList<FileData> *getDatas() const;

signals:
    void sigLogMessage(QString log);

private:
    QMutex *mutex;
    QList<FileData> *datas;
    ProcessingSystem *processingSystem;
    DataInfo *dataInfo;
};

#endif // DATAPARSER_H
