libept
Classes | Functions
ept::str Namespace Reference

Classes

struct  Split
 Split a string where a given substring is found. More...
 

Functions

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...
 
void appendpath (std::string &dest, const char *path2)
 Append path2 to path1, adding slashes when appropriate. More...
 
void appendpath (std::string &dest, const std::string &path2)
 Append path2 to path1, adding slashes when appropriate. More...
 
std::string joinpath (const std::string &path1, const std::string &path2)
 
std::string normpath (const std::string &pathname)
 Normalise a pathname. More...
 
std::string encode_cstring (const std::string &str)
 Escape the string so it can safely used as a C string inside double quotes. More...
 
std::string decode_cstring (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...
 
std::string encode_url (const std::string &str)
 Urlencode a string. More...
 
std::string decode_url (const std::string &str)
 Decode an urlencoded string. More...
 
std::string encode_base64 (const std::string &str)
 Encode a string in Base64. More...
 
std::string decode_base64 (const std::string &str)
 Decode a string encoded in Base64. 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...
 
template<typename ITER >
std::string join (const std::string &sep, const ITER &begin, const ITER &end)
 Stringify and join a sequence of objects. More...
 
template<typename ITEMS >
std::string join (const std::string &sep, const ITEMS &items)
 Stringify and join an iterable container. More...
 
template<typename FUN >
std::string lstrip (const std::string &str, const FUN &classifier)
 Return the substring of 'str' without all leading characters for which 'classifier' returns true. More...
 
std::string lstrip (const std::string &str)
 Return the substring of 'str' without all leading spaces. More...
 
template<typename FUN >
std::string rstrip (const std::string &str, const FUN &classifier)
 Return the substring of 'str' without all trailing characters for which 'classifier' returns true. More...
 
std::string rstrip (const std::string &str)
 Return the substring of 'str' without all trailing spaces. More...
 
template<typename FUN >
std::string strip (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 strip (const std::string &str)
 Return the substring of 'str' without all leading and trailing spaces. More...
 
std::string upper (const std::string &str)
 Return an uppercased copy of str. More...
 
std::string lower (const std::string &str)
 Return a lowercased copy of str. More...
 
template<typename S1 , typename S2 , typename... Args>
void appendpath (std::string &dest, S1 first, S2 second, Args... next)
 Append an arbitrary number of path components to dest. More...
 
template<typename... Args>
std::string joinpath (Args... components)
 Join two or more paths, adding slashes when appropriate. More...
 

Function Documentation

◆ appendpath() [1/3]

void ept::str::appendpath ( std::string &  dest,
const char *  path2 
)

Append path2 to path1, adding slashes when appropriate.

Referenced by appendpath(), joinpath(), and lower().

◆ appendpath() [2/3]

void ept::str::appendpath ( std::string &  dest,
const std::string &  path2 
)

Append path2 to path1, adding slashes when appropriate.

Referenced by joinpath(), and normpath().

◆ appendpath() [3/3]

template<typename S1 , typename S2 , typename... Args>
void ept::str::appendpath ( std::string &  dest,
S1  first,
S2  second,
Args...  next 
)

Append an arbitrary number of path components to dest.

References appendpath().

◆ basename()

std::string ept::str::basename ( const std::string &  pathname)

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

Referenced by lower().

◆ decode_base64()

std::string ept::str::decode_base64 ( const std::string &  str)

Decode a string encoded in Base64.

References res.

Referenced by ept::str::Split::end().

◆ decode_cstring()

std::string ept::str::decode_cstring ( 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)

References res.

Referenced by ept::str::Split::end().

◆ decode_url()

std::string ept::str::decode_url ( const std::string &  str)

Decode an urlencoded string.

References res.

Referenced by ept::str::Split::end().

◆ dirname()

std::string ept::str::dirname ( const std::string &  pathname)

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

Referenced by lower(), and ept::sys::makedirs().

◆ encode_base64()

std::string ept::str::encode_base64 ( const std::string &  str)

Encode a string in Base64.

References res.

Referenced by ept::str::Split::end().

◆ encode_cstring()

std::string ept::str::encode_cstring ( const std::string &  str)

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

References res.

Referenced by ept::str::Split::end(), and ept::tests::ActualCString::operator==().

◆ encode_url()

std::string ept::str::encode_url ( const std::string &  str)

Urlencode a string.

References res.

Referenced by ept::str::Split::end().

◆ endswith()

bool ept::str::endswith ( const std::string &  str,
const std::string &  part 
)
inline

Check if a string ends with the given substring.

Referenced by ept::tests::ActualStdString::ActualStdString(), ept::tests::assert_endswith(), and ept::tests::ActualCString::isfalse().

◆ join() [1/2]

template<typename ITER >
std::string ept::str::join ( const std::string &  sep,
const ITER &  begin,
const ITER &  end 
)

Stringify and join a sequence of objects.

References res.

◆ join() [2/2]

template<typename ITEMS >
std::string ept::str::join ( const std::string &  sep,
const ITEMS &  items 
)

Stringify and join an iterable container.

References res.

◆ joinpath() [1/2]

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

◆ joinpath() [2/2]

template<typename... Args>
std::string ept::str::joinpath ( Args...  components)

Join two or more paths, adding slashes when appropriate.

References appendpath(), normpath(), and res.

◆ lower()

std::string ept::str::lower ( const std::string &  str)
inline

Return a lowercased copy of str.

References appendpath(), basename(), dirname(), and res.

◆ lstrip() [1/2]

template<typename FUN >
std::string ept::str::lstrip ( const std::string &  str,
const FUN &  classifier 
)
inline

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

Referenced by lstrip().

◆ lstrip() [2/2]

std::string ept::str::lstrip ( const std::string &  str)
inline

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

References lstrip().

◆ normpath()

std::string ept::str::normpath ( const std::string &  pathname)

Normalise a pathname.

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

References appendpath(), and res.

Referenced by ept::sys::abspath(), and joinpath().

◆ rstrip() [1/2]

template<typename FUN >
std::string ept::str::rstrip ( const std::string &  str,
const FUN &  classifier 
)
inline

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

Referenced by rstrip().

◆ rstrip() [2/2]

std::string ept::str::rstrip ( const std::string &  str)
inline

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

References rstrip().

◆ startswith()

bool ept::str::startswith ( const std::string &  str,
const std::string &  part 
)
inline

Check if a string starts with the given substring.

Referenced by ept::tests::ActualStdString::ActualStdString(), ept::tests::assert_startswith(), and ept::tests::ActualCString::isfalse().

◆ strip() [1/2]

template<typename FUN >
std::string ept::str::strip ( const std::string &  str,
const FUN &  classifier 
)
inline

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

Referenced by strip().

◆ strip() [2/2]

std::string ept::str::strip ( const std::string &  str)
inline

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

References strip().

◆ upper()

std::string ept::str::upper ( const std::string &  str)
inline

Return an uppercased copy of str.

References res.