summaryrefslogtreecommitdiff
path: root/src/file/mail.cpp
diff options
context:
space:
mode:
authoreportnov <eportnov@ibs.ru>2022-09-13 15:03:29 +0300
committereportnov <eportnov@ibs.ru>2022-09-13 15:03:29 +0300
commitbab12f829beb53feb6f48db7a0ef33574740989c (patch)
treeb99540f810072b746d033d6cd8d06aabb75afcad /src/file/mail.cpp
parenta58088ec7a45bb86b155a8ef9514b35b0ba8d1c9 (diff)
parente8aeea36e6b48e18d27f9d7857cd29524cc8aa1f (diff)
downloadobmc-sila-smtp-bab12f829beb53feb6f48db7a0ef33574740989c.tar.xz
Merge branch 'bugfix/write_file'
Diffstat (limited to 'src/file/mail.cpp')
-rw-r--r--src/file/mail.cpp24
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