blob: 3580265ac6f763585f2b0315b1f5c41f0e438705 (
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
|
#include "host_number.hpp"
#include "managment/logger.hpp"
#include <stdexcept>
namespace smtp::checker::errors::settings
{
bool HostNumber::Check( const manage::SettingsFileDataType& line ) const
{
//TODO общее использование полей
auto find = line.find("host");
if(find == line.end())
{
manage::Logger::LogError("Host doesn't found");
return false;
}
int host_as_int{};
auto host_as_string = find->second;
if(host_as_string.empty())
{
return true;
}
try
{
host_as_int = std::stoi( host_as_string );
}
catch( std::invalid_argument const& ex )
{
manage::Logger::LogError("Host doesn't entered by numbers");
}
catch( std::out_of_range const& ex )
{
manage::Logger::LogError("Host out of range");
}
return host_as_int >= 0 && host_as_int <= 65535;
}
}
|