diff options
Diffstat (limited to 'src/file/mail.cpp')
-rw-r--r-- | src/file/mail.cpp | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/file/mail.cpp b/src/file/mail.cpp index 14e6228..4da36c5 100644 --- a/src/file/mail.cpp +++ b/src/file/mail.cpp @@ -5,21 +5,21 @@ namespace smtp::file { Mail::Mail( std::string const& path_file ) - : PathFile( path_file ) + : mPathFile( path_file ) { } - std::list<std::string> Mail::Read() const + manage::MailsSet Mail::Read() const { - std::ifstream mail_file{ PathFile }; + 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{}; - std::list<std::string> result; + manage::MailsSet result; while ( std::getline( mail_file, line ) ) { @@ -32,6 +32,22 @@ namespace smtp::file 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<std::string> Mail::GetMailFromLine( std::string const& line ) const { //TODO parsing |