예제 #1
0
/*
 * Split a string into multiple strings when a character is met.
 * Returns all tokens in an array.
 */
std::vector<std::string> util::split_string(const std::experimental::string_view &str, const char c)
{
    assert(!str.empty());
    assert(c);

    using std::experimental::string_view;
    std::vector<std::string> result;

    for (string_view::const_iterator len = str.begin(); len <= str.end(); len++) {
        string_view::const_iterator token_start = len;

        while (*len != c && *len)
            len++;

        result.emplace_back(token_start, len);
    }

    return result;
}
예제 #2
0
	Exception::Exception(ErrorCode error_id, std::experimental::string_view information) :
		m_error_id{error_id},
		m_information{information.begin(), information.end()}
	{}