summaryrefslogtreecommitdiff
path: root/src/file/settings/parser.cpp
blob: b692ac3761266d1e6868e4d09ada0add392e162f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include "parser.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};
    }
}