summaryrefslogtreecommitdiff
path: root/src/file/settings/checker_decorator.cpp
blob: ef560ad266143be21946908346f8e286612c801a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "checker_decorator.hpp"

namespace smtp::file::settings
{

	//
	//Constructors
	//

    CheckerDecorator::CheckerDecorator( checker::RegistratorSettings const& registrator_errors )
            : mRegistratorErrors( registrator_errors )
	{
	}

	//
	//Public methods
	//

    manage::SettingsFileDataType CheckerDecorator::Read() const
	{
        manage::SettingsFileDataType result;
        if(!mBase)
        {
            return result;
        }
        result = mBase->Read();
        return mRegistratorErrors.Check( result ) ? result : manage::SettingsFileDataType{};
	}

    bool CheckerDecorator::Write( manage::SettingsFileDataType const& settings_fields ) const
	{
        if( !mBase )
        {
            return false;
        }
        if( mRegistratorErrors.Check( settings_fields ) )
        {
            return mBase->Write(settings_fields);
        }
        return false;
	}
}