libwreport 3.42
wreport::str Namespace Reference

String functions. More...

Data Structures

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

Functions

bool startswith (const std::string &str, const std::string &part)
 Check if a string starts with the given substring.
 
bool endswith (const std::string &str, const std::string &part)
 Check if a string ends with the given substring.
 
template<typename ITER>
std::string join (const std::string &sep, const ITER &begin, const ITER &end)
 Stringify and join a sequence of objects.
 
template<typename ITEMS>
std::string join (const std::string &sep, const ITEMS &items)
 Stringify and join an iterable container.
 
std::string lstrip (const std::string &str)
 Return the substring of 'str' without all leading spaces.
 
std::string rstrip (const std::string &str)
 Return the substring of 'str' without all trailing spaces.
 
std::string strip (const std::string &str)
 Return the substring of 'str' without all leading and trailing spaces.
 
std::string upper (const std::string &str)
 Return an uppercased copy of str.
 
std::string lower (const std::string &str)
 Return a lowercased copy of str.
 
std::string basename (const std::string &pathname)
 Given a pathname, return the file name without its path.
 
std::string dirname (const std::string &pathname)
 Given a pathname, return the directory name without the file name.
 
void appendpath (std::string &dest, const char *path2)
 Append path2 to path1, adding slashes when appropriate.
 
void appendpath (std::string &dest, const std::string &path2)
 Append path2 to path1, adding slashes when appropriate.
 
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.
 
template<typename... Args>
std::string joinpath (Args... components)
 Join two or more paths, adding slashes when appropriate.
 
std::string normpath (const std::string &pathname)
 Normalise a pathname.
 
std::string encode_cstring (const std::string &str)
 Escape the string so it can safely used as a C string inside double quotes.
 
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.
 
std::string encode_url (const std::string &str)
 Urlencode a string.
 
std::string decode_url (const std::string &str)
 Decode an urlencoded string.
 
std::string encode_base64 (const std::string &str)
 Encode a string in Base64.
 
std::string encode_base64 (const void *data, size_t size)
 Encode a buffer in Base64.
 
std::string decode_base64 (const std::string &str)
 Decode a string encoded in Base64.
 

Detailed Description

String functions.

Author
Enrico Zini enric.nosp@m.o@en.nosp@m.ricoz.nosp@m.ini..nosp@m.org

Copyright (C) 2007–2015 Enrico Zini enric.nosp@m.o@de.nosp@m.bian..nosp@m.org

Function Documentation

◆ decode_cstring()

std::string wreport::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)

◆ normpath()

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

Normalise a pathname.

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