MXS-1775 Add mxs::[l|r]trimmed_copy(const std::string&)

Make it more convenient to get a left-trimmed, right-trimmed
or trimmed copy of a string.
This commit is contained in:
Johan Wikman 2018-05-21 10:25:57 +03:00
parent 043232990c
commit 498572c671

View File

@ -64,6 +64,49 @@ inline void trim(std::string &s)
rtrim(s);
}
/**
* @brief Left-trimmed copy of a string.
*
* @param s The string to the trimmed.
*
* @return A left-trimmed copy of the string.
*/
inline std::string ltrimmed_copy(const std::string& original)
{
std::string s(original);
ltrim(s);
return s;
}
/**
* @brief Right-trimmed copy of a string.
*
* @param s The string to the trimmed.
*
* @return A right-trimmed copy of the string.
*/
inline std::string rtrimmed_copy(const std::string& original)
{
std::string s(original);
rtrim(s);
return s;
}
/**
* @brief Trimmed copy of a string.
*
* @param s The string to the trimmed.
*
* @return A trimmed copy of the string.
*/
inline std::string trimmed_copy(const std::string& original)
{
std::string s(original);
ltrim(s);
rtrim(s);
return s;
}
/**
* @class CloserTraits utils.hh <maxscale/utils.hh>
*