libscstring/string_utils.hpp

72 lines
3.0 KiB
C++
Raw Normal View History

2020-03-16 15:16:35 +01:00
/*
* string_utils.h
*
* Created by Bob Polis on 27-06-2006.
* Copyright 2006-2015 Thalictrum. All rights reserved.
*
*/
#ifndef _string_utils_
#define _string_utils_
#include <vector>
#include <string>
#include <map>
#include <regex>
namespace sc {
std::vector<std::string> split (const std::string& str,
const std::string& sep);
std::vector<std::string> split (const std::string& str,
const std::regex& sep);
2020-03-16 15:16:35 +01:00
std::string join (const std::vector<std::string>& components,
const std::string& join);
std::string trim (const std::string& str,
const std::string& del = " ");
std::string str_replace (const std::string& what,
2020-03-16 15:16:35 +01:00
const std::string& replacement,
const std::string& target);
std::wstring replace_all (const std::wstring& what,
const std::wstring& replacement,
const std::wstring& target);
bool file_exists (const std::string& path);
2020-03-16 15:16:35 +01:00
std::string file_get_contents (const std::string& path);
2020-03-16 15:16:35 +01:00
std::map<std::string, std::string> parse_ini_file (const std::string& path);
void create_dir (const std::string& path,
int mode = 0777);
std::string dirname (const std::string& path);
std::string basename (const std::string& path, bool remove_extension = false);
std::string replace_tilde (const std::string& path);
std::string filename_extension (const std::string& path);
2020-03-16 15:16:35 +01:00
std::string tool_path (const std::string& name);
std::string truncate (const std::string& str, unsigned int maxlen, int how = 0);
std::string lowercase (const std::string& str, const std::locale& loc);
std::string uppercase (const std::string& str, const std::locale& loc);
bool is_valid_utf8 (const std::string& str);
2020-03-16 15:16:35 +01:00
std::string real_path (const std::string& path);
std::string remove_accents (const std::string& text);
2020-03-16 15:16:35 +01:00
}
#endif // _string_utils_