diff options
author | claiff <claiff@mail.ru> | 2022-10-05 15:57:43 +0300 |
---|---|---|
committer | claiff <claiff@mail.ru> | 2022-10-05 15:57:43 +0300 |
commit | 43e721305c866ad4b2c4c35d1133f169e41dd49b (patch) | |
tree | c7ae9c113d29aa3350eca04f27a933bd3b5f769c /src/file/mail/checker_decorator.cpp | |
parent | 9ed43c1057eeec6a01b8fdfd4d2ee54f9df39670 (diff) | |
download | obmc-sila-smtp-43e721305c866ad4b2c4c35d1133f169e41dd49b.tar.xz |
file reader/writer split by decorators
Diffstat (limited to 'src/file/mail/checker_decorator.cpp')
-rw-r--r-- | src/file/mail/checker_decorator.cpp | 58 |
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; + } +} |