diff options
author | eportnov <eportnov@ibs.ru> | 2022-09-13 11:13:38 +0300 |
---|---|---|
committer | eportnov <eportnov@ibs.ru> | 2022-09-13 11:13:38 +0300 |
commit | a58088ec7a45bb86b155a8ef9514b35b0ba8d1c9 (patch) | |
tree | 95a796ba075edb1abf4edea29a11544fa7344754 /src/file/settings_converter.hpp | |
parent | df33492b80495fd36a1a488c0b0a39753f1df415 (diff) | |
parent | dcbaf61e4968734d9b3bc41f704ea04d54746cea (diff) | |
download | obmc-sila-smtp-a58088ec7a45bb86b155a8ef9514b35b0ba8d1c9.tar.xz |
Merge branch 'feature/mail_user_managment'
Diffstat (limited to 'src/file/settings_converter.hpp')
-rw-r--r-- | src/file/settings_converter.hpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/file/settings_converter.hpp b/src/file/settings_converter.hpp new file mode 100644 index 0000000..36041c3 --- /dev/null +++ b/src/file/settings_converter.hpp @@ -0,0 +1,41 @@ +#pragma once + +#include <unordered_map> +#include <string> + +namespace smtp::file +{ + struct SettingsFields + { + bool is_need_auth; + bool is_need_ssl; + std::string username; + std::string password; + std::string host; + std::string port; + }; + + using ParsedDataType = std::unordered_map<std::string, std::string>;; + + class SettingsConverter + { + public: + SettingsConverter() = default; + ~SettingsConverter() = default; + + SettingsFields Convert( std::unordered_map<std::string, std::string> const& from ) const; + std::unordered_map<std::string, std::string> Convert( SettingsFields const& from ) const; + private: + void ApplyAuth( SettingsFields& result, ParsedDataType const& from ) const; + void ApplySsl( SettingsFields& result, ParsedDataType const& from ) const; + void ApplyBool( ParsedDataType const& from, std::string const& search_field, bool& field ) const; + + void ApplyUsername( SettingsFields& result, ParsedDataType const& from ) const; + void ApplyPassword( SettingsFields& result, ParsedDataType const& from ) const; + void ApplyHost( SettingsFields& result, ParsedDataType const& from ) const; + void ApplyPort( SettingsFields& result, ParsedDataType const& from ) const; + void ApplyString( ParsedDataType const& from, std::string const& search_field, std::string& field ) const; + }; +} + + |