#include "filewriter.h"
#include <QString>
#include <QDebug>

void FileWriter::writeImageName(QString line){

    if(!(createfileabstraction->getFile())->isOpen()){
        qDebug()<<"Error!!!, unable to open the file";
    }

    outStream<<line<<"\r\n";
}

void FileWriter::writeFilePoint(int pointx,int pointy)
{
    if(!(createfileabstraction->getFile())->isOpen()){
        qDebug()<<"Error!!!, unable to open the file";
    }

    outStream<<" x: "<<pointx<<" y: "<<pointy;
}

void FileWriter::writeFileRectangleId(int id){

    if(!(createfileabstraction->getFile())->isOpen()){
        qDebug()<<"Error!!!, unable to open the file";
    }

    outStream<<"ID: "<<id;
}

void FileWriter::writeFileRectangleGeo(int width,int height){

    if(!(createfileabstraction->getFile())->isOpen()){
        qDebug()<<"Error!!!, unable to open the file";
    }

    outStream<<" w: "<<width<<" h: "<<height;
}

void FileWriter::writeComment(QString comment){

    if(!(createfileabstraction->getFile())->isOpen()){
        qDebug()<<"Error!!!, unable to open the file";
    }

    outStream<<" c: "<<comment;
}

void FileWriter::changeLine(){

    if(!(createfileabstraction->getFile())->isOpen()){
        qDebug()<<"Error!!!, unable to open the file";
    }

    // \r\n is the change line operation for Windows. Change it according
    // to the Operating System.
    outStream<<"\r\n";
    outStream.flush();
}

void FileWriter::writeWordNumber(QString word){

    if(!(createfileabstraction->getFile())->isOpen()){
        qDebug()<<"Error!!!, unable to open the file";
    }

    outStream<<" wn: "<<word;

}

void FileWriter::writeLineNumber(QString line){

    if(!(createfileabstraction->getFile())->isOpen()){
        qDebug()<<"Error!!!, unable to open the file";
    }

    outStream<<" ln: "<<line;
}

CreateFileAbstraction* FileWriter::getCreateFileAbstraction()const{
    return createfileabstraction;
}
