You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

36 lines
1.2 KiB

#ifndef STRINGUTILS_H
#define STRINGUTILS_H
#include <string>
#include <vector>
const std::string toLowercase(const std::string &str);
// should be moved to URL
const std::string getFilenameExtension(std::string const& fileName);
const std::string getDocumentFromURL(const std::string &url);
const std::string getHostFromURL(const std::string &url);
const std::string getSchemeFromURL(const std::string &url);
std::vector<std::string> split(const std::string &text, char sep);
std::vector<std::string> parseSepButNotBetween(std::string string, std::string sep, std::vector<std::string> open, std::vector<std::string> close);
// from https://stackoverflow.com/a/25385766/7697705
// trim from end of string (right)
inline std::string& rtrim(std::string& s, const char* t = " \t\n\r\f\v") {
s.erase(s.find_last_not_of(t) + 1);
return s;
}
// trim from beginning of string (left)
inline std::string& ltrim(std::string& s, const char* t = " \t\n\r\f\v") {
s.erase(0, s.find_first_not_of(t));
return s;
}
// trim from both ends of string (left & right)
inline std::string& trim(std::string& s, const char* t = " \t\n\r\f\v") {
return ltrim(rtrim(s, t), t);
}
#endif