#include #include "mail.hpp" namespace smtp::file { Mail::Mail( std::string const& path_file ) : mPathFile( path_file ) { } manage::MailsSet Mail::Read() const { std::ifstream mail_file{ mPathFile }; if ( !mail_file.is_open() ) { //TODO new file // std::cerr << "Failed to open pcie_devices database \n"; } std::string line{}; manage::MailsSet result; while ( std::getline( mail_file, line ) ) { auto parsed_data = GetMailFromLine( line ); if( parsed_data ) { result.push_back( *parsed_data ); } } return result; } bool Mail::Write( manage::MailsSet const& data ) const { std::ofstream settings_file{ mPathFile }; if ( !settings_file.is_open() ) { //TODO new file // std::cerr << "Failed to open pcie_devices database \n"; return false; } for( const auto& pair : data ) { settings_file << pair << "\n"; } return true; } std::optional Mail::GetMailFromLine( std::string const& line ) const { //TODO parsing return line; } }