summaryrefslogtreecommitdiff
path: root/src/checker/errors
diff options
context:
space:
mode:
Diffstat (limited to 'src/checker/errors')
-rw-r--r--src/checker/errors/mail/empty.cpp9
-rw-r--r--src/checker/errors/mail/empty.hpp17
-rw-r--r--src/checker/errors/settings/host_number.cpp36
-rw-r--r--src/checker/errors/settings/host_number.hpp17
-rw-r--r--src/checker/errors/types/imails_error.hpp19
-rw-r--r--src/checker/errors/types/isettings_error.hpp22
6 files changed, 120 insertions, 0 deletions
diff --git a/src/checker/errors/mail/empty.cpp b/src/checker/errors/mail/empty.cpp
new file mode 100644
index 0000000..06f6f4c
--- /dev/null
+++ b/src/checker/errors/mail/empty.cpp
@@ -0,0 +1,9 @@
+#include "empty.hpp"
+
+namespace smtp::checker::errors::settings
+{
+ bool Empty::Check( std::string const& line ) const
+ {
+ return !line.empty();
+ }
+}
diff --git a/src/checker/errors/mail/empty.hpp b/src/checker/errors/mail/empty.hpp
new file mode 100644
index 0000000..9e8c0da
--- /dev/null
+++ b/src/checker/errors/mail/empty.hpp
@@ -0,0 +1,17 @@
+#pragma once
+
+#include "checker/errors/types/imails_error.hpp"
+
+namespace smtp::checker::errors::settings
+{
+ class Empty : public types::IError
+ {
+ public:
+ Empty() = default;
+ ~Empty() override = default;
+
+ bool Check( std::string const& line ) const override;
+ };
+}
+
+
diff --git a/src/checker/errors/settings/host_number.cpp b/src/checker/errors/settings/host_number.cpp
new file mode 100644
index 0000000..3580265
--- /dev/null
+++ b/src/checker/errors/settings/host_number.cpp
@@ -0,0 +1,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;
+ }
+}
diff --git a/src/checker/errors/settings/host_number.hpp b/src/checker/errors/settings/host_number.hpp
new file mode 100644
index 0000000..1f2bfe7
--- /dev/null
+++ b/src/checker/errors/settings/host_number.hpp
@@ -0,0 +1,17 @@
+#pragma once
+
+#include "checker/errors/types/isettings_error.hpp"
+
+namespace smtp::checker::errors::settings
+{
+ class HostNumber : public types::IErrorSettings
+ {
+ public:
+ HostNumber() = default;
+ ~HostNumber() override = default;
+
+ virtual bool Check( const manage::SettingsFileDataType& line ) const override;
+ };
+}
+
+
diff --git a/src/checker/errors/types/imails_error.hpp b/src/checker/errors/types/imails_error.hpp
new file mode 100644
index 0000000..d696bbd
--- /dev/null
+++ b/src/checker/errors/types/imails_error.hpp
@@ -0,0 +1,19 @@
+#pragma once
+
+#include <memory>
+#include <string>
+
+namespace smtp::checker::errors::types
+{
+ class IError
+ {
+ public:
+ IError() = default;
+ virtual ~IError() = default;
+
+ virtual bool Check( std::string const& line ) const = 0;
+ };
+ using IErrorPtr = std::shared_ptr<IError>;
+}
+
+
diff --git a/src/checker/errors/types/isettings_error.hpp b/src/checker/errors/types/isettings_error.hpp
new file mode 100644
index 0000000..d5a788f
--- /dev/null
+++ b/src/checker/errors/types/isettings_error.hpp
@@ -0,0 +1,22 @@
+//
+// Created by claiff on 18.09.22.
+//
+
+#pragma once
+
+#include <memory>
+
+#include "managment/general.hpp"
+
+namespace smtp::checker::errors::types
+{
+ class IErrorSettings
+ {
+ public:
+ IErrorSettings() = default;
+ virtual ~IErrorSettings() = default;
+
+ virtual bool Check( manage::SettingsFileDataType const& line ) const = 0;
+ };
+ using IErrorSettingsPtr = std::shared_ptr<IErrorSettings>;
+} \ No newline at end of file