School Commit Init

This commit is contained in:
2024-08-31 12:07:21 +03:00
commit 0b130ee18c
2801 changed files with 4720552 additions and 0 deletions
@@ -0,0 +1,33 @@
#include "ParticipantRepo.h"
#include <stdexcept>
#include <fstream>
ParticipantRepo::ParticipantRepo(std::string file_name)
{
this->_file_name = file_name;
this->read_from_file();
}
std::vector<Participant> ParticipantRepo::get_all()
{
return this->_participants;
}
int ParticipantRepo::size()
{
return this->_participants.size();
}
void ParticipantRepo::read_from_file()
{
std::ifstream file(this->_file_name);
if(!file.is_open())
throw std::runtime_error("File could not be opened!");
std::string line;
while(std::getline(file, line) && !line.empty())
{
Participant p(line);
this->_participants.push_back(p);
}
file.close();
}