mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Add general delimiter split() to rfc2616
This commit is contained in:
@@ -165,9 +165,11 @@ trim (std::string const& s)
|
|||||||
http://www.w3.org/Protocols/rfc2616/rfc2616-sec2.html#sec2
|
http://www.w3.org/Protocols/rfc2616/rfc2616-sec2.html#sec2
|
||||||
*/
|
*/
|
||||||
template <class FwdIt,
|
template <class FwdIt,
|
||||||
class Result = std::vector<std::basic_string<typename FwdIt::value_type>>>
|
class Result = std::vector<
|
||||||
|
std::basic_string<typename FwdIt::value_type>>,
|
||||||
|
class Char>
|
||||||
Result
|
Result
|
||||||
split_commas(FwdIt first, FwdIt last)
|
split(FwdIt first, FwdIt last, Char delim)
|
||||||
{
|
{
|
||||||
Result result;
|
Result result;
|
||||||
using string = typename Result::value_type;
|
using string = typename Result::value_type;
|
||||||
@@ -206,7 +208,7 @@ split_commas(FwdIt first, FwdIt last)
|
|||||||
e.clear();
|
e.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (*iter == ',')
|
else if (*iter == delim)
|
||||||
{
|
{
|
||||||
e = trim_right (e);
|
e = trim_right (e);
|
||||||
if (! e.empty())
|
if (! e.empty())
|
||||||
@@ -235,6 +237,15 @@ split_commas(FwdIt first, FwdIt last)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class FwdIt,
|
||||||
|
class Result = std::vector<
|
||||||
|
std::basic_string<typename FwdIt::value_type>>>
|
||||||
|
Result
|
||||||
|
split_commas(FwdIt first, FwdIt last)
|
||||||
|
{
|
||||||
|
return split(first, last, ',');
|
||||||
|
}
|
||||||
|
|
||||||
template <class Result = std::vector<std::string>>
|
template <class Result = std::vector<std::string>>
|
||||||
Result
|
Result
|
||||||
split_commas(std::string const& s)
|
split_commas(std::string const& s)
|
||||||
|
|||||||
Reference in New Issue
Block a user