/usr/include/barry18/barry/trim.h is in libbarry-dev 0.18.5-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | // Found at:
// http://stackoverflow.com/questions/216823/whats-the-best-way-to-trim-stdstring
// Note that these functions trim the same arguments passed in, and do not
// make copies.
#ifndef __BARRY_TRIM_H__
#define __BARRY_TRIM_H__
#include <stdlib.h>
#include <algorithm>
#include <functional>
#include <locale>
namespace Barry { namespace Inplace {
// Windows CE defines std::isspace(int) as a macro to a function with
// two arguments with one prefilled, so a wrapper function is needed.
static inline int isSpaceChar(int c) {
return std::isspace(c);
}
// trim from start
static inline std::string <rim(std::string &s) {
std::string::iterator end(std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun<int, int>(isSpaceChar))));
s.erase(s.begin(), end);
return s;
}
// trim from end
static inline std::string &rtrim(std::string &s) {
std::string::reverse_iterator start(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<int, int>(isSpaceChar))));
s.erase(start.base(), s.end());
return s;
}
// trim from both ends
static inline std::string &trim(std::string &s) {
return ltrim(rtrim(s));
}
}} // namespace Barry::Inplace
#endif
|