#pragma once

#include <QObject>

//class StdOutRedirector : public QObject
//{
//	Q_OBJECT
//
//public:
//	StdOutRedirector(QObject *parent);
//	~StdOutRedirector();
//};


#include <QString>
#include <iostream>
#include <stdio.h>
#include <fcntl.h>
#include <QTextEdit>

#ifdef __linux__
#include <unistd.h>
#else
#include <io.h>
#endif

class StdOutRedirector : public QObject
{
	Q_OBJECT
public:
	StdOutRedirector();
	~StdOutRedirector();
	void setOutputTF(QTextEdit* _output)
	{
		output = _output;
	}

public slots:
	void readOutsToTF();

private:
	QTextEdit* output;
	int fdStdOut;
	int fdguistd[2];
	char* buffer = nullptr;
	const int bufferSize = 4096;
};
