summaryrefslogtreecommitdiff
path: root/src/file/mail/checker_decorator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/file/mail/checker_decorator.cpp')
-rw-r--r--src/file/mail/checker_decorator.cpp58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/file/mail/checker_decorator.cpp b/src/file/mail/checker_decorator.cpp
new file mode 100644
index 0000000..54da9da
--- /dev/null
+++ b/src/file/mail/checker_decorator.cpp
@@ -0,0 +1,58 @@
+#include "checker_decorator.hpp"
+#include "logger/logger_set.hpp"
+
+namespace smtp::file::mail
+{
+
+ //
+ //Constructors
+ //
+
+ CheckerDecorator::CheckerDecorator( checker::RegistratorMails const& registrator_errors )
+ : mRegistratorErrors( registrator_errors )
+ {
+ }
+
+ //
+ //Public methods
+ //
+
+ manage::MailsSet CheckerDecorator::Read() const
+ {
+ manage::MailsSet result;
+
+ if( !mBase )
+ {
+ return result;
+ }
+
+ auto parsed_data = mBase->Read();
+
+ for( auto const& line : parsed_data )
+ {
+ if( mRegistratorErrors.Check( line ) )
+ {
+ result.push_back( line );
+ }
+ }
+ return result;
+ }
+
+ bool CheckerDecorator::Write( manage::MailsSet const& data ) const
+ {
+ manage::MailsSet result;
+
+ for( const auto& line : data )
+ {
+ if( mRegistratorErrors.Check( line ) )
+ {
+ result.push_back( line );
+ }
+ }
+ if( mBase )
+ {
+ return mBase->Write(result);
+ }
+ return false;
+ }
+}