diff options
Diffstat (limited to 'src/file/parser')
-rw-r--r-- | src/file/parser/settings.cpp | 20 | ||||
-rw-r--r-- | src/file/parser/settings.hpp | 19 |
2 files changed, 39 insertions, 0 deletions
diff --git a/src/file/parser/settings.cpp b/src/file/parser/settings.cpp new file mode 100644 index 0000000..590ed72 --- /dev/null +++ b/src/file/parser/settings.cpp @@ -0,0 +1,20 @@ +#include "settings.hpp" + +namespace smtp::file::parser +{ + ParseResult Settings::Parse( std::string const& line ) const + { + static constexpr char DELIMITER = '='; + static constexpr size_t ZERO_POSITION = 0; + static constexpr size_t NEXT_POSITION = 1; + + auto position = line.find(DELIMITER); + if( position == std::string::npos) + { + return {}; + } + auto first_part = line.substr( ZERO_POSITION, position ); + auto second_part = line.substr(position + NEXT_POSITION, line.length()); + return {first_part, second_part}; + } +} diff --git a/src/file/parser/settings.hpp b/src/file/parser/settings.hpp new file mode 100644 index 0000000..e7de2f6 --- /dev/null +++ b/src/file/parser/settings.hpp @@ -0,0 +1,19 @@ +#pragma once + +#include <utility> +#include <string> + +namespace smtp::file::parser +{ + using ParseResult = std::pair<std::string,std::string>; + + class Settings + { + public: + Settings() = default; + ~Settings() = default; + + ParseResult Parse( std::string const& line ) const; + }; + +} |