wibble::str Namespace Reference

## Classes

class | Split
| Split a string where a given substring is found. More...
class | YamlStream
| Parse a record of Yaml-style field: value couples. More...

## Functions

std::string | fmtf (const char *f,...)
std::string | fmt (const char *f,...)
std::string | normpath (const std::string &pathname)
| Normalise a pathname. More...
std::string | urlencode (const std::string &str)
| Urlencode a string. More...
std::string | urldecode (const std::string &str)
| Decode an urlencoded string. More...
std::string | encodeBase64 (const std::string &str)
| Encode a string in Base64. More...
std::string | decodeBase64 (const std::string &str)
| Decode a string encoded in Base64. More...
std::string | c_escape (const std::string &str)
| Escape the string so it can safely used as a C string inside double quotes. More...
std::string | c_unescape (const std::string &str, size_t &lenParsed)
| Unescape a C string, stopping at the first double quotes or at the end of the string. More...
template<typename T >
std::string | fmt (const T &val)
| Format any value into a string using a std::stringstream. More...
template<typename X >
TPair< std::ostream, typename X::Type >::First & | operator<< (std::ostream &o, X list)
template<>
std::string | fmt< std::string > (const std::string &val)
template<>
std::string | fmt< char * > (char *const &val)
template<typename C >
std::string | fmt_container (const C &c, char f, char l)
template<typename X >
std::string | fmt (const std::set< X > &val)
template<typename X >
std::string | fmt (const std::vector< X > &val)
template<typename X >
std::string | fmt (const std::deque< X > &val)
std::string | basename (const std::string &pathname)
| Given a pathname, return the file name without its path. More...
std::string | dirname (const std::string &pathname)
| Given a pathname, return the directory name without the file name. More...
bool | startsWith (const std::string &str, const std::string &part)
| Check if a string starts with the given substring. More...
bool | endsWith (const std::string &str, const std::string &part)
| Check if a string ends with the given substring. More...
std::string | replace (const std::string &str, char from, char to)
template<typename FUN >
std::string | trim (const std::string &str, const FUN &classifier)
| Return the substring of 'str' without all leading and trailing characters for which 'classifier' returns true. More...
std::string | trim (const std::string &str)
| Return the substring of 'str' without all leading and trailing spaces. More...
std::string | toupper (const std::string &str)
| Convert a string to uppercase. More...
std::string | tolower (const std::string &str)
| Convert a string to lowercase. More...
std::string | ucfirst (const std::string &str)
| Return the same string, with the first character uppercased. More...
std::string | joinpath (const std::string &path1, const std::string &path2)
| Join two paths, adding slashes when appropriate. More...
std::string | appendpath (const std::string &path1, const std::string &path2)
template<typename ITER >
std::string | join (const ITER &begin, const ITER &end, const std::string &sep=", ")

## Function Documentation

## appendpath()

std::string wibble::str::appendpath | ( | const std::string & | path1,
|  | const std::string & | path2
| ) |  |

inline

References decodeBase64(), encodeBase64(), joinpath(), urldecode(), and urlencode().

## basename()

std::string wibble::str::basename | ( | const std::string & | pathname | ) |

inline

Given a pathname, return the file name without its path.

Referenced by wibble::net::http::FileParam::FileInfo::read().

## c_escape()

std::string wibble::str::c_escape | ( | const std::string & | str | ) |

Escape the string so it can safely used as a C string inside double quotes.

Referenced by wibble::str::YamlStream::end(), and wibble::sys::Buffer::print_preview().

## c_unescape()

std::string wibble::str::c_unescape | ( | const std::string & | str,
|  | size_t & | lenParsed
| ) |  |

Unescape a C string, stopping at the first double quotes or at the end of the string.

lenParsed is set to the number of characters that were pased (which can be greather than the size of the resulting string in case escapes were found)

Referenced by wibble::str::YamlStream::end().

## decodeBase64()

std::string wibble::str::decodeBase64 | ( | const std::string & | str | ) |

Decode a string encoded in Base64.

Referenced by appendpath().

## dirname()

std::string wibble::str::dirname | ( | const std::string & | pathname | ) |

inline

Given a pathname, return the directory name without the file name.

References normpath().

## encodeBase64()

std::string wibble::str::encodeBase64 | ( | const std::string & | str | ) |

Encode a string in Base64.

Referenced by appendpath().

## endsWith()

bool wibble::str::endsWith | ( | const std::string & | str,
|  | const std::string & | part
| ) |  |

inline

Check if a string ends with the given substring.

Referenced by wibble::tests::TestEndsWith::check(), and wibble::tests::test_assert_endswith().

## fmt() [1/5]

template<typename T >

std::string wibble::str::fmt | ( | const T & | val | ) |

inline

Format any value into a string using a std::stringstream.

## fmt() [2/5]

template<typename X >

std::string wibble::str::fmt | ( | const std::set< X > & | val | ) |

inline

References fmt_container().

## fmt() [3/5]

template<typename X >

std::string wibble::str::fmt | ( | const std::vector< X > & | val | ) |

inline

References fmt_container().

## fmt() [4/5]

template<typename X >

std::string wibble::str::fmt | ( | const std::deque< X > & | val | ) |

inline

References fmt_container().

## fmt() [5/5]

std::string wibble::str::fmt | ( | const char * | f,
|  |  | ...
| ) |  |

Referenced by wibble::assert_list_eq_fn(), fmt_container(), operator<<(), and wibble::commandline::Int::toString().

## fmt< char * >()

template<>

std::string wibble::str::fmt< char *> | ( | char *const & | val | ) |

inline

## fmt< std::string >()

template<>

std::string wibble::str::fmt< std::string > | ( | const std::string & | val | ) |

inline

## fmt_container()

template<typename C >

std::string wibble::str::fmt_container | ( | const C & | c,
|  | char | f,
|  | char | l
| ) |  |

inline

References fmt().

Referenced by fmt().

## fmtf()

std::string wibble::str::fmtf | ( | const char * | f,
|  |  | ...
| ) |  |

Referenced by wibble::net::http::Params::parse_post(), wibble::net::http::FileParam::FileInfo::read(), RunAll::runSuite(), wibble::net::http::error::send(), wibble::net::http::Request::send_result(), wibble::sys::ChildProcess::waitForSuccess(), and wibble::sys::fs::writeFileAtomically().

## join()

template<typename ITER >

std::string wibble::str::join | ( | const ITER & | begin,
|  | const ITER & | end,
|  | const std::string & | sep = `", "`
| ) |  |

References wibble::list::end().

## joinpath()

std::string wibble::str::joinpath | ( | const std::string & | path1,
|  | const std::string & | path2
| ) |  |

inline

Join two paths, adding slashes when appropriate.

Referenced by appendpath(), wibble::sys::fs::findExecutable(), wibble::sys::fs::inode(), normpath(), wibble::net::http::Request::pop_path_info(), and wibble::net::http::FileParam::FileInfo::read().

## normpath()

std::string wibble::str::normpath | ( | const std::string & | pathname | ) |

Normalise a pathname.

For example, A//B, A/./B and A/foo/../B all become A/B.

References wibble::str::Split::begin(), wibble::str::Split::end(), and joinpath().

Referenced by dirname().

## operator<<()

template<typename X >

TPair< std::ostream, typename X::Type >::First& wibble::str::operator<< | ( | std::ostream & | o,
|  | X | list
| ) |  |

inline

References fmt().

## replace()

std::string wibble::str::replace | ( | const std::string & | str,
|  | char | from,
|  | char | to
| ) |  |

inline

## startsWith()

bool wibble::str::startsWith | ( | const std::string & | str,
|  | const std::string & | part
| ) |  |

inline

Check if a string starts with the given substring.

Referenced by wibble::tests::TestStartsWith::check(), and wibble::tests::test_assert_startswith().

## tolower()

std::string wibble::str::tolower | ( | const std::string & | str | ) |

inline

Convert a string to lowercase.

Referenced by wibble::net::mime::Reader::read_headers(), and ucfirst().

## toupper()

std::string wibble::str::toupper | ( | const std::string & | str | ) |

inline

Convert a string to uppercase.

Referenced by wibble::net::http::Request::read_method(), and ucfirst().

## trim() [1/2]

template<typename FUN >

std::string wibble::str::trim | ( | const std::string & | str,
|  | const FUN & | classifier
| ) |  |

inline

Return the substring of 'str' without all leading and trailing characters for which 'classifier' returns true.

References wibble::list::end().

Referenced by wibble::net::mime::Reader::read_headers(), and trim().

## trim() [2/2]

std::string wibble::str::trim | ( | const std::string & | str | ) |

inline

Return the substring of 'str' without all leading and trailing spaces.

References wibble::list::end(), and trim().

## ucfirst()

std::string wibble::str::ucfirst | ( | const std::string & | str | ) |

inline

Return the same string, with the first character uppercased.

References tolower(), and toupper().

## urldecode()

std::string wibble::str::urldecode | ( | const std::string & | str | ) |

Decode an urlencoded string.

Referenced by appendpath(), and wibble::net::http::Params::parse_urlencoded().

## urlencode()

std::string wibble::str::urlencode | ( | const std::string & | str | ) |

Urlencode a string.

Referenced by appendpath().