2010-11-13 23:59:23 +00:00
|
|
|
#ifndef S3FS_STRING_UTIL_H_
|
|
|
|
#define S3FS_STRING_UTIL_H_
|
|
|
|
|
|
|
|
/*
|
|
|
|
* A collection of string utilities for manipulating URLs and HTTP responses.
|
|
|
|
*/
|
|
|
|
#include <sstream>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#define SPACES " \t\r\n"
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
template<typename T> string str(T value) {
|
|
|
|
stringstream tmp;
|
|
|
|
tmp << value;
|
|
|
|
return tmp.str();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline string trim_left(const string &s, const string &t = SPACES) {
|
|
|
|
string d(s);
|
|
|
|
return d.erase(0, s.find_first_not_of(t));
|
|
|
|
}
|
|
|
|
|
|
|
|
inline string trim_right(const string &s, const string &t = SPACES) {
|
|
|
|
string d(s);
|
|
|
|
string::size_type i(d.find_last_not_of(t));
|
|
|
|
if (i == string::npos)
|
|
|
|
return "";
|
|
|
|
else
|
|
|
|
return d.erase(d.find_last_not_of(t) + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline string trim(const string &s, const string &t = SPACES) {
|
|
|
|
string d(s);
|
|
|
|
return trim_left(trim_right(d, t), t);
|
|
|
|
}
|
|
|
|
|
|
|
|
string lower(string s);
|
2010-12-21 15:24:46 +00:00
|
|
|
string IntToStr(int);
|
|
|
|
|
2010-11-13 23:59:23 +00:00
|
|
|
|
|
|
|
#endif // S3FS_STRING_UTIL_H_
|