MXS-2208 Now use trim() from maxbase
This commit is contained in:
@ -15,6 +15,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
#include <maxbase/assert.h>
|
#include <maxbase/assert.h>
|
||||||
|
#include <maxbase/string.hh>
|
||||||
|
|
||||||
using std::map;
|
using std::map;
|
||||||
using std::string;
|
using std::string;
|
||||||
@ -22,27 +23,6 @@ using std::string;
|
|||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
// TODO: Remove once trim is in maxbase.
|
|
||||||
// trim from beginning (in place)
|
|
||||||
inline void ltrim(std::string &s) {
|
|
||||||
s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](int ch) {
|
|
||||||
return !std::isspace(ch);
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
// trim from end (in place)
|
|
||||||
inline void rtrim(std::string &s) {
|
|
||||||
s.erase(std::find_if(s.rbegin(), s.rend(), [](int ch) {
|
|
||||||
return !std::isspace(ch);
|
|
||||||
}).base(), s.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
// trim from both ends (in place)
|
|
||||||
inline void trim(std::string &s) {
|
|
||||||
ltrim(s);
|
|
||||||
rtrim(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline void checked_curl_setopt(CURL* pCurl, CURLoption option, T value)
|
inline void checked_curl_setopt(CURL* pCurl, CURLoption option, T value)
|
||||||
{
|
{
|
||||||
@ -84,8 +64,8 @@ size_t header_callback(char* ptr, size_t size, size_t nmemb, void* userdata)
|
|||||||
string key(ptr, i - ptr);
|
string key(ptr, i - ptr);
|
||||||
++i;
|
++i;
|
||||||
string value(i, end - i);
|
string value(i, end - i);
|
||||||
trim(key);
|
mxb::trim(key);
|
||||||
trim(value);
|
mxb::trim(value);
|
||||||
pHeaders->insert(std::make_pair(key, value));
|
pHeaders->insert(std::make_pair(key, value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user