diff options
Diffstat (limited to 'src/file/converter/settings.cpp')
-rw-r--r-- | src/file/converter/settings.cpp | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/src/file/converter/settings.cpp b/src/file/converter/settings.cpp new file mode 100644 index 0000000..809eef8 --- /dev/null +++ b/src/file/converter/settings.cpp @@ -0,0 +1,65 @@ +#include "settings.hpp" + +namespace smtp::file::converter +{ + + ParsedDataType Settings::Convert( manage::SettingsFields const& from ) const + { + ParsedDataType result; + + ApplyPort( from, result ); + ApplyHost( from, result ); + ApplyPassword( from, result ); + ApplyUsername( from, result ); + ApplySsl( from, result ); + ApplyAuth( from, result ); + + return result; + } + + void Settings::ApplyAuth( manage::SettingsFields const& from, ParsedDataType& result ) const + { + static const std::string FIELD = "need_auth"; + static const std::string TRUE_AS_STRING = "true"; + static const std::string FALSE_AS_STRING = "false"; + + from.is_need_auth ? result.insert({FIELD, TRUE_AS_STRING}) : result.insert({FIELD, FALSE_AS_STRING}); + } + + void Settings::ApplySsl( manage::SettingsFields const& from, ParsedDataType& result ) const + { + static const std::string FIELD = "need_ssl"; + static const std::string TRUE_AS_STRING = "true"; + static const std::string FALSE_AS_STRING = "false"; + + from.is_need_ssl ? result.insert({FIELD, TRUE_AS_STRING}) : result.insert({FIELD, FALSE_AS_STRING}); + } + + void Settings::ApplyUsername( manage::SettingsFields const& from, ParsedDataType& result ) const + { + static const std::string FIELD = "username"; + + result.insert({FIELD, from.username}); + } + + void Settings::ApplyPassword( manage::SettingsFields const& from, ParsedDataType& result ) const + { + static const std::string FIELD = "password"; + + result.insert({FIELD, from.password}); + } + + void Settings::ApplyHost( manage::SettingsFields const& from, ParsedDataType& result ) const + { + static const std::string FIELD = "host"; + + result.insert({FIELD, from.host}); + } + + void Settings::ApplyPort( manage::SettingsFields const& from, ParsedDataType& result ) const + { + static const std::string FIELD = "port"; + + result.insert({FIELD, from.port}); + } +} |