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:
@ -64,6 +64,49 @@ inline void trim(std::string &s)
|
|||||||
rtrim(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>
|
* @class CloserTraits utils.hh <maxscale/utils.hh>
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user