summaryrefslogtreecommitdiff
path: root/src/file/mail.cpp
diff options
context:
space:
mode:
authorclaiff <claiff@mail.ru>2022-09-19 19:25:16 +0300
committerclaiff <claiff@mail.ru>2022-09-20 12:44:34 +0300
commit7485f26f35c9cfc1489a2e425fee57a2b51059a9 (patch)
treea29ccecb6fba0b0b0f4ad3a1f6e12b429434fb77 /src/file/mail.cpp
parent7fd7a6488625acc45b48ca21d55ed13783cae27f (diff)
downloadobmc-sila-smtp-7485f26f35c9cfc1489a2e425fee57a2b51059a9.tar.xz
add logger journal and phosphor
Diffstat (limited to 'src/file/mail.cpp')
-rw-r--r--src/file/mail.cpp102
1 files changed, 51 insertions, 51 deletions
diff --git a/src/file/mail.cpp b/src/file/mail.cpp
index 5452136..1453535 100644
--- a/src/file/mail.cpp
+++ b/src/file/mail.cpp
@@ -1,63 +1,63 @@
#include <fstream>
#include "mail.hpp"
-#include "managment/logger.hpp"
+#include "logger/logger_set.hpp"
namespace smtp::file
{
- Mail::Mail( std::string const& path_file )
- : mPathFile( path_file )
- {
- }
+ Mail::Mail( std::string const& path_file )
+ : mPathFile( path_file )
+ {
+ }
- manage::MailsSet Mail::Read() const
- {
- std::ifstream mail_file{ mPathFile, std::fstream::in };
- if ( !mail_file.is_open() )
- {
- manage::Logger::LogError( "Unable to open file to read " + mPathFile );
- return {};
- }
- std::string line{};
- manage::MailsSet result;
+ manage::MailsSet Mail::Read() const
+ {
+ std::ifstream mail_file{mPathFile, std::fstream::in};
+ if( !mail_file.is_open())
+ {
+ logger::LoggerSet::GetInstance()->LogError( "Unable to open file to read " + mPathFile );
+ return {};
+ }
+ 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 );
- }
- }
- mail_file.close();
- return result;
- }
+ while( std::getline( mail_file, line ))
+ {
+ auto parsed_data = GetMailFromLine( line );
+ if( parsed_data )
+ {
+ result.push_back( *parsed_data );
+ }
+ }
+ mail_file.close();
+ return result;
+ }
- bool Mail::Write( manage::MailsSet const& data ) const
- {
- std::ofstream mail_file{ mPathFile, std::fstream::out | std::fstream::trunc };
- if ( !mail_file.is_open() )
- {
- manage::Logger::LogError( "Unable to open file to write " + mPathFile );
- return false;
- }
- for( const auto& pair : data )
- {
- mail_file << pair << "\n";
- }
- mail_file.close();
- return true;
- }
+ bool Mail::Write( manage::MailsSet const& data ) const
+ {
+ std::ofstream mail_file{mPathFile, std::fstream::out | std::fstream::trunc};
+ if( !mail_file.is_open())
+ {
+ logger::LoggerSet::GetInstance()->LogError( "Unable to open file to write " + mPathFile );
+ return false;
+ }
+ for( const auto& pair: data )
+ {
+ mail_file << pair << "\n";
+ }
+ mail_file.close();
+ return true;
+ }
- std::optional<std::string> Mail::GetMailFromLine( std::string const& line ) const
- {
- //TODO registrator if checking parsing
- auto pos = line.find('@');
- if(pos == std::string::npos)
- {
- return {};
- }
- return line;
- }
+ std::optional < std::string > Mail::GetMailFromLine( std::string const& line ) const
+ {
+ //TODO registrator if checking parsing
+ auto pos = line.find( '@' );
+ if( pos == std::string::npos )
+ {
+ return {};
+ }
+ return line;
+ }
}