#include "pch.h"
#include "DataReader.h"
#include <fstream>
#include <string>

DataReader::DataReader()
{
	std::locale().global(std::locale("rus"));
}

double * DataReader::GetValues()
{
	string line;
	ifstream in("csrA.csv");

	if (in.is_open())
	{
		while (getline(in, line))
		{
			_values.push_back(stod(line));
		}
	}
	in.close();

	return &_values[0];
}

int * DataReader::GetRows()
{
	string line;
	ifstream in("csrRowPtr.csv");

	if (in.is_open())
	{
		while (getline(in, line))
		{
			_rows.push_back(stoi(line));
		}
	}
	in.close();

	return &_rows[0];
}

int * DataReader::GetColumns()
{
	string line;
	ifstream in("csrColInd.csv");

	if (in.is_open())
	{
		while (getline(in, line))
		{
			_columns.push_back(stoi(line));
		}
	}
	in.close();

	return &_columns[0];
}

double * DataReader::GetRHS()
{
	string line;
	ifstream in("rhs.csv");

	if (in.is_open())
	{
		while (getline(in, line))
		{
			_rhs.push_back(stod(line));
		}
	}
	in.close();

	return &_rhs[0];
}

DataReader::~DataReader()
{
}
