58 std::string
ltrim(
const std::string &
str,
const std::string &whitespace =
"\t ");
60 std::string
rtrim(
const std::string &str,
const std::string &whitespace =
"\t ");
62 std::string
trim(
const std::string &str,
const std::string &whitespace =
"\t ");
64 char *
trim(
char *txt);
66 char *
trim(
char *dest,
const char *src);
69 std::string
pad(
const std::string &s,
size_t n,
char c =
' ');
72 std::string
unescape(
const std::string &str);
75 inline std::string
tolower(
const std::string &s) { std::string o(s); FOREACH2(std::string::iterator, o) { *i =
::tolower(*i); };
return o; }
77 inline std::string
toupper(
const std::string &s) { std::string o(s); FOREACH2(std::string::iterator, o) { *i =
::toupper(*i); };
return o; }
80 inline std::string
str(
size_t n) {
char buf[20]; sprintf(buf,
"%lu", n);
return buf; }
82 inline std::string
str(
int n) {
char buf[20]; sprintf(buf,
"%d", n);
return buf; }
84 inline std::string
str(
char c) {
char buf[2] = {
c, 0};
return buf; }
86 inline std::string
str(
double n,
const char *fmt =
"%f") {
char buf[20]; sprintf(buf, fmt, n);
return buf; }
91 inline std::string
str(
const T& var)
93 std::ostringstream ss;
101 demangling_error(
const char* s): std::runtime_error((
"While demangling " + std::string(s)).c_str()) {}
105 inline std::string
type_name(
const std::type_info &ti){
110 inline std::string
type_name(
const std::type_info &ti){
113 char * tmp = abi::__cxa_demangle(ti.name(), 0, 0, &status);
114 std::string name = tmp;
134 return type_name<T>();
137 namespace Util = util;
141 using namespace peyton::util;